Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default public variable question

is it possible to not only declare a public variable, but also set it to a value
to be used throughout he app?

--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default public variable question

Does the variable change?

If no, then you could use:
Public Const myConst As String = "hi there"

If yes, you could declare the variable as public, but then set it to its
original value in the workbook_open event or auto_open procedure.

Or you could be careful and check it before you try to use it:

Public VarsPopulated as boolean
public myVar as long

----
in some procedu

if varspopulated = false then
call PopulateVars
end if

=========
Sub PopulateVars()
VarsPopulated = true
myVar = 1234
End Sub



Gary Keramidas wrote:

is it possible to not only declare a public variable, but also set it to a value
to be used throughout he app?

--

Gary


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default public variable question

that's what i needed, i had public and const reversed.

thanks again
--


Gary


"Dave Peterson" wrote in message
...
Does the variable change?

If no, then you could use:
Public Const myConst As String = "hi there"

If yes, you could declare the variable as public, but then set it to its
original value in the workbook_open event or auto_open procedure.

Or you could be careful and check it before you try to use it:

Public VarsPopulated as boolean
public myVar as long

----
in some procedu

if varspopulated = false then
call PopulateVars
end if

=========
Sub PopulateVars()
VarsPopulated = true
myVar = 1234
End Sub



Gary Keramidas wrote:

is it possible to not only declare a public variable, but also set it to a
value
to be used throughout he app?

--

Gary


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default public variable question

sorry about the time, that damn vista keeps changing it when i dual boot.

--


Gary


"Dave Peterson" wrote in message
...
Does the variable change?

If no, then you could use:
Public Const myConst As String = "hi there"

If yes, you could declare the variable as public, but then set it to its
original value in the workbook_open event or auto_open procedure.

Or you could be careful and check it before you try to use it:

Public VarsPopulated as boolean
public myVar as long

----
in some procedu

if varspopulated = false then
call PopulateVars
end if

=========
Sub PopulateVars()
VarsPopulated = true
myVar = 1234
End Sub



Gary Keramidas wrote:

is it possible to not only declare a public variable, but also set it to a
value
to be used throughout he app?

--

Gary


--

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
Public Variable Marvin Excel Programming 1 March 29th 07 09:50 PM
Public variable Eric[_35_] Excel Programming 7 March 18th 07 06:54 AM
Declaration of public variable - Question Les Stout[_2_] Excel Programming 2 October 5th 05 02:53 PM
Public Variable Jason Excel Programming 4 April 12th 04 07:06 PM
public variable marwan hefnawy Excel Programming 1 September 5th 03 08:54 AM


All times are GMT +1. The time now is 01:11 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"