Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement class constructor in Visual Basic?

Tags:

vb.net

I just would like to know how to implement class constructor in this language.

like image 858
yonan2236 Avatar asked Jul 19 '10 07:07

yonan2236


People also ask

What is a constructor in Visual Basic?

A constructor in VB.NET is defined as a procedure that has the name New (rather than Initialize as in VB 6.0) and can accept arguments to allow clients to pass data into the instance to assist with initialization. Constructors do not return values and therefore are always declared as a Sub.

How many constructors can a class have in Visual Basic?

In case, if we create a class without having any constructor, the compiler will automatically create a one default constructor for that class. So, there is always one constructor that will exist in every class.


1 Answers

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 
like image 169
Hans Olsson Avatar answered Oct 07 '22 17:10

Hans Olsson