Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default userform parameters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default userform parameters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default userform parameters

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default userform parameters

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM
Entering Query Parameters by UserForm David Excel Programming 2 April 29th 04 09:21 AM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"