Click here to Skip to main content
15,879,077 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
c# winforms . suppose I enter in value 5 , I want a result in Message box like this 1,2,3,4,5 please tell me best solution.
Posted
Comments
[no name] 20-Jul-14 19:05pm    
I will give the benefit of the doubt here. You really should get a decent book on basic programming and work through it. We can't possibly teach you programming in a forum posting and we sure are not going to be doing your homework for you.

I will show you the way, but you have to put in effort to do it yourself:
1. Create a textbox in the winform to let user enter an integer number, say 5
2. Create a loop that starts from 1 to that integer number
3. At each loop, say at the 3rd loop, convert the current loop count (3) to string and concatenate it with the previous loop counts (1,2), e.g. 1,2,3
4. At the end of the whole loop, show the result in a message box, e.g. 1,2,3,4,5
The End.
Refer:
1. For Loop[^]
2. Messagebox-show[^]
3. Integer to String conversion and string concatenation, Ask Google.
 
Share this answer
 
v2
you've to iterate a loop from starting with 1 and ending with the value entered in the textbox.

to display the result for all values make a string with comma separated within the loop.
 
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