Results 1 to 2 of 2

Thread: Validation Command

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009
    Posts
    1,058

    Validation Command

    Hi,

    I have the following validation which works fine for numeric textbox i.e., txtprojstart, however I want to update it for datetime textbox instead of numeric any help please... See code below


    Code:
    Private Sub txtprojstart_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtprojstart.Validating
            If Not IsNumeric(txtprojstart.Text) And txtprojstart.Text <> "" Then
                ' Cancel the event moving off of the control.
                e.Cancel = True
                ' Select the offending text.
                txtprojstart.Select(0, txtprojstart.Text.Length)
                ' Give the ErrorProvider the error message to display.
                ErrorProvider.SetError(txtprojstart, "Enter correct date format")
            End If
        End Sub]

    Code:
    Private Sub txtprojstart_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtprojstart.Validated
            ErrorProvider.SetError(txtprojstart, "")
        End Sub
    thanks

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Validation Command

    Any reason why you are not just using numeric up/down controls and date/time calender control?

    In case you really need it there is an IsDate method just like the IsNumeric.
    Last edited by Grimfort; Aug 2nd, 2010 at 09:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width