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/LondonPilot Jan 12 '20
Ok, so although I can't really see much of what you've done from that screenshot, I'm in front of the computer for a bit, so I was able to try some stuff out myself and put together an example for you. Here's my example code:
Program.vb
Test.vb
Note that, to be able to access
numbersfrom theProgrammodule, I had to:Mark it as "Public" in Test.vb, using the word
Publicinstead ofDimPrefix it with the name of the module that contained it when I wanted to access it in a different module. Note that I wrote
Test.numbers, and not justnumbers.Also:
I created a static constructor in the new module, which is the most convenient place to initialise the array. (You can't just put the initialisation code below the declaration, because it's not in a method.)
Hope that with those examples you're able to get back on track! If you're stuck again, though, please post both files, not just one.