arraylist problems

juggernot

Well-known member
Joined
Sep 28, 2006
Messages
173
Programming Experience
Beginner
I would really like to remove and add items to an arraylist within a for each statement. This causes problems however. Does anyone know a way around this?

In my program, you log on to a keyboarding program, and it will load your information( Username, password, words perminute, errors, etc.) Then you do a keyboarding session, and it changes that information. I know need it to save the new information over the previous information. I have it in this for each statement:

For Each myUser As clsUsers In alAllUsers
If (PubUser = myUser.strUsername) Then
alallusers.remove(myuser)
myUser.strPassword = Pubpass
myUser.strUsername = PubUser
myUser.intWPM = pubwpm + WPM / (pubnumberoftrials + 1)
myUser.intNumberofTrials = pubnumberoftrials + 1
myUser.intIncorrect = pubincorrect + incorrect
alAllusers.Add(myUser)
myUser =
Nothing
End If

Note that all users are called myuser, so I don't know if removing myuser would get rid of one or all of them. Help please?!?!
 
VB.NET:
For Each myUser As clsUsers In alAllUsers
  If (PubUser = myUser.strUsername) Then
    myUser.strPassword = Pubpass
    myUser.strUsername = PubUser
    myUser.intWPM = pubwpm + WPM / (pubnumberoftrials + 1)
    myUser.intNumberofTrials = pubnumberoftrials + 1
    myUser.intIncorrect = pubincorrect + incorrect
    '([U]Exit For[/U] here if you are finished after modifying first match)
  End If
Next
 
Back
Top