Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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
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
Declare variables to a code? Pas Excel Discussion (Misc queries) 6 April 10th 10 01:14 PM
How to pass variables as arguments of a function Excel-craze Excel Worksheet Functions 1 August 12th 09 11:48 AM
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
how to pass on different parameters to VBA Code? Ahmaq Excel Worksheet Functions 2 April 22nd 07 04:30 AM
Having one form show another form's input? Lucosa New Users to Excel 3 June 13th 06 04:16 PM


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

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

About Us

"It's about Microsoft Excel"