r/visualbasic • u/Dennis13631 • Jan 12 '20
Need a bit help
So ive done a program and my teacher just casually said its spagheti code and i need to somehow fix it but im totally out of idea how to do that so i would appreciate all help i can get from here!
Here is the code:
https://pastebin.com/qzPbMXh8
6
Upvotes
2
u/Songg45 Jan 12 '20 edited Jan 12 '20
So I took a look at your code, and had made a few enhancements (note: I did not add LondonPilot's suggestions) :
Changed your if text = 1 or 2 or.... to a Regex function.
Made it into a Do While loop exiting by typing "exit"
The Regex function forces text to have a length of 1.
Changed your 25 if then index statements to a select case
Added a closing statement and error message
https://pastebin.com/18HbDEX0