tags:

views:

25

answers:

2

Greetings to all!

I'm a newbie in vb. I just would like to know how to implement class constructor in this language.

Thanks in advance..

A: 

Not sure what you mean with "class constructor" but I'd assume you mean one of the ones below.

Instance constructor:

Public Sub New()

End Sub

Shared constructor:

Shared Sub New()

End Sub
ho1
Class constructor is a VB 6 term for an instance constructor. Alas it is also a OOP term for what you called a shared constructor.
Jonathan Allen
@Jonathan: Thanks, I knew it was an ambigious term, but wasn't sure what it meant where. Btw, your answer is slightly wrong in that a `Shared` constructor can't be `Public`.
ho1
Ugh, that's what I get for typing too fast.
Jonathan Allen
By the way, I just saw a cheat sheet listing `public Foo()` as a "class constructor" in C#. At this point I'm thinking the term is essentially useless.
Jonathan Allen
what do you mean "useless"?
yonan2236
If I say "object constructor" or "static constructor" you know exactly what I mean. If I say "class constructor" you have to ask. That makes it useless to me.
Jonathan Allen
A: 

If you mean VB 6, that would be Private Sub Class_Initialize().

http://msdn.microsoft.com/en-us/library/55yzhfb2(VS.80).aspx

If you mean VB.NET it is Public Sub New() or Shared Sub New().

Jonathan Allen