VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Date Validation. If any simple code is available please do mail me.

by Sathyanarayanan (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 13th June 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Date Validation. If any simple code is available please do mail me.

API Declarations


Dim sDate As String

Rate Date Validation. If any simple code is available please do mail me.



// Add to the user control form.
// Note:This can be done without the user control but it will useful once 
// you create User control. 

Private Sub MaskEdBox1_LostFocus()
    sDate = MaskEdBox1.Text
    If IsDate(sDate) = False Then
        MaskEdBox1.SetFocus
        Exit Sub
    Else
    iYear = Mid(sDate, 7, 4)
    If Mid(sDate, 1, 2) <= 0 Or Mid(sDate, 1, 2) > 12 Then
        MsgBox "Enter Months Between 1 TO 12"
    End If
    If Mid(sDate, 1, 2) = 1 Or Mid(sDate, 1, 2) = 3 Or Mid(sDate, 1, 2) = 5 Or Mid(sDate, 1, 2) = 7 Or Mid(sDate, 1, 2) = 8 Or Mid(sDate, 1, 2) = 10 Or Mid(sDate, 1, 2) = 12 Then
        If Mid(sDate, 4, 2) <= 0 Or Mid(sDate, 4, 2) > 31 Then
            MsgBox "Enter Days Between 1 TO 31"
        End If
    Else
   if Mid(sDate, 1, 2) = 4 Or Mid(sDate, 1, 2) = 6 Or Mid(sDate, 1, 2)= 9          Or Mid(sDate, 1, 2) = 11 Then
            If Mid(sDate, 4, 2) <= 0 Or Mid(sDate, 4, 2) > 30 Then
                MsgBox "Enter Days Between 1 TO 30"
            End If
        Else
        If Mid(sDate, 1, 2) = 2 And (iYear Mod 4 = 0) Then
            If Mid(sDate, 4, 2) <= 0 Or Mid(sDate, 4, 2) > 28 Then
    '            MsgBox "Enter Days Between 1 TO 28"
            End If
         Else
                'MsgBox "Enter Days Between 1 TO 28"
        End If
        End If
    End If
    End If
end sub


Download this snippet    Add to My Saved Code

Date Validation. If any simple code is available please do mail me. Comments

No comments have been posted about Date Validation. If any simple code is available please do mail me.. Why not be the first to post a comment about Date Validation. If any simple code is available please do mail me..

Post your comment

Subject:
Message:
0/1000 characters