=================================Slip
9_1================================ Write a VB Program to accept
birth date through textbox from user and calculate age. (Use Message box to
display result)
=======================================================================
Private Sub Command1_Click()
BirthDate =
Text1.Text
MsgBox ("Age
:" &ExactAge(BirthDate))
End Sub
Public Function ExactAge(BirthDate As Variant) As String
Dim yer As
Integer, mon As Integer, d As Integer
Dim dt As Date
Dim sAns As String
dt = CDate(BirthDate)
If dt> Now Then
Exit Function
yer = Year(dt)
Print yer
mon = Month(dt)
Print mon
d = Day(dt)
Print d
yer = Year(Date) -
yer
mon = Month(Date)
- mon
d = Day(Date) - d
sAns = yer&
" year(s) " &mon& " month(s) " & d & "
day(s) old."
ExactAge = sAns
End Function
No comments:
Post a Comment
Note: only a member of this blog may post a comment.