Results 1 to 5 of 5

Thread: [RESOLVED] MaskedTextBox Verification

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [RESOLVED] MaskedTextBox Verification

    Maybe it's a simple quiestion but i realy don't know how to solve it... i've searched on google bu i did not find any clue how can i check the MaskedTextBox...

    I have put the mask "##/##/####" (to serve as a date input) and i dont know how can i check this do not be empty... i have tried "__/__/____" and also " / / " and "##/##/####" but nothings working...

    Thanks in advice...
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: MaskedTextBox Verification

    You're saying you tried " / /"? Because that works for me:

    vb.net Code:
    1. Dim emptystring As String = "  /  /"
    2.         If Me.MaskedTextBox1.Text = emptystring Then
    3.             MessageBox.Show("Empty")
    4.         End If

  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: MaskedTextBox Verification

    i have tried...
    i need to check if "dd/MM/yyyy" one by one...
    dd ?
    MM ?
    yyyy ?

    is something about Empty strings ? i think the yyyy section is not verified...
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: MaskedTextBox Verification

    try

    vb.net Code:
    1. Dim DateVals() As String = Me.MaskedTextBox1.Text.Split("/"c)
    2.         If (DateVals(0).Length = 2 AndAlso DateVals(1).Length = 2 AndAlso DateVals(2).Length = 4) AndAlso _
    3.            (CInt(DateVals(0)) < 32 AndAlso CInt(DateVals(1)) < 13) Then 'month and day check
    4.            'days must be 31 or less
    5.            'months must be 12 or less
    6.            'year can be anything
    7.             MessageBox.Show("Correctly inputted")
    8.         Else
    9.             MessageBox.Show("Invalid input")
    10.         End If
    11.     End Sub

  5. #5

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved Re: MaskedTextBox Verification

    Thanks alot for your big help...
    Works like a charm...
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

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