ListBox Question

  • Thread starter Thread starter cjobes
  • Start date Start date
Claus,

Than you cannot set it in a single string as you did, however have to do
that to an array something as
\\\
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim myarray(ListBox1.SelectedItems.Count - 1) As String
For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
myarray(i) = DirectCast(ListBox1.SelectedItems(i), _
DataRowView)(0).ToString
Next
End Sub
////
 
Cor,

The code that I posted works great. It creates the search string and the
selection comes up in the grid.

Claus
 
Claus,

I was not sure of that, however now I look to it I see what you are up too.
I advise you to try some simple changes.

Dim pickTry As String = ""
Dim drv As DataRowView
For Each drv In pickBox.SelectedItems
If pickTry = "" Then
pickTry = "user='" & drv(0) & "'"
Else
pickTry = pickTry & " or user='" & drv(0) & "'"
End If
Next

The first changes because it does the same and is more standard, the change
from + in & because using the + can give in VBNet give problems. (Not in
this case by the way, however using it standard is not confusing)

Cor
 
Thanks Cor,

Standard is always good and your advice fixed another problem in a different
project where the + didn't seem to work.

Claus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top