|
-
Sep 21st, 2003, 02:55 PM
#1
Thread Starter
Junior Member
Ensuring UNIQUE values in arrays
I'm having problems ensuring that one of the values in my array is unique.
I have a file that I open to get the information from, validate it, and then put it into an array of structures.
After validating all the data, I want to make sure that all the IDnumbers are unique. Is there a simple way to do this?
Here is a snippet of the code:
Dim x As Integer : Dim y As Integer : Dim size As Integer
Dim intIndex As Integer : Dim intIndexToRemove As Integer
size = Customers.GetUpperBound(0)
MessageBox.Show("SIZE " & size)
For x = 0 To size - 1
For y = 0 To size
If Customers(x).IDNumber = Customers(y).IDNumber Then
If (Customers(x).Name <> Customers(y).Name) OrElse (Customers(x).Address <> Customers(y).Address) Then
intIndexToRemove = y
For intIndex = intIndexToRemove To UBound(Customers) - 1
Customers(intIndex) = Customers(intIndex + 1)
Next
' Delete the last entry
ReDim Preserve Customers(UBound(Customers) - 1)
size -= 1
End If
End If
Next
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|