Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Class_Initialize


Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2005, 11:10 PM
Legend Legend is offline
Contributor
 
Join Date: Dec 2002
Posts: 539
Default Class_Initialize

I've hardly written any vb in the last year or so, and I've forgotten something....

Can you pass parameters to the default constructor for a class?



E.G.:

The class constructor (for class cTrain):
Code:
Private Sub Class_Initialize(sFlowTag As String, sFieldTag As String) 'Do some stuff End Sub

Then declare an instance:

Code:
Dim Train1 As cTrain Sub test() Set Train1 = New cTrain("AFIC-0160/A","AZSC-0111") End Sub

IIRC, don't I have to set a new instance of the class, THEN call some other initialisation routine?

E.g.:
Code:
Dim Train1 As cTrain Sub test() Set Train1 = New cTrain Train1.SetTags("AFIC-0160/A","AZSC-0111") End Sub
Reply With Quote
  #2  
Old 05-18-2005, 03:33 AM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,256
Default

If you try to compile the 'Intialise' event code above, you'll have your answer You can't add/remove arguments to the argument list for a procedure without modifying the procedure architecture itself. Your approach correction is correct
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #3  
Old 05-18-2005, 06:19 PM
Legend Legend is offline
Contributor
 
Join Date: Dec 2002
Posts: 539
Default

Quote:
Originally Posted by Timbo
If you try to compile the 'Intialise' event code above, you'll have your answer You can't add/remove arguments to the argument list for a procedure without modifying the procedure architecture itself. Your approach correction is correct
Yes - I got the compile error, but it was not in the class - it was when I tried to call the constructor. I was wondering if there was work-around, but my mind was blank and I'd forgotten.....

Thanks though - it works fine.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:

Powered by liquidweb