Form Show

  • Thread starter Thread starter kirkm
  • Start date Start date
K

kirkm

The Brackets in the Show Command e.g.

frmMyForm.Show ()

... what are they used for?

I thought it was for passing a variable, but if I put
one in the brackets, how can I read it ?

I've tried

Private Sub UserForm_Activate(x)
End Sub

Private Sub UserForm_Initialize(x)
End Sub

Bring up an error 'Procedure declaration does not match description of
event or procedure having the same name'

I can't find a 'Form Load' or any place in properties to use.

What am I doing wrong?


Thanks - Kirk
 
I tried:
Userform1.show()
and it didn't even compile.

One easy way to pass variables to a userform is to use public variables.
Declare them in a General module outside any procedure:

Public myVar as Variant
Public myLong as long
....

Then your can assign what you want to that public variable and pick it up in
your userform code.

Another way is to load the form (not show it), then do the assignments, then
show the userform:

Load UserForm1
UserForm1.CheckBox1.Value = True
UserForm1.Show
 
Dave,

If we want to pull a value back out of the user form, is the only way to do
that with a Public variable?

Thanks,
Barb
 
If you use the Public variables in Private functions, you have remove the
Private from the function names. for example, if you use a public variable
in a click function.
 
I could be wrong, and frequently am, but from what I can see in the Show
Method decription, only DialogBoxes offer the argument () option. It does
not apply to the UserForm.Show method.
 
If the form is still loaded (but hidden???), you can get the value this way:

I put this behind the Ok button on a userform:

Option Explicit
Private Sub CommandButton1_Click()
Me.Hide
End Sub


And I used this to load the form:

Option Explicit
Sub testme()
Dim myStr As String

UserForm1.Show
myStr = UserForm1.TextBox1.Value
Unload UserForm1

MsgBox myStr

End Sub
 

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