Runing Text

Do not Click

Searching data within the array

Saturday 16 January 2010 , Posted by Andi at 03:30

The easiest way to search is to check all the array elements from the smallest index to the largest index of searchable data to be found. Example use in an array of data search is shown in the following programs:

Dim data(5) As Integer
Dim x As Integer
Randomize
For i = 0 To 5
data(i) = Rnd() * 10 + 5
Next

x = InputBox("Entry Data: ", "Input")

For j = 0 To 5
If x = data(j) Then
cek = True
Exit For
Else
cek = False
End If
Next
If cek = True Then
MsgBox ("Found")
Else
MsgBox ("Not Found")
End If

Currently have 0 komentar:

Leave a Reply

Post a Comment

Related Post