Posted by: Sourav | February 12, 2016

Constructor in VB.Net


Option Strict On
Imports System
Public Class Time

Private year As Integer
Private month As Integer
Private mydate As Integer
Private hour As Integer
Private minute As Integer
Private second As Integer
Public Sub displayCurrentTime()
Console.WriteLine(“{0}/{1}/{2} {3}:{4}:{5}”, month, mydate, year, hour, minute, second)
End Sub
Public Sub New(ByVal theyear As Integer, ByVal themonth As Integer, _
ByVal thedate As Integer, ByVal thehour As Integer, _
ByVal theminute As Integer, ByVal thesecond As Integer)

year = theyear
month = themonth
mydate = thedate
hour = thehour
minute = theminute
second = thesecond

End Sub

End Class

Module Module1

Sub Main()
Dim timeobj As New Time(2016, 2, 12, 9, 21, 30)
timeobj.displayCurrentTime()
Console.ReadLine()
End Sub

End Module


Leave a comment

Categories