(VB6.0)validating a textbox for MM/dd/yyyy format
-
iam validating the textbox in lostfocus event but it is changing values for month to date and viceversa when the day is single digit. this is the code iam using,please mail how to weite code for validating.thanks Private Sub txtfromip_LostFocus() If txtfromip.Text <> "" Then On Error GoTo errtrap If Not IsDate(Format(txtfromip.Text, "MM/dd/yyyy")) Then MsgBox "Invalid Date. Enter Valid Date. Format is 'MM/dd/yyyy'", vbInformation txtfromip.SetFocus SendKeys "{home}+{end}" Else txtfromip.Text = Format(txtfromip.Text, "MM/dd/yyyy") End If Exit Sub errtrap: MsgBox Err.Description, vbCritical, "Error No:" & CStr(Err.Number) Err.clear End If End Sub
-
iam validating the textbox in lostfocus event but it is changing values for month to date and viceversa when the day is single digit. this is the code iam using,please mail how to weite code for validating.thanks Private Sub txtfromip_LostFocus() If txtfromip.Text <> "" Then On Error GoTo errtrap If Not IsDate(Format(txtfromip.Text, "MM/dd/yyyy")) Then MsgBox "Invalid Date. Enter Valid Date. Format is 'MM/dd/yyyy'", vbInformation txtfromip.SetFocus SendKeys "{home}+{end}" Else txtfromip.Text = Format(txtfromip.Text, "MM/dd/yyyy") End If Exit Sub errtrap: MsgBox Err.Description, vbCritical, "Error No:" & CStr(Err.Number) Err.clear End If End Sub