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

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Class module constructors

In the class module use the object_Initialize event, e.g.:

Private Sub Class_Initialize()
'Do something
End Sub

In article ,
vivmaha wrote:

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Class module constructors

Hi, this did not work.

Thanks.

"JE McGimpsey" wrote:

In the class module use the object_Initialize event, e.g.:

Private Sub Class_Initialize()
'Do something
End Sub

In article ,
vivmaha wrote:

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Class module constructors

What does "did not work" mean? The Class_Initialize procedure is within the
class module and is automatically called when an instance of the class is
created. VBA does not allow for alternate constructors.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"vivmaha" wrote in message
...
Hi, this did not work.

Thanks.

"JE McGimpsey" wrote:

In the class module use the object_Initialize event, e.g.:

Private Sub Class_Initialize()
'Do something
End Sub

In article ,
vivmaha wrote:

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Class module constructors

Sorry.

When he said "Class_Initialize" i assumed I had to put the class name where
"class" was.

I put "Class_Initialize" and it worked.

Thanks.

Also, is there a destructor in VBA?

"Chip Pearson" wrote:

What does "did not work" mean? The Class_Initialize procedure is within the
class module and is automatically called when an instance of the class is
created. VBA does not allow for alternate constructors.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"vivmaha" wrote in message
...
Hi, this did not work.

Thanks.

"JE McGimpsey" wrote:

In the class module use the object_Initialize event, e.g.:

Private Sub Class_Initialize()
'Do something
End Sub

In article ,
vivmaha wrote:

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Class module constructors

Also, is there a destructor in VBA?

The Terminate method is called when the class is destroyed.

Private Sub Class_Terminate()
' your code here
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"vivmaha" wrote in message
...
Sorry.

When he said "Class_Initialize" i assumed I had to put the class name
where
"class" was.

I put "Class_Initialize" and it worked.

Thanks.

Also, is there a destructor in VBA?

"Chip Pearson" wrote:

What does "did not work" mean? The Class_Initialize procedure is within
the
class module and is automatically called when an instance of the class is
created. VBA does not allow for alternate constructors.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"vivmaha" wrote in message
...
Hi, this did not work.

Thanks.

"JE McGimpsey" wrote:

In the class module use the object_Initialize event, e.g.:

Private Sub Class_Initialize()
'Do something
End Sub

In article ,
vivmaha wrote:

How do i make a constructor in VBA?
I search one the web and help for 'constructor' but found nothing.

Thanks.



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
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
Class Module Bill Martin[_2_] Excel Programming 6 January 25th 06 08:56 PM
Class module Mark[_36_] Excel Programming 2 February 17th 04 03:14 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:07 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"