0

Hey, I have a little problem that I can't resolve, maybe you can:

I want to write in a textbox a number, let's say 3.
Then I'll click on a button and in the combobox it'll add the items 1, 2 and 3.

Thank you for helping!

5
Contributors
10
Replies
40
Views
4 Years
Discussion Span
Last Post by yagelnnn1
Featured Replies
  • 1

    I would suggest using a numericupdown control, as that will eliminate having to validate the users input. It would be used, in a buttons click event handler, something like this: Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click For I = 1 To NumericUpDown1.Value ComboBox1.Items.Add(I) Next End Sub Read More

0

You need to do following things on click event of Button

1) Write a loop iterating 'n' times where n is textbox input (an integer).
2) within that loop add counter variable as item into Combo Box.

Done.

Edited by Rahul47: Typing Mistakes

0

Hi,

You can find a tutorial, Here
Please try some coding and when you still have some trouble we'll glad to help.

0

That's not what I meant, what you sent is from combobox to listbox, I want from textbox to combobox, but to spread them, like if I'll type 5 in the textbox so it'll add in the combobox: 1, 2, 3, 4 and 5.

0

Please take the time to explain what you want clearly. You said

if I'll type 5 in the textbox so it'll add in the combobox: 1, 2, 3, 4 and 5.

Do you mean you want to do 1+2+3+4+5? Do you mean you want to add the first five items in the combobox? You didn't say what you want to do with the result. If you can't put any effort into the question why should we put any effort into guessing what you want and providing an answer?

0

It's not very complecated to understand, listen, I would like to write on a textbox 5, click on a button
and in the combobox It will add the numbers 1, 2, 3, 4 and 5.

That's it..

1

I would suggest using a numericupdown control, as that will eliminate having to validate the users input. It would be used, in a buttons click event handler, something like this:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    For I = 1 To NumericUpDown1.Value
        ComboBox1.Items.Add(I)
    Next
End Sub
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.