Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

some VB Help

ok im writing this VB program in VS 2005 and i cant quite get down how i want it to perform certain things. When the application runs you are going to be able to add usernames, passwords and a display name to a list and the display name will then be shown in a combobox. I am able to update the combobox with the display names and am able to write all 3 to a file but im not sure how to associate usernames and passwords with display names. any suggestions?

basically if i have the second display name selected i want to read the second username and password.
[571 byte] By [Hijikata] at [2007-11-11 9:52:46]
# 1 Re: some VB Help
One solution is to use three ArrayLists: one each for display name, username and password. Assuming that the data is stored in a comma-delimited text file, e.g.:

Name 1,username,password
Name 2,username,password
...etc.

as you read each line from the file, use the Split function to get the three values from the line and assign each value to the corresponding array:

Dim theLine As String = sr.ReadLine
Dim values() As String = Split(theLine, ",")

DisplayNames.Add(values(0))
UserNames.Add(values(1))
Passwords.Add(values(2))

Then, when a user selects a display name from the combobox, you may use the combo's SelectedIndex property to retrieve the associated values from the UserNames and Passwords ArrayLists.
Phil Weber at 2007-11-11 21:45:19 >