任何人都可以知道如何从 vb6 中的整数数组中找到一个整数吗?
Dim myArray(2) As Integer
myArray(1) = 1001
myArray(2) = 1002
Dim searchTerm As Integer
searchTerm = 1005
Dim flag As Boolean
flag = True
Dim temp As Variant
For Each temp In myArray
If temp = searchTerm Then
flag = False
End If
Next temp
If flag = False Then
MsgBox "find"
End If
我通过使用 For Each 语句得到了解决方案,但我想要使用 Do..Loop 的解决方案?
编辑
Dim myArray(2) As Integer
myArray(0) = 1000
myArray(1) = 1001
myArray(2) = 1002
'Initialise Search Term
Dim searchTerm As Integer
searchTerm = 1001
'Check if a value exists in the Array
If UBound(Filter(myArray, searchTerm)) >= 0 And searchTerm <> "" Then
MsgBox ("Search Term SUCCESSFULLY located in the Array")
Else
MsgBox ("Search Term could NOT be located in the Array")
End If