do you mean something like this? (or a class that inherits and then
overloads?)
Public Class clsColli
Private colID As Integer
Private colNaam As String
Private colPrijs As Double
Private colOms As String
Public Sub New()
colID = 0
colNaam = ""
colOms = ""
colPrijs = 0
End Sub
Public Sub New(ByVal id As Integer)
Me.New()
colID = id
End Sub
Public Sub New(ByVal naam As String, Optional ByVal oms As String = "",
Optional ByVal prijs As Double = 0)
colID = 0
colNaam = naam
colOms = oms
colPrijs = prijs
End Sub
end class
then you can do as i said
you yust have to keep in mind you can't have 2 constructors w the same type
of parameters
ex.
public sub new(x as integer, y as string)
xke= x
yke= y
end sub
public sub new(x as integer, z as string) ' will give an error, you are
passing an integer and a string 2 times the program won't know w one you
mean
xke= x
zke= y
end sub
'you can do this
public sub new(z as string, x as integer)
xke= x
zke= y
end sub
Public Sub New( ByVal title As String, ByVal qualification As String) '
only two parameters
End Sub
'AND
Public Sub New( ByVal title As String ) ' only one parameters
End Sub
'AND
Public Sub New( ) ' Zero parameters
End Sub
Now your Constructor can be any of the above.
*** Note - here you are overloading constructors. Dont forget, if you
override a constructor, remember to call MyBase.New() from the overridden
constrcutor.
Regards - OHM
'my constructor looks like this
Public Sub New(ByVal title As String, ByVal qualification As String,
ByVal age As Integer)
Me.iTitle = title
Me.iQualification = qualification
Me.iAge = age
End Sub
' I want to implement multiple constructor overloads under this
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.