Exception on ListBox Read

tpra21

Active member
Joined
Oct 21, 2006
Messages
26
Programming Experience
1-3
Below, I am trying to read through a listbox and check for selected items. I am getting the following exception on the following line of code:

Public member Selected on type String not Found
VB.NET:
Expand Collapse Copy
If lstCustInfo.Items(i).Selected = True then

VB.NET:
Expand Collapse Copy
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] lstCustInfo.Items.Count - 1[/SIZE]
[SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] lstCustInfo.Items(i).Selected = [/SIZE][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]     'Grab cusotmer number form selected listbox item[/COLOR][/SIZE]
[SIZE=2]     selectedCustomer = lstCustInfo.Items(i)[/SIZE]
[SIZE=2]     aryCustomerInfo = Split(selectedCustomer, " ")[/SIZE]
[SIZE=2]     customerNumber = aryCustomerInfo(0)[/SIZE]
[SIZE=2][COLOR=#0000ff]     If[/COLOR][/SIZE][SIZE=2] File.Exists(DTPath) [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]       'Prime the loop with first read[/COLOR][/SIZE]
[SIZE=2]       currentRecord = DTReader.ReadLine[/SIZE]
[SIZE=2][COLOR=#0000ff]       Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] DTReader.Peek = -1[/SIZE]
[SIZE=2]           c += 1[/SIZE]
[SIZE=2][COLOR=#0000ff]           If[/COLOR][/SIZE][SIZE=2] dailyTransaction(0) = customerNumber [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]             'Move the input record to the Deck record with a 'P'[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]             'for preferred cusotmer added to the end[/COLOR][/SIZE]
[SIZE=2]             currentRecord2 = currentRecord + ",'P'"[/SIZE]
[SIZE=2]             deckWriter.WriteLine(currentRecord2)[/SIZE]
[SIZE=2][COLOR=#0000ff]           End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2]           currentRecord = DTReader.ReadLine[/SIZE]
[SIZE=2][COLOR=#0000ff]        Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]     End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]   End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] i[/SIZE]

Thanks for any and all help, Adam
 
Listbox in VB.Net winforms and ASP.Net webapps are different controls. Use the different properties that begin with "selected.." in winforms Listbox.
 
Back
Top