Code Sample
Option Explicit
Private Const MAX As Integer = 30
Private data(1 To MAX) As Integer
Private Function exists(ByRef ar() As Integer, _
ByVal key As Integer) As Boolean
Dim size As Long
size = UBound(ar)
Dim index As Long
index = LBound(ar)
Dim found As Boolean
found = False
Do While index <= size And Not found
If ar(index) = key Then
found = True
Else
index = index + 1
End If
Loop
exists = found
End Function
Private Sub Command1_Click()
Dim whatNum As Integer
whatNum = Val(InputBox("Number?"))
MsgBox exists(data, whatNum)
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim dataStr As String
For i = 1 To MAX
data(i) = Int(Rnd * MAX) + 1
dataStr = dataStr & Str(data(i)) & vbCrLf
Next i
Text1 = dataStr
End Sub