[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...
Re: MaskedTextBox Verification
You're saying you tried " / /"? Because that works for me:
vb.net Code:
Dim emptystring As String = " / /"
If Me.MaskedTextBox1.Text = emptystring Then
MessageBox.Show("Empty")
End If
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...
Re: MaskedTextBox Verification
try
vb.net Code:
Dim DateVals() As String = Me.MaskedTextBox1.Text.Split("/"c)
If (DateVals(0).Length = 2 AndAlso DateVals(1).Length = 2 AndAlso DateVals(2).Length = 4) AndAlso _
(CInt(DateVals(0)) < 32 AndAlso CInt(DateVals(1)) < 13) Then 'month and day check
'days must be 31 or less
'months must be 12 or less
'year can be anything
MessageBox.Show("Correctly inputted")
Else
MessageBox.Show("Invalid input")
End If
End Sub
Re: MaskedTextBox Verification
Thanks alot for your big help...
Works like a charm... ;)