Link to home
Start Free TrialLog in
Avatar of smollah
smollah

asked on

arrays

I'm creating an array. I'm reading in 30 numbers, each of which is between 20 and 100. As I input each number, I only want it to print if it is not a duplicate. Would I use a one-dimensional array?
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

A one-dimensional array is sufficient.

Function InArray(arr() as Long, X As Long) As Boolean
Dim I As Integer
Dim Done As Boolean

InArray = False      'Assume not found

Done = True
I = LBound(arr)
Do While Not Done
   If X = arr(I) Then
      Done = True
      InArray = True
   ElseIf I = UBound(Arr) Then
      Done = True
   Else
      I = I + 1
   End If
Loop
     
End Function

Anthony
ASKER CERTIFIED SOLUTION
Avatar of ameba
ameba
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smollah
smollah

ASKER

Thanks for the quick reply!