CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2006
    Posts
    141

    DateTime Checking

    I have a datetime that must required user to key in textbox.Does anyone has idea on checking the datetime that user key in such as IsNumeric?

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: DateTime Checking

    Have you checked DateTime.TryParse() method? This method will check if the Datetime entered is a valid date/time or not.

  3. #3
    Join Date
    Jul 2006
    Posts
    141

    Re: DateTime Checking

    Got it ..this is what i do
    Code:
    Public  Function IsDate(ByVal strDate  As String) As Boolean
            If strDate Is Nothing Then
               strDate = ""
            End If
            If strDate.Length > 0 Then
                Dim dteEmpty As Date = Nothing
                Return DateTime.TryParse(strDate, dteEmpty)
            Else
                Return False
            End If
    Last edited by johnsonlim026; July 12th, 2007 at 03:36 AM.

  4. #4
    Join Date
    Jul 2006
    Posts
    141

    Date And Time constraints in a textbox

    Hi,
    I have a textbox that required user to key in the date and time together.
    I have try with DateTime.TryParse() method .It only return true if the text in the textbox is datetime.
    But how if I want to enforce user to key in the date and time together in the textbox(For Example: 13/7/2007 08:00:59.000) .If user key in the date only or time only it will prompt out error message...
    Does anyone idea on doing this?

  5. #5
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Date And Time constraints in a textbox

    [Merged Threads]
    John,
    As you already have the similar kind of thread, I have merged them. You can ask questions related to the same issue here also.

    Instead of using DateTime.TryParse, use DateTime.TryParseExact.

  6. #6
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: Date And Time constraints in a textbox

    You can also use MaskedTextBox control.

  7. #7
    Join Date
    Jul 2006
    Posts
    141

    Smile Re: Date And Time constraints in a textbox

    Got it thanks

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

Featured