Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello - I have a lot of userforms that use global variables that are created
just for the purpose of populating the userforms. Is there a way to create a userform that accepts parameters? How? And what would be the syntax to show the userform ans pass the parameters to it? -- Thanks, Mike |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can easily accept parameters for the userform - but how do you want them
entered? In worksheet cells, or in a dialog box? This shows examples of both, prompting the user for one parameter and taking the second from Cell A1. The userform needs two textboxes, Textbox1 and Textbox2, for this example: Sub TestForm() Dim Param1 As String Param1 = InputBox("Enter Parameter 1:") UserForm1.TextBox1 = Param1 UserForm1.TextBox2 = Range("A1").Value UserForm1.Show End Sub -- - K Dales "Mike Archer" wrote: Hello - I have a lot of userforms that use global variables that are created just for the purpose of populating the userforms. Is there a way to create a userform that accepts parameters? How? And what would be the syntax to show the userform ans pass the parameters to it? -- Thanks, Mike |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike,
You can add customer properties to the userform. e.g. 'Assuming you have textbox called txtTester on this user form. Public Property Let InitText(argText As String) txtTester.Text = argText End Property Or you can create a class that has a reference to a form 'In the class module Dim MyForm As UserFormdataInput Public Propert Let InitText(argText As String) MyForm.txtTester.Text = argText End Property Depends how you wish to reuse the forms that you already have. NickHK "Mike Archer" wrote in message ... Hello - I have a lot of userforms that use global variables that are created just for the purpose of populating the userforms. Is there a way to create a userform that accepts parameters? How? And what would be the syntax to show the userform ans pass the parameters to it? -- Thanks, Mike |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
A userform is just a class module, so it can have properties and methods
exposed to other modules, just like other classes. For example Private mValue As String Public Property Let myValue(pValue As String) mValue = pValue End Property Private Sub UserForm_Activate() TextBox1.Text = mValue End Sub and in a code module, use Load UserForm1 UserForm1.myValue = "Hello" UserForm1.Show -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Mike Archer" wrote in message ... Hello - I have a lot of userforms that use global variables that are created just for the purpose of populating the userforms. Is there a way to create a userform that accepts parameters? How? And what would be the syntax to show the userform ans pass the parameters to it? -- Thanks, Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Userform to enter values and shown in same userform in list | Excel Programming | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
Activating userform and filling it with data form row where userform is activate | Excel Programming | |||
Access from add_in userform to main template userform.... | Excel Programming | |||
Entering Query Parameters by UserForm | Excel Programming |