![]() |
Form Show
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 |
Form Show
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 procedu 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 kirkm wrote: 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 -- Dave Peterson |
Form 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 "Dave Peterson" wrote: 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 procedu 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 kirkm wrote: 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 -- Dave Peterson |
Form Show
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. "Dave Peterson" wrote: 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 procedu 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 kirkm wrote: 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 -- Dave Peterson |
Form Show
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. "kirkm" wrote: 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 |
Form Show
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 Barb Reinhardt wrote: 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 "Dave Peterson" wrote: 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 procedu 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 kirkm wrote: 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 -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 11:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com