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!

Member Avatar for Rahul47

Are you trying to add range of numbers when you supply upper range in textbox ?

Member Avatar for Rahul47

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.

Can you give me a code or something?

Hi,

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

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.

Somebody?

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?

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..

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

Thank you very much!!!!
It helped me alot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.