I have a hashtable that stores sports players: key = jersey number, value = an array of information
...
and what I am trying to do is put this information into combobox (but only showing a certain array elements), so for example say this was the information stored in the hashtable:
(key,{value})
"01",{"john smith","125lbs","qb"}
"02",{"john doe","205lbs","rb"}
so what I have done is created an arraylist that will store the items in the combobox.
but my problem happends when I try to loop through the array from the hashtable values.
(playerlisting is the hashtable)
The above works, however since it's a foreach loop I cannot specify which array indexes I want to add onto the "listitem" string.
But, when I try a simple forloop instead I get a "late binding" error with the 3rd line. Even when I cast the arr(i) as a string I get the error. What needs to be changed? It's very misleading
...
and what I am trying to do is put this information into combobox (but only showing a certain array elements), so for example say this was the information stored in the hashtable:
(key,{value})
"01",{"john smith","125lbs","qb"}
"02",{"john doe","205lbs","rb"}
so what I have done is created an arraylist that will store the items in the combobox.
but my problem happends when I try to loop through the array from the hashtable values.
(playerlisting is the hashtable)
VB.NET:
Dim playerlist As New ArrayList
For Each item As DictionaryEntry In playerlisting
Dim listitem As String = CStr(item.Key)
For Each info As String In CType(item.Value, Array)
listitem += info & " "
Next
playerlist.Add(listitem)
Next
VB.NET:
Dim arr As Array = CType(item.Value, Array)
For i = 0 To arr.Length - 1
listitem += arr(i) & " "
Next
Last edited: