我的代码运行良好,除非我添加了我不想要的大于或小于数字。如何修改我的代码,以便不需要的号码不会出现在列表框中。同样在我的阵列上,我认为 (10,100) 只会接受数字 10 到 100。
Private Sub GoBtn_Click(sender As Object, e As EventArgs) Handles GoBtn.Click
If GotxtBox.Text < 10 Then
MessageBox.Show("Can not be less than 10")
End If
If GotxtBox.Text > 100 Then
MessageBox.Show("Can not be grater than 100 ")
End If
Dim number As Integer = Val(GotxtBox.Text) ' get number
' add the number to the end of the numberListBox
GoLstBox.Items.Add(number)
If ArrayCountInteger(10, 100) = 10 Then 'only allows 10 numbers but not necessarly 10-100???
MessageBox.Show("You have entered the maximum number of items")
Return
End If
numberArray(ArrayCountInteger(10, 100)) = GotxtBox.Text
ArrayCountInteger(10, 100) += 1
GotxtBox.Clear()
GotxtBox.Focus()
End Sub