searching a listbox - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

searching a listbox

Geoff_HGeoff_H Posts: 45Member
How do you search a list box which has both the username and password in one line and separate these to do a if statement to see whether the username of the list box is equal to the textbox. I just need the most basic of search methods. Thanks in advance

Comments

  • kapiloo7kapiloo7 Posts: 45Member
    : How do you search a list box which has both the username and password in one line and separate these to do a if statement to see whether the username of the list box is equal to the textbox. I just need the most basic of search methods. Thanks in advance
    :


    u can do one thing. concatenate those username and password with a comma in between them and add that string to list box. then when ever u have to search a username split that string into an array like this

    [code]
    Dim sUser(2) as string
    Dim i as integer

    For i = 0 to lstListBox.ListCount - 1
    sUser = Split(lstListBox.List(i))
    If sUser(0) = txtUserName.Text Then
    '
    ' do something
    '
    Else
    ' not found
    End If
    Next

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : : How do you search a list box which has both the username and password in one line and separate these to do a if statement to see whether the username of the list box is equal to the textbox. I just need the most basic of search methods. Thanks in advance
    : :
    :
    :
    : u can do one thing. concatenate those username and password with a comma in between them and add that string to list box. then when ever u have to search a username split that string into an array like this
    :
    : [code]
    : Dim sUser(2) as string
    : Dim i as integer
    :
    : For i = 0 to lstListBox.ListCount - 1
    : sUser = Split(lstListBox.List(i))
    : If sUser(0) = txtUserName.Text Then
    : '
    : ' do something
    : '
    : Else
    : ' not found
    : End If
    : Next
    [/code]

    And what would you be splitting then? Nothing?
    You have to specify the Delimiter to use.
    Split "One,Two", ","
    Or...
    Split "One, Two", ", "

    Greets...
    Richard

Sign In or Register to comment.