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


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default class functions


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default class functions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default class functions

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
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
How to convert cell formula functions to code functions Adnan Excel Discussion (Misc queries) 1 October 1st 08 08:30 PM
efficiency: database functions vs. math functions vs. array formula nickname Excel Discussion (Misc queries) 2 July 14th 06 04:26 AM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM
Class Modules mark Excel Programming 7 April 14th 04 10:10 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM


All times are GMT +1. The time now is 09:19 PM.

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"