ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA and Constructors; exist? (https://www.excelbanter.com/excel-programming/336018-vba-constructors%3B-exist.html)

McManCSU[_16_]

VBA and Constructors; exist?
 

Do constructors exist in VBA? All I have seen are static type
variables for the object's variables. For example, if you use the ne
statement, does it just create an object and you have to initialize it
fields, or does it look for a constructor?

Also, for the class module, do you need to export the code to use b
able to save it as the correct object name, say "person.cls"

--
McManCS
-----------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...fo&userid=2437
View this thread: http://www.excelforum.com/showthread.php?threadid=39178


Tom Ogilvy

VBA and Constructors; exist?
 
for a class, I think the initialize event is considered the constructor:

Private Sub Class_Initialize()

End Sub

--
Regards,
Tom Ogilvy


"McManCSU" wrote in
message ...

Do constructors exist in VBA? All I have seen are static typed
variables for the object's variables. For example, if you use the new
statement, does it just create an object and you have to initialize its
fields, or does it look for a constructor?

Also, for the class module, do you need to export the code to use be
able to save it as the correct object name, say "person.cls"?


--
McManCSU
------------------------------------------------------------------------
McManCSU's Profile:

http://www.excelforum.com/member.php...o&userid=24379
View this thread: http://www.excelforum.com/showthread...hreadid=391781




McManCSU[_22_]

VBA and Constructors; exist?
 

Is there a way to do this auto constructor and pass in arguments?

ie: cktbd as new CircuitBoard (size, side

--
McManCS
-----------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...fo&userid=2437
View this thread: http://www.excelforum.com/showthread.php?threadid=39178


Chip Pearson

VBA and Constructors; exist?
 
No, there is only one class constructor and it takes no
arguments.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"McManCSU"
wrote in
message
...

Is there a way to do this auto constructor and pass in
arguments?

ie: cktbd as new CircuitBoard (size, side)


--
McManCSU
------------------------------------------------------------------------
McManCSU's Profile:
http://www.excelforum.com/member.php...o&userid=24379
View this thread:
http://www.excelforum.com/showthread...hreadid=391781





All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com