Ally
Ally

Reputation: 843

Correct syntax for a constructor in VB?

I was creating a constructor within a class in VB6 but seems the New keyword is a problem that the compiler doesn't allow me to use it I am sure it's a reserved word but why not for a constructor.

Public Sub New(ByVal Name As String)
  'Statements
End Sub

I get the error pointing to the 'New' keyword. Is there a work around for this or any references for VB6?

Upvotes: 2

Views: 885

Answers (1)

Jeandey Boris
Jeandey Boris

Reputation: 743

In VB6 class implementation, constructor and destructor are defined through Class_Initialize and Class_Terminate procedures.

Private Sub Class_Initialize()
'...
End Sub

Private Sub Class_Terminate()
'
End Sub

Upvotes: 5

Related Questions