Results 1 to 2 of 2

Thread: combo boxes..where to start

  1. #1

    Thread Starter
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    combo boxes..where to start

    hey, can any one tell me somewhere, where i can find some thing that explains how to use combo boxes, not anything with API or stuff like that, just the basics


    thanks

  2. #2
    PWNettle
    Guest

    Some Basics

    I usually prefer to set the style of a combobox to '2 - Dropdown List'.

    You can add items to a combo with the combo's AddItem method, for example:
    Code:
    Private Sub Form_Load()
    
      '  Using a combobox named Combo1 with its Style set to 2.
      With Combo1
        .AddItem "Belgium"
        .AddItem "Canada"
        .AddItem "Denmark"
        .AddItem "England"
        .AddItem "France"
        '  Set the ListIndex so that the first item in the combo is selected/displayed.
        .ListIndex = 0
      End With
    
    End Sub
    You can get the currently selected item from a combo with its Text property:
    Code:
    Private Sub Command1_Click()
    
      MsgBox Combo1.Text
      
    End Sub
    If for some reason you want to examine all the values in a combo you can use the ListCount property of the combo to see how many items and the List property to get at the items, for example:
    Code:
    Private Sub Command2_Click()
      Dim intIndex As Integer
      Dim strMsg As String
      
      For intIndex = 0 To Combo1.ListCount - 1
        strMsg = strMsg & Combo1.List(intIndex) & vbCrLf
      Next intIndex
       
      MsgBox strMsg, , ""
      
    End Sub
    Paul

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