Overloading Constructors
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickConstructors provide initialization code when you instantiate objects in Visual Basic .NET or in Visual Basic 2010. If you overload the constructor of a Visual Basic object, you can alter this instantiation process. For example, if you overload the constructor of a class, you can initialize values for properties.
Dim Sedan As New Vehicle()
MessageBox.Show (Sedan.NumberOfWheels.ToString)
Dim TractorTrailer As New Vehicle(18)
MessageBox.Show (TractorTrailer.NumberOfWheels.ToString)
End Sub
Public Class Vehicle
Private m_Wheels As Integer
Sub New() 'Default Constructor
m_Wheels = 4
End Sub
Sub New(ByVal NumberOfWheels As Integer) 'Overloaded Constructor
m_Wheels = NumberOfWheels
End Sub
Public Property NumberOfWheels()
Get
Return m_Wheels
End Get
Set(ByVal Value)
m_Wheels = Value
End Set
End Property
End Class
In cegonsoft training all advanced concepts are trained ..








Reply With Quote
2}:{2