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

I'm either horribly confused, or old age is taking its toll. But there seems
to be too many options for declaring variables and I;m having trouble
figuring out the best way for declaring variables.

Tell me if I have it straight:

variables declared at the top of a module are shared within all procedures
in the module, decalred within a procedure/function are available to only
that procedure/function

variables declared Public are available to all modules
- in this workbook only or all workbooks?
- so these should be declared at the top of a module?

variables declared Static retain their values between procedure/function calls
- declare in a procedure/function

variables do not retain their values once hte code stops and control returns
to the user, so if you want to retain values you need to stor ethem in a cell
in the spreadsheet

Sound right?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Declaring Variables

Does these articles help.

http://www.ozgrid.com/VBA/variable-scope-lifetime.htm
http://www.java2s.com/Code/VBA-Excel...sics/Const.htm

"BlairH" wrote:

I'm either horribly confused, or old age is taking its toll. But there seems
to be too many options for declaring variables and I;m having trouble
figuring out the best way for declaring variables.

Tell me if I have it straight:

variables declared at the top of a module are shared within all procedures
in the module, decalred within a procedure/function are available to only
that procedure/function

variables declared Public are available to all modules
- in this workbook only or all workbooks?
- so these should be declared at the top of a module?

variables declared Static retain their values between procedure/function calls
- declare in a procedure/function

variables do not retain their values once hte code stops and control returns
to the user, so if you want to retain values you need to stor ethem in a cell
in the spreadsheet

Sound right?

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Declaring Variables

I notice the specific question marks only now..Answers within brackets


- in this workbook only or all workbooks?
(In this workbook)

- so these should be declared at the top of a module?
(Yes)

variables declared Static retain their values between procedure/function calls
- declare in a procedure/function (Yes)


-variables do not retain their values once hte code stops and control
returns to the user, so if you want to retain values you need to stor ethem
in a cell
in the spreadsheet Sound right?

(Variables declared on top will retain their values all through that
Application session OR until Excel application is closed (assuming they are
not initialised within code))

"Jackpot" wrote:

Does these articles help.

http://www.ozgrid.com/VBA/variable-scope-lifetime.htm
http://www.java2s.com/Code/VBA-Excel...sics/Const.htm

"BlairH" wrote:

I'm either horribly confused, or old age is taking its toll. But there seems
to be too many options for declaring variables and I;m having trouble
figuring out the best way for declaring variables.

Tell me if I have it straight:

variables declared at the top of a module are shared within all procedures
in the module, decalred within a procedure/function are available to only
that procedure/function

variables declared Public are available to all modules
- in this workbook only or all workbooks?
- so these should be declared at the top of a module?

variables declared Static retain their values between procedure/function calls
- declare in a procedure/function

variables do not retain their values once hte code stops and control returns
to the user, so if you want to retain values you need to stor ethem in a cell
in the spreadsheet

Sound right?

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Declaring Variables

Those article sdo help. Thanks.

"Jackpot" wrote:

Does these articles help.

http://www.ozgrid.com/VBA/variable-scope-lifetime.htm
http://www.java2s.com/Code/VBA-Excel...sics/Const.htm

"BlairH" wrote:

I'm either horribly confused, or old age is taking its toll. But there seems
to be too many options for declaring variables and I;m having trouble
figuring out the best way for declaring variables.

Tell me if I have it straight:

variables declared at the top of a module are shared within all procedures
in the module, decalred within a procedure/function are available to only
that procedure/function

variables declared Public are available to all modules
- in this workbook only or all workbooks?
- so these should be declared at the top of a module?

variables declared Static retain their values between procedure/function calls
- declare in a procedure/function

variables do not retain their values once hte code stops and control returns
to the user, so if you want to retain values you need to stor ethem in a cell
in the spreadsheet

Sound right?

Thanks!

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
Declaring Variables Twice? Chad[_12_] Excel Programming 2 May 19th 09 11:48 PM
Declaring variables freekrill Excel Discussion (Misc queries) 2 July 19th 06 06:36 AM
Declaring variables freekrill Excel Discussion (Misc queries) 0 July 18th 06 06:15 PM
Declaring Variables Brad Excel Programming 3 May 12th 04 08:13 PM
Declaring Variables chris brunt Excel Programming 2 August 4th 03 02:02 PM


All times are GMT +1. The time now is 10:53 PM.

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"