item in Listbox
dim s as string =""
for each item In me.listbox1.items
s=s & item.tostring & vbcrlf
...
i get this error msg: "Name 'item' is not declared"
Any help would be appreciated.
aLEX
Hi,
try changing the following code line [assuming your listbox is filled with string items]:
For Each item As String In Me.listbox1.Items
...
Andrej
My listbox is filled with strings.
please, help
thanks
According to your error message, the list items are of DataRowView type, not string - you're probably binding to a datatable. Try this:
For Each item As DataRowView In ListBox1.Items
Dim itemText As String = item(ListBox1.DisplayMember).ToString()
...
The reason for "'Item' undeclared" message is that you didn't declare your item variable (in the for each statement) as the same type you're using to fill the listbox.
Andrej