Question Choosing the amount of times a loop, or sub should occur

Haxaro

Well-known member
Joined
Mar 13, 2009
Messages
105
Programming Experience
1-3
I have made an app that the user has to type a number, and i want the process for the app to do this how evermany times the user wishes it to do.

for example, the app is ment to create a line in a text document, so they write in textbox1 what they want written on the line, and then in textbox2, tey say how many lines they want to create.

So,

TextBox1.Text = "BLAA"
TextBox2.Text = "782"

It will create 782 lines of BLAA. not just one...

Thanks in advance.
 
Use a NumericUpDown control for numeric user input. The Value property is a Decimal you can simply convert to an Integer using the CInt conversion function.
For writing a number of lines to a text document use the StreamWriter.
Write the lines with a For loop.
 
Try doing the loop like this:

VB.NET:
Dim str As String 
For howManyTimes = 1 to Cint(textbox2.Text)
   str &= textbox1.Text
Next
Then add the str to the text file after the loop is done.
Consider using the KeyPress event to capture only numbers in your textbox.
 

Latest posts

Back
Top