Okay it's 5:10 AM and I've been up all night trying to figure out this simple problem with Visual Basic in Visual Studio 2010 in a new .ASP website project.

I'm in Visual Basic II class and this has nothing to do with any of my assignments, I'm just messing around trying to understand everything better.

I've read pages and pages of forums and websites regarding this issue, but I either don't understand, or it's a similar issue but doesn't fix my exact problem.

I did however figure out how to declare a global variable, by doing using Public instead of Dim at the very top before any of my sub routines go.

I also figured out that I did it right because I no longer had to declare each thing in a different sub routine, like a button event, or whatever else it may be.

However, here is my situation and problem:

I want to click a button, and have a number randomly generated (figured that part out already). This is a one form personal project of mine and I need other sub modules to use the same variable values. My problem is that all modules can see and use my public declared variable, however what my modules do to that variable isn't public.

So basically my code is like :

Public intRandomNumber As Integer(my global variable)

Protected Sub button1(one button event module)

intRandomNumber = 1 or 2 random formula

end sub

Protected Sub button2 (second button event module)

Do something different if intRandomNumber = 1 or 2.

End Sub

But what happens in button1 sub doesn't carry over the value it ended up with for intRandomNumber so intRandomNumber has no value when I get to button2 module.

How do I make what happens in these different modules to the value of my global variable, stick with my global variable globally??

I hope this all makes sense of some sort... lol.