Variables

  • Thread starter Thread starter mikeymay
  • Start date Start date
M

mikeymay

I am naming a boolean variable, say Var1 from a textbox in
a user form, I am wanting to call up that variable in a
subsequent sub routine within the macro, but Var1 in the
subsequent code is always empty...

What am I doing wrong
 
Hi
then you have to dim this variable as global (outside your procedure)
 
Did post in Programming, but it seemed to disappear.
Thought maybe someone had deleted it as it was in wrong
board......
 
Frank Kabel said:
Hi
then you have to dim this variable as global (outside your procedure)

Have to ? What happened to "One way is to ..." ? <g>

Best wishes Harald
 
lol

--
Regards
Frank Kabel
Frankfurt, Germany

Harald Staff said:
procedure)

Have to ? What happened to "One way is to ..." ? <g>

Best wishes Harald
 
Tried 'Global Var1 as Boolean' and Var1 is still empty
when code runs.

I have dimensioned Var1 as global in my module and Var1 is
being named in a rountine within the Form (won't let me
dim as Global in Form Declarations) When the code in my
module runs and I want to call up Var1 it's empty.

???????
 
Reposting it here then:

Apart from globals, my preference is to pass variables to the macros that
need them, like this:

Sub tester()
Dim B As Boolean
B = True
Call NextOne(B)
B = Not B
Call ThirdOne(B, "Simon says:")
End Sub

Sub NextOne(B As Boolean)
MsgBox "Next one says " & B
End Sub

Sub ThirdOne(B As Boolean, S As String)
MsgBox S & vbNewLine & B
End Sub

HTH. Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top