哪里有问题?
Private Sub Text2_Change()
Dim y As Long
Dim r As Variant
r = Split( "1. 3. 5. 7. 9. 12. 14. 16. 18. 19. 21. 23. 25. 27. 30. 32. 36 ", ". ", -1, 1)
For y = 0 To 17
If Text2 = r(i) Then
Text3.Text = "通过 "
Else
Text3.Text = "不行 "
End If
end sub
这段代码为何不可以执行呢?
[解决办法]
For y = 0 To 16
If Text2 = r(i) Then
Text3.Text = "通过 "
Else
Text3.Text = "不行 "
End If
split之后,你的数组r,不存在r(17)
[解决办法]
Private Sub Command1_Click()
Dim y As Long
Dim r As Variant
Dim i As Integer
r = Split( "1. 3. 5. 7. 9. 12. 14. 16. 18. 19. 21. 23. 25. 27. 30. 32. 36 ", ". ", -1, 1)
For i = 0 To UBound(r)
If Text2 = r(i) Then
Text3.Text = "通过 "
exit sub '如果你想一旦查找到相同的数就显示‘通过’的话,就要加这个
Else ’不然结果都会是显示‘不行’
Text3.Text = "不行 "
End If
Next i
End Sub
改了一下,加了一个command1,你的for都没有next的