VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This little program will restrict a date entered to anyone older than 18 years of age.

by Syed Zubair Ali (7 Submissions)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 26th April 2009
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This little program will restrict a date entered to anyone older than 18 years of age.

API Declarations


'one label box
'(very good for NIC Generatiing Program)
'take 3 maskedbox on array from
'one command button
'if you found any error plz email me: [email protected]

Rate This little program will restrict a date entered to anyone older than 18 years of age.



r = (DateValue(MaskEdBox1(0).Text)) - (DateValue(MaskEdBox1(1).Text))
r = r / 365
Label1.Caption = Str$(Round(r, 2))

Select Case Val(Label1.Caption)
Case Is <= (18)
MsgBox "Date Error"
MaskEdBox1(1).SetFocus
Case Else
MaskEdBox1(2).SetFocus
End Select
End Sub

Private Sub MaskEdBox1_GotFocus(Index As Integer)
MaskEdBox1(Index).Mask = "##-##-####"
MaskEdBox1(Index).ForeColor = vbRed

End Sub

Private Sub MaskEdBox1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
SendKeys "{tab}"
KeyAscii = 0
End If
End Sub

Private Sub MaskEdBox1_LostFocus(Index As Integer)
MaskEdBox1(Index).ForeColor = vbBlue
MaskEdBox1(Index).Text = Format$(CVDate(MaskEdBox1(Index).Text), "dd-mm-yyyy")
MaskEdBox1(Index).Text = Format$(CVDate(MaskEdBox1(Index).Text), "dd-mm-yyyy")
End Sub

Download this snippet    Add to My Saved Code

This little program will restrict a date entered to anyone older than 18 years of age. Comments

No comments have been posted about This little program will restrict a date entered to anyone older than 18 years of age.. Why not be the first to post a comment about This little program will restrict a date entered to anyone older than 18 years of age..

Post your comment

Subject:
Message:
0/1000 characters