Well as my homework i had to investigate about the instruction For....Next and then make a basic program witch im having a hard time finding information about how to even do it.
I Know that For....Next is used to do a instruction a selected amount of times .
I'm trying to make a basic program on VS 2010 With only 1 txtbox (I'm trying to use For ..Next to have to type on the same txtbox 3 times without having to add more boxes i don't know if it possible :C , but how i tryed it , it ends up doing the amount of turns i gived but without even giving me the ability to type on the txtbox again i type 1 time and it finished and when i add a MsgBox it ends up poping 3 of them without leting me type.
Dim Contador As Integer
Dim SM9 As Double
Dim SIM As Double
For Contador = 1 To 3
Next
If Val(txtn.Text) Mod 9 = 0 Then
SM9 = SM9 + Val(txtn.Text)
End If
If Val(txtn.Text) Mod 2 = 0 = False Then
SIM = SIM + Val(txtn.Text)
End If
txtn.Text = String.Empty
lblsim.Text = SIM
lblsumam9.Text = SM9
I have changed the spot of the code multiple times :C
They don't really mix. The loop will continue loop, and when will the user have time to type? It doesn't work.
Maybe try using InputBox?
Also, If Val(txtn.Text) Mod 2 = 0 = False Then, looks funny. Why are there 2 == signs? Are you trying to find even/odd numbers or what? You should only need one =.
Originally Posted by abuckau907
Basically no, not the way you're doing it.
A loop is designed to execute some ## of times.
The GUI is designed to take input at any time.
They don't really mix. The loop will continue loop, and when will the user have time to type? It doesn't work.
Maybe try using an InputBox?
Also, If Val(txtn.Text) Mod 2 = 0 = False Then, looks funny. Why are there 2 == signs? Are you trying to find even/odd numbers or what? You should only need one =.
Trying to find odd numbers that's the first thing that comed up on my main and tryed to try something different lol and it worked.
Also abou Input Box i was looking for a method and well i think that's it thanks alot , i will try it tomarrow since im really sleepy atm
kk. good luck. Update post if you figure it out / need help : )
Code:
Dim userInput As String = ""
Dim userInputINT As Integer = 0
For xx As Int32 = 1 to 3
userInput = InputBox("Please enter a number","The Message Title", "0") '// 0 is default number
userInputINT = CInt(userInput)
If ******
...
Next xx
edit: There is no error-checking, so if the user types "abcd" for the number, the call to CInt() will not be able to convert it to a number, and fail. Just saying.
Originally Posted by abuckau907
kk. good luck. Update post if you figure it out / need help : )
Code:
Dim userInput As String = ""
Dim userInputINT As Integer = 0
For xx As Int32 = 1 to 3
userInput = InputBox("Please enter a number","The Message Title", "0") '// 0 is default number
userInputINT = CInt(userInput)
If ******
...
Next xx
edit: There is no error-checking, so if the user types "abcd" for the number, the call to CInt() will not be able to convert it to a number, and fail. Just saying.
Well Thanks a lot got the simple program done and also i kind of learned how to use InputBoxes a bit ty