您好,程序的设计思路是将各个数组添加到某一集合中,对集合中的数组进行遍历查询。请参考下面代码
Dim clt As Collection
Private Sub Command1_Click()
Dim i As Integer, j As Integer
For i = 1 To clt.Count
For j = 0 To UBound(clt(i))
If clt(i)(j) = Val(Text1) Then
MsgBox "在" & trans(i) & "组内"
Exit Sub
End If
Next j
Next i
End Sub
Private Sub Form_Load()
Set clt = New Collection
Dim A, B, C, D
A = Array(1, 5, 9, 13, 17)
clt.Add A
B = Array(2, 6, 10, 14, 18)
clt.Add B
C = Array(3, 7, 11, 15, 19)
clt.Add C
D = Array(4, 8, 12, 16, 20)
clt.Add D
End Sub
Private Function trans(ByVal num As Integer)
Select Case num
Case 1
trans = "A"
Case 2
trans = "B"
Case 3
trans = "C"
Case 4
trans = "D"
End Select
End Function