Results 1 to 6 of 6

Thread: [RESOLVED] How do I get a combo box to add text to a text box?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Resolved [RESOLVED] How do I get a combo box to add text to a text box?

    Please remove this thread. I solved my own question.
    Last edited by i like pizza; Oct 21st, 2011 at 01:12 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] How do I get a combo box to add text to a text box?

    Please do not remove your question simply because you solved it yourself. By doing so you are potentially depriving others from the solution.

    If you had this problem chances are so did, or will, someone else.

    Rather than remove your question, please post your solution (and put your question back).

    Thanks.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Re: [RESOLVED] How do I get a combo box to add text to a text box?

    Okay, here's what I did.

    I created ComboBox11 and TextBox19. I put several strings in the combo box.

    In design mode, I clicked the combobox, and wrote this code....

    Code:
    Private Sub ComboBox11_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox11.SelectedIndexChanged
            TextBox19.Text = TextBox19.Text + ComboBox11.Text
    End Sub
    When I run it, every time I choose a string from the combo box, it adds the string to the text box. I can create a large paragraph this way in the text box by adding one string at a time from the combo box.

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: [RESOLVED] How do I get a combo box to add text to a text box?

    Quote Originally Posted by i like pizza View Post
    Okay, here's what I did.

    I created ComboBox11 and TextBox19. I put several strings in the combo box.

    In design mode, I clicked the combobox, and wrote this code....

    Code:
    Private Sub ComboBox11_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox11.SelectedIndexChanged
            TextBox19.Text = TextBox19.Text + ComboBox11.Text
    End Sub
    When I run it, every time I choose a string from the combo box, it adds the string to the text box. I can create a large paragraph this way in the text box by adding one string at a time from the combo box.
    The + operator is used for maths generally. The & operator is used for string concatenation. When adding the same value together you use +=.

    vb Code:
    1. Private Sub ComboBox1_SelectedIndexChanged()
    2. Me.TextBox1.Text += Me.ComboBox1.Text
    3. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    11

    Re: [RESOLVED] How do I get a combo box to add text to a text box?

    Thanks Ident. What will happen if I leave it the way I did it?

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,401

    Re: [RESOLVED] How do I get a combo box to add text to a text box?

    Quote Originally Posted by i like pizza View Post
    Thanks Ident. What will happen if I leave it the way I did it?
    100% nothing...

    More code = more noise,

    do it other way be a better programmer....

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