1
切片我需要的是這樣的:(A,B,C,d,等等。是字符的部分的(名))VB.NET幫助與不同數字
A = 0-40
B = 41-80
C = 81-120
d = 121-160
等
我有一個包含從0到1040的數字的組合框,當我選擇數字(例如80)時,該部分變成C,它應該是B,因爲它在41-80之內,如上所示。以及我選擇120,它變成D,應該是C等。只有1-40的數字完美地工作。這裏是我的代碼:
Dim counter As String
Dim mysection As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
counter = cmbYearAdd.SelectedItem
Dim a As Char = "A"
Dim distinct1% = 1, distinct2% = 40
For x As Integer = counter To 1040
If x >= distinct1 And x <= distinct2 Then
mysection = a
Exit For
Else
a = Chr(Asc(a) + 1)
distinct1 += 40
distinct2 += 40
End If
Next
lblSectionAdd.Text = "Section: " & mysection
End Sub
我有一個標籤,組合框和按鈕。
哇,它完美的作品!謝謝 – Shivr 2015-04-02 12:20:21
很高興我能幫忙。我沒有VB.net的簡單說明。如果你滿意,如果你喜歡,你可以接受我的答案。 – user1016274 2015-04-02 12:31:32