Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a question.

You have 2 textboxes, one listbox and one button.
You have to put one number in each of the textboxes then when you click the button the numbers are supposed to be in the textbox and be arranged as follows...

You put number 1 on the first text box then number 4 on the other textbox, the listbox should contain, 1 2 3 4 respectively, help please!
Posted
Updated 7-Dec-11 22:30pm
v2
Comments
Dalek Dave 8-Dec-11 4:30am    
Edited for Grammar and Readability.
OriginalGriff 8-Dec-11 4:41am    
That doesn't make a lot of sense - where did 2 and 3 come from? Why does the list box get 1 and 4 when you didn't tell it to?
Use the "Improve question" widget to edit your question and provide better information.
[no name] 8-Dec-11 4:44am    
maybe the range from 1-4
paulroa 8-Dec-11 4:47am    
yes it is supposed to be like that, when you out 1 in the first textbox and 4 in the other textbox and click the button the listbox should contain 1 2 3 4 respectively.
paulroa 8-Dec-11 13:20pm    
How do you sort the numbers in the list box in descending order

1 solution

Try this one:

C#
int firstNumber = Convert.ToInt32(TextBox1.Text);
int secondNumber = Convert.ToInt32(TextBox2.Text);

for(int i = firstnumber ; i < secondNumber; i++)
{
   ListBox1.Items.Add(i);
}


Regards,
Eduard
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900