Public Function ValidDate(MDate)
'Amaç: 4 digitli "yyyy" formatindaki tarihi kontrol etmek; hata var ise kullaniciyi uyarmaktir.
'Input: Texbox'tan string
'Output: True yada False
'Default : False
ValidDate = False
'Eger uzunluk "m/d/yyyy" 'den kisa ise fonkiyondan çik
If Len(MDate) < 8 Then Exit Function
'Geçerli bir tarih türü girilmemisse terket
If IsDate(MDate) = False Then Exit Function
'Sonu "yyyy" ile bitmiyorsa yada baslamiyorsa terket
Dim StartDate As String
Dim EndDate As String
EndDate = Right(MDate, 4)
StartDate = Left(MDate, 4)
If ValidChar(EndDate, "0123456789") = False And _
ValidChar(StartDate, "0123456789") = False Then Exit Function
'Tüm bu testlerden geçilirse True yükle
ValidDate = True
End Function
0 yorum:
Yorum Gönder