msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Verify Input

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
Ron



Joined: 04 Oct 2007
Posts: 201

PostPosted: Wed Dec 06, 2006 12:53 pm    Post subject: Verify Input Reply with quote

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

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
"Rick Rothstein \



Joined: 04 Oct 2007
Posts: 1584

PostPosted: Wed Dec 06, 2006 4:35 pm    Post subject: Re: Verify Input Reply with quote

>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
Back to top
View user's profile Send private message
Ron



Joined: 04 Oct 2007
Posts: 201

PostPosted: Thu Dec 07, 2006 8:31 am    Post subject: Re: Verify Input Reply with quote

Sorry about the dot Rick I did a cut and paste from my efforts that did not
work to the only part that did, and missed the dot, but you were able to
answer me anyway and it works perfect thats very much.

"Rick Rothstein (MVP - VB)" wrote:

> >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
>
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group