Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() i've programed classes in C++ where you can have functions that are specific to the class and have access to all the variables in the class. how would i need to setup a Sub that would have access to these variables? i want something along the lines of Code: -------------------- Private Sub DrawAddOne(ByVal a As Integer) m_Draw(a) = m_Draw(a) + 1 End Sub -------------------- -- TheIrishThug ------------------------------------------------------------------------ TheIrishThug's Profile: http://www.excelforum.com/member.php...o&userid=29682 View this thread: http://www.excelforum.com/showthread...hreadid=496534 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello TheIrishThug, Unfortunately VBA is not a true object oriented language like C++. A VBA object does not inherit all the properities from a particular class when it is created. Programmers who use other OOLs that start to learn VB or VBA often assume that a Class is a Class. A Class object in VB or VBA is more like Java and nothing like a C or C++ class. I would suggest you read up on VB classes to gain a better understanding of their function and design. Wish I could be more help, but it isn't as simple as your example. Sincerely, Leith Ross -- Leith Ross ------------------------------------------------------------------------ Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465 View this thread: http://www.excelforum.com/showthread...hreadid=496534 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Declare the variables as module level variables perhaps? That is, before any
procedure declarations within the module. -- HTH RP (remove nothere from the email address if mailing direct) "TheIrishThug" wrote in message news:TheIrishThug.20ruga_1135809301.4345@excelforu m-nospam.com... i've programed classes in C++ where you can have functions that are specific to the class and have access to all the variables in the class. how would i need to setup a Sub that would have access to these variables? i want something along the lines of Code: -------------------- Private Sub DrawAddOne(ByVal a As Integer) m_Draw(a) = m_Draw(a) + 1 End Sub -------------------- -- TheIrishThug ------------------------------------------------------------------------ TheIrishThug's Profile: http://www.excelforum.com/member.php...o&userid=29682 View this thread: http://www.excelforum.com/showthread...hreadid=496534 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Declare the variables in the declarations section of the class
(before and outside of any procedure), and make you procedures Public not Private. E.g., Private m_Draw(1 To Whatever) As Whatever Public Sub DrawAddOne(ByVal a As Integer) m_Draw(a) = m_Draw(a) + 1 End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "TheIrishThug" wrote in message news:TheIrishThug.20ruga_1135809301.4345@excelforu m-nospam.com... i've programed classes in C++ where you can have functions that are specific to the class and have access to all the variables in the class. how would i need to setup a Sub that would have access to these variables? i want something along the lines of Code: -------------------- Private Sub DrawAddOne(ByVal a As Integer) m_Draw(a) = m_Draw(a) + 1 End Sub -------------------- -- TheIrishThug ------------------------------------------------------------------------ TheIrishThug's Profile: http://www.excelforum.com/member.php...o&userid=29682 View this thread: http://www.excelforum.com/showthread...hreadid=496534 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to convert cell formula functions to code functions | Excel Discussion (Misc queries) | |||
efficiency: database functions vs. math functions vs. array formula | Excel Discussion (Misc queries) | |||
excel functions and User defined functions | Excel Programming | |||
Class Modules | Excel Programming | |||
RaiseEvent from a class contained in a 2nd class collection? | Excel Programming |