Re: Verify Input



I want to verify that the input to a MaskEdBox is complete ie with 11
numbers
inc zero's, I can check that some input has been made with Change option,
is
it possible to do better?
My books and the VB help file do not give very good examples.

This is my code now:-

Private Sub mebMask_Change()
.cmdAddRec.Caption = "OK to Post"
End Sub

That is your code? What is with the dot in front of the control name? Did
you leave out the With-EndWith statement? Other code?

Anyway, assuming the leading dot is a mistake and that you want the caption
of a control named cmdAddRec to signal when the all 11 characters in your
MaskEditBox are filled in, try this...

Private Sub mebMask_Change()
If Len(mebMask.ClipText) = 11 Then
cmdAddRec.Caption = "OK to Post"
Else
cmdAddRec.Caption = "Not Ready to Post yet"
End If
End Sub

However, if cmdAddRec is a CommandButton (which the 3-character prefix would
indicate), and if it is meant to be clicked on only when the MaskEditBox
entry is complete, then I would enable/disable it in response the user's
input. Something like this...

Private Sub mebMask_Change()
cmdAddRec.Enabled = (Len(mebMask.ClipText) = 11)
End Sub

or, if you prefer the "long" way...

Private Sub mebMask_Change()
If Len(mebMask.ClipText) = 11 Then
cmdAddRec.Enabled = True
Else
cmdAddRec.Enabled = False
End If
End Sub

Just remember to start the CommandButton off with Enabled set to False
(because there will be no text in the MaskEditBox at that point in time).

Oh, and by the way, using the ClipText property will work whether your mask
has hard-coded characters in it or not (ClipText ignores any characters that
are part of the mask and only sees the characters actually typed by the
user). So, if your mask were for a US Social Security Number (###-##-####),
and the user had typed in 1234 as some point, the ClipText would contain
"1234" and not "123-4" or "123-4_-____".

Rick


.


Loading