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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: