lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I want to define a variable as a global so I can use it on all other sub()s in the module. It is working fine but I noticed one thing. If I created a new sub, lets say sub4(), then this sub4() will not be able to get the value of x unless I go to sub1() and run it again. Why is that? I thought once I run sub1() for the first time then X will be fixed (whatever user going to enter) for all current and future subs
I want to define a variable as a global so I can use it on all other sub()s in the module. It is working fine but I noticed one thing. If I created a new sub, lets say sub4(), then this sub4() will not be able to get the value of x unless I go to sub1() and run it again. Why is that? I thought once I run sub1() for the first time then X will be fixed (whatever user going to enter) for all current and future subs
Code:
dim x as integer
sub sub1()
x=inputbox("input number")
end sub
sub sub2()
msgbox x
end sub
sub sub3()
msgbox x
end sub
Last edited: