Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting a Custom Class as a Global variable


I know when a custom class this is the proper syntax
Dim SSheet as New SSched
but I want to know is how to change it globally. I use that same
syntax uptop of the sheet to set it globallly, but it seems like
whenever I access the page or something it resets the variable as a new
variable and all my information is reset.

if I *Dim SSheet as SSched* you know with out the "new" I always get an
error. my question is how do I set a Global Custom Class Variable?


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=544048

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Setting a Custom Class as a Global variable

Xiazer,

I'd declare without the New & use the Workbook_Open method to initialise
(Set x =New x).

I'd probably declare it private to the code module & set Property Get/Set
methods up to access it, but that would be doing a belt & braces job.

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Xiazer" wrote:


I know when a custom class this is the proper syntax
Dim SSheet as New SSched
but I want to know is how to change it globally. I use that same
syntax uptop of the sheet to set it globallly, but it seems like
whenever I access the page or something it resets the variable as a new
variable and all my information is reset.

if I *Dim SSheet as SSched* you know with out the "new" I always get an
error. my question is how do I set a Global Custom Class Variable?


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=544048


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Setting a Custom Class as a Global variable


I've Tried the Set, and am playing with the get, but I can get the code
to run but everytime I do it seems like im reseting my global var to a
New.

I have an Options menu(custom form), and I want to set all those to a
custom class global variable on sheet1.

I created a function that when called from by another sheet it will set
a passed class to the global var of sheet1

*sheet1.SetVartoGlobal (Variable)*

then it is supposed to set to passed variable to the global variable of
sheet1. Although I alway get an error saying that the global variable
doesn't equal anything.

What would be the proper way to access a global variable on sheet1 from
custom form code


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=544048

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Setting a Custom Class as a Global variable

Hi,

From experience if you amend your code you need to re run the
'Workbook_Open' - as I think changing the code resets the global variables.

You would be able to access a public variable on sheet1 (where sheet1 is the
code name - not the sheet name - i.e. what you can change in the properties
window in VBA) as sheet1.variablename, provided variablename has been
declared as public (or has public get/let/set accessors).

As a toy problem try adding the following to the 'ThisWorkbook' code module
of a new workbook;

Option Explicit

Public dOpenDateTime As Date

Private Sub Workbook_Open()

dOpenDateTime = Now

End Sub

Close it and open it again - type;

? ThisWorkbook.dOpenDateTime

In the immediate window & you should get the date/time you opened the file.

In principal I think this is the basis of what you are trying to do. To add
accessors you would change;

Public dOpenDateTime As Date

To;

Private dOpenDateTime As Date

And add;

Public Property Get OpenDateTime() As Date

OpenDateTime = dOpenDateTime

End Property

Public Property Let OpenDateTime(dNewValue As Date)

dOpenDateTime = dNewValue

End Property

I'm using Let as a Date variable type is not an object - otherwise I'd use
Set & need to use Set in my Workbook_Open routine.

Regards,

Chris.

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"Xiazer" wrote:


I've Tried the Set, and am playing with the get, but I can get the code
to run but everytime I do it seems like im reseting my global var to a
New.

I have an Options menu(custom form), and I want to set all those to a
custom class global variable on sheet1.

I created a function that when called from by another sheet it will set
a passed class to the global var of sheet1

*sheet1.SetVartoGlobal (Variable)*

then it is supposed to set to passed variable to the global variable of
sheet1. Although I alway get an error saying that the global variable
doesn't equal anything.

What would be the proper way to access a global variable on sheet1 from
custom form code


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=544048


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 Header Setting Bern Notice Excel Discussion (Misc queries) 1 January 4th 09 04:13 PM
Change Magnification default global setting Steve Setting up and Configuration of Excel 3 November 18th 08 08:39 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
Global Setting For All Workbooks - Filename In Footer TOMB Excel Worksheet Functions 3 April 4th 05 06:53 PM
Excel Global Variable Setting John Baker Excel Programming 8 November 25th 03 02:34 PM


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