Results 1 to 4 of 4

Thread: Ok, ok, I got a good one...

  1. #1

    Thread Starter
    Addicted Member Daniel_Christie's Avatar
    Join Date
    Jan 2000
    Location
    USA
    Posts
    245
    I need to check if the user's name has been added into a listbox. As soon as it is I need to change the user form's caption to display the correct status.

    Code:
    If lstConnections.AddItem = txtName.Text Then
    frmMain.Caption = "SmallTalk -  Now Serving"
    End If
    This is the code I thought would work, but actually it stirs the following error, "Compile error - Argumant not optional."

    Why did I get this error and How will I be able to check for the user's name added to the listbox in order to be able to set the correct status for the form's caption?

    I appreciate all of your time and effort,
    Daniel Christie
    VB 5 and 6 Enterprise Editions,
    Html, Java scipt, Vb script,
    & etc...
    http://www.qwcd.com

  2. #2
    Guest
    AddItem is used to add items. Use List(indexnro) instead.

    List(0) for first item, List(1) for second etc.

    You can check number of items with ListIndex. Remember that last List item is List(ListCount - 1).

    ListIndex tell you which one of the items is selected.


    Hope this helps,

  3. #3
    New Member
    Join Date
    Sep 2000
    Posts
    8
    hi

    not sure.... but u may be able to use the "Instr" function to check if what u have in txtname.text is in lstConnections

    hope that give u another option!!

    Sanj

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'if you load the caption when you load the name you
    'don't have to check
    'ie. list1.additem text1.text
    'frmWhat.Caption = What

    'I don't see as you need to check but if you want to

    Code:
    Option Explicit
    
    'this can be any event you load the listbox from
    Private Sub Command1_Click()
        List1.AddItem Text1.Text
        List1_ItemCheck (List1.ListCount - 1)
    End Sub
    
    Private Sub List1_ItemCheck(Item As Integer)
      List1.ListIndex = List1.ListCount - 1
        If List1.Text = Text1.Text Then
           If lstConnections.AddItem = txtName.Text Then
              frmMain.Caption = "SmallTalk -  Now Serving"
          End If
              End If
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width