Consulting

Results 1 to 7 of 7

Thread: Solved: Array & cbos?

  1. #1

    Solved: Array & cbos?

    Hi People

    Basically I have a cbo which displays 1 to 5, I want to use the number selected and * by something else, basically how to I reference the option (number) selected in a cbo?

  2. #2
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    I'm assuming this is a userform?

    [VBA]combobox1.text * 5[/VBA]

    HTH
    Cal
    The most difficult errors to resolve are the one's you know you didn't make.


  3. #3
    Quote Originally Posted by CBrine
    I'm assuming this is a userform?

    [vba]combobox1.text * 5[/vba]
    HTH
    Cal
    Hi

    Yeah its a userform, For a example a user selects the "3" option from the cbo, this number is then included in some calculation, see what I mean

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Just to show it in use Cal:
    [VBA]TextBox1.Value = ComboBox1.Value * 5[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Quote Originally Posted by lucas
    Just to show it in use Cal:
    [vba]TextBox1.Value = ComboBox1.Value * 5[/vba]
    I want to use the value within the combo box to multiply the value, example

    private sub textbox1_afterupdate()
    txttotal = txtcost.text * "value/option selected in the combo box"

    the coding probably wont work, however I am just using it as an illustration

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Why wouldn't you use your ComboBox_AfterUpdate event with your TextBox_AfterUpdate? Using them both and using a private sub to run would make things much easier. So when your combobox or your textbox is changed the routine would fire, keeping it much more dynamic.

    HTH

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    [VBA]Private Sub ComboBox1_Change()
    TextBox1.Value = ComboBox1.Value * TextBox2.Value
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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