r/visualbasic • u/Shimomura • Feb 01 '16
[VB2015] User Input Loop question
Hello I am working on an visual basic assignment. For what its worth I got it to work/filled the requirements for it but I want to try to get it to work in a loop. So I did a do while loop. And that works as well...but can't exit out of the loop leading me into a infinite loop. Is there anyway for me to exit out properly?
Code pasted here: http://paste.ofcode.org/6Qn5ViBt33442Fwum2CRyZ
6
Upvotes
2
u/ViperSRT3g Application Specialist Feb 01 '16
You forgot to set the value of numInt to something other than -1. Your whole loop there is correctly formatted (aside from not declaring the variable locally) but you don't have anything in there that would affect the conditions of your loop. What the logic is stating in your code, is you type in -1 to start the process. Once it has started, the variable numInt remains at -1 because nothing else changes its value. So you can enter in all the inputs you want, and it will keep asking you for more inputs. If you set the value of numInt to anything else besides -1 when you input a letter, your loop would end immediately.