During learning of Visual basic such task has been given to the learner in very beginning stage of learning.So let first design the windows form and place the various controls on windows form. The control which I am using is as under
sno control name property
01 Textbox1.text Name property- txtTime
02 Textbox2.text Name property- txtdate
03 Textbox3.text Name property- txtDay
04 Label1 Text Property- Time No is
05 Label2 Text Property- Date Today is
06 Label3 Text Property- Enter Date
07 Label4 -
08 Command Button Text Property- Find the day
The windows form will be like this
then on form load event write following code
Private Sub frmDate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txttime.Text = TimeString
TxtDate.Text = DateString
End Sub
the code on click event of button1 will be
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MYDATE As Date
Dim aday As String
MYDATE = CDate(TxtDay.Text)
aday = Format(MYDATE, "dddd")
Label4.Text = "The day on " & TxtDate.Text & " is " & aday
End Sub
Enter the date in "enter date" text box in dd/mm/yyyy format.
No comments:
Post a Comment