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

VB.Net Arrays

I am trying to read a txt file into an array and then use those string/integer/double values in txt boxes in the user interface. I am able to read the txt file but can't figure out how to automatically update the form when a particular item is selected from the combo box.
The combo box contains one item from the array and there are 3 additional items per selection in the array.
I am not sure but I may be doing something wrong when reading the array or am trying to read the index number of the array and not the value of that index number.

Any help out there?
[586 byte] By [CB77] at [2007-11-11 7:51:10]
# 1 Re: VB.Net Arrays
Please post the code from your combo box's Click or Change events (wherever it is that you're updating the textboxes).
Phil Weber at 2007-11-11 21:48:20 >
# 2 Re: VB.Net Arrays
I have read the array in this manner:

Do
TempName = Readline()
TempShares = Readline()
TempPrice = Readline()
TempDate = Readline()

stkArray(index) = New Stock(Name, Share, Price, Date)

Loop

There are 3 elements in the array with 4 items. So now how do I read just the Name from each element into my combo box collection?
CB77 at 2007-11-11 21:49:20 >
# 3 Re: VB.Net Arrays
Assuming that your textboxes are named txtName, txtShare, txtPrice and txtDate, add the following code to your combobox's SelectedIndexChanged event:

With stkArray(cboBox.SelectedIndex)
txtName.Text = .Name
txtShare.Text = .Share
txtPrice.Text = .Price
txtDate.Text = .Date
End With
Phil Weber at 2007-11-11 21:50:24 >