Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pass Variables into Form's code
How do I pass a variable from a standard module into
the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pass Variables into Form's code
Stuart,
Declare it as a public variable in the Declarations section of a normal code module, and it will be available to the userform. -- HTH Bob Phillips "Stuart" wrote in message ... How do I pass a variable from a standard module into the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pass Variables into Form's code
Hi Stuart,
There are several approaches. One is to define a property in the Form. Something like: Dim m_HideSameCols As Boolean Public Property Set HideSameCols(byval a_bHideAs Boolean) m_HideSameCols = a_bHide End Property Then from your caller you would use: Load GetUserWkbk_PrintOptions GetUserWkbk_PrintOptions.HideSameCols = Global_HideSameCols GetUserWkbk_PrintOptions.Show Alternatively if you define Global_HideSameCols in a code module as: Global Global_HideSameCols As Boolean it will also be visible in your form. I would generally use the second method, because it involves less typing (and also because your variable name says it global <g), although the good design mafia (who deprecate global variables) would no doubt advocate the first. HTH Peter Beach "Stuart" wrote in message ... How do I pass a variable from a standard module into the code behind a form, please? Eg I would like to pass "Global_HideSameCols" which is dimmed as Boolean, to the form "GetUserWkbk_PrintOptions" and use it in the initialise event: Private Sub UserForm_Initialize 'Fill the ListBox With GetUserWkbk_PrintOptions.ListBox1 If Global_HideSameCols = False Then .RowSource = "" etc Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pass Variables into Form's code
Peter used it as part of the name--not the variable itself. And Peter did it to
make sure the next person (him in 2 weeks?) recognizes that it's available to all the modules. Stuart wrote: Many thanks to you both.....Global statements then, I think. I thought a variable beginning 'Global...' might not be considered advisable! Regards. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Declare variables to a code? | Excel Discussion (Misc queries) | |||
How to pass variables as arguments of a function | Excel Worksheet Functions | |||
Not at all clear on use of variables and/or object variables | Excel Discussion (Misc queries) | |||
how to pass on different parameters to VBA Code? | Excel Worksheet Functions | |||
Having one form show another form's input? | New Users to Excel |