Pages

Thursday, 29 March 2012

WORKING WITH DIALOG BOXES



WORKING WITH DIALOG BOXES

 requirments :
label box, text box for input
msgbox,command button 



coding:- 

Dim birthdate As Date

Calculate:

Private Sub Command1_Click()
If Not (IsDate(birthdate)) Then
MsgBox "I don't understand your date,please Retry"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Exit Sub
Else
Text3.Text = ("You have been Alive for" & Date - birthdate & "Day(s)")
End If
myDate = birthdate
myweekDay = Weekday(myDate)
Select Case myweekDay
Case 1
d = "Sunday"
Case 2
d = "Monday"
Case 3
d = "Tuesday"
Case 4
d = "Wednesday"
Case 5
d = "Thursday"
Case 6
d = "Friday"
Case 7
d = "Saturday"
End Select
Text1.Text = d
y = Year (Now) - Year (birthdate)
Text2.Text = y & "Year(s)"
MsgBox "Thankyou,Have a nice Day", vbExclamation
End Sub


End:
Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Form_Load()
MsgBox "Welcome to Days calclation", vbOKCancel + vbExclamation
birthdate = InputBox("Enter your date of Birth", "Date")
End Sub


OUTPUT:




0 comments

Post a Comment

would u like this?

Chitika