Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Set Global Variable Inside Object Module

I have a user form that I'd like to establish a global constant, but I
don't know how. I've tried:

Public Const strPW As String = "myPW"

but it errors out saying that this is "not allowed as Public members
of object modules".

Can I declare this publicly so that I don't have to do it in every
subroutine?

Thanks,
Randy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Set Global Variable Inside Object Module

You can remove Public and it will work and still be recognized inside private
subs in your userform.

"Randy" wrote:

I have a user form that I'd like to establish a global constant, but I
don't know how. I've tried:

Public Const strPW As String = "myPW"

but it errors out saying that this is "not allowed as Public members
of object modules".

Can I declare this publicly so that I don't have to do it in every
subroutine?

Thanks,
Randy


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Set Global Variable Inside Object Module

If you want to access it beyond the userform, you can either set it up as a
Public Const in a standard code module rather than the userform, or you
could create a public property of the userform and load it in the form
initialize event.



--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Randy" wrote in message
ups.com...
I have a user form that I'd like to establish a global constant, but I
don't know how. I've tried:

Public Const strPW As String = "myPW"

but it errors out saying that this is "not allowed as Public members
of object modules".

Can I declare this publicly so that I don't have to do it in every
subroutine?

Thanks,
Randy



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Set Global Variable Inside Object Module

Thanks, guys. I know what to do now.

Randy

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
Global (Module) Variable Problem Allen Geddes Excel Programming 2 November 21st 05 03:36 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Create Global Variables in a module Bruce Excel Programming 1 June 1st 04 07:55 AM
Global module Al Excel Programming 2 April 30th 04 12:02 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


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