Results 1 to 8 of 8

Thread: Combo, Option Button, etc

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    143

    Talking Combo, Option Button, etc

    Sup guys, Im still very new to VB..and Im taking a programming Visual Basic class right now. Our instructor said late this week we're gonna be workin with combo boxes and option buttons..so I wanna get a head start and learn it.

    Im foolin around right now..with the combo boxes..trying to get things added to them. I did a search..and found that only items can be added in the Form_Load section...why is that?

    When I go into the code for the combo box thingie..and put like
    cmb1.additem "hello" it wont list it at runtime...but when I put it in Form Load...it will ....????

    Also...can someone tell me how to or whats the code for like option buttons? how do they work?

    Also...if i want to select like "hello" from my combo box and have it appear in my text box...how do i do that? Thanx!!

  2. #2
    gaffa
    Guest
    You need to load the combo box at runtime, and generally the best place to do it from is the Form_Load event...

    To get the text from the combo try this:
    VB Code:
    1. Text1.Text = Combo1.List(Combo1.ListIndex)

    That will put the selected text of the combo into the text box. This is assuming that the style of the combo box is 2 - Dropdown, and that an item is selected in the combo (if not item is selected, then the ListIndex value will be -1, and the line above will crash...

    - gaffa

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    143
    Thanx....that code sounds good....aint workin. Hmmm

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    combo1.text

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    143
    Cant get it.....anyone else?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    143
    Actually...Gaffa...I just got ur code to work for a List box....

    but I cant get it to work for a combo box...

  7. #7
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I've attached a quick sample that may get you started.
    Attached Files Attached Files

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    143
    Cool thanx buddy !

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