VB.NET: I Cant find the index of an array
Posted
by steve
on Stack Overflow
See other posts from Stack Overflow
or by steve
Published on 2010-04-15T08:39:59Z
Indexed on
2010/04/15
11:03 UTC
Read the original article
Hit count: 194
This is the code for my array (which is working)
Public numUsers As Integer
Public fNameUsers As String = ("..\..\..\users.txt")
Public UserRecords As Usersclass() 'note... this line is in a module '
reader = New System.IO.StreamReader(fNameUsers)
numUsers = 0
'Split the array up at each delimiter of "," and add new objects '
Do While reader.Peek <> -1
ReDim Preserve UserRecords(numUsers)
oneline = reader.ReadLine
fields = oneline.Split(",")
UserRecords(numUsers) = New Usersclass
UserRecords(numUsers).AccountNumber = fields(0)
UserRecords(numUsers).CourseName = fields(1)
UserRecords(numUsers).FirstName = fields(2)
UserRecords(numUsers).LastName = fields(3)
UserRecords(numUsers).DOB = fields(4)
UserRecords(numUsers).Email = fields(5)
UserRecords(numUsers).CourseProgress = (6)
UserRecords(numUsers).AdminCheck = fields(7)
numUsers = numUsers + 1
Loop
reader.Close()
My problem is that I don't know how to lookup the index of an array where the .accountNumber = a variable. For example the acccountNumber is 253, what is the code to find the index this relates to????
Thanks in advance
© Stack Overflow or respective owner