r/visualbasic • u/Allegiance10 • May 06 '19
Global Variables Help
I’m working on small project for class right now, and I’m having nothing but issues getting global variables to work. What is the easiest way to do this? I have them declared on Form1 as Public and I’m trying to use them on Form2 in order to save a value, then use that value on Form1. Using VisualStudio.
Any help is greatly appreciated!
5
Upvotes
3
u/ostreddit May 06 '19
If you want to make them in the form declare them as public at the top of your Form1 code window.
Public intScore as Integer
To access it from another Form:
Form1.intScore += 1
It would be better practice to put them in a module, but not necessary.