[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

User of Masked Edit control

Marv

5/23/2011 1:25:00 AM

I have a form with a masked edit control (me Zip) with a mask of
"#####-####". In the process data is entered to this control is as
43065878. The data is then written to a record as part to a user defined
type in a field defined as 'DateRec.ZipCode as string * 9' with the
following statement 'DataRec.ZipCode = meZip.ClipText'.

During the process the data is copied from the UDT field back to the
original input control 'DataRec.ZipCode' with the statement
'meZip = format(DataRec.ZipCode,"#####-####"'. When the data field
contains the entire 9 characters this works fine. However, if the
original input was only the first 5 characters of zip code (43065) (zip
without the last four characters) the value of the dataRec.ZidCode is
'43065 ' and the statement does not work. I have tied many different
means to get around this without success. Any ideas would be appreciated.

Marv
13 Answers

GS

5/23/2011 1:59:00 AM

0

Marv presented the following explanation :
> I have a form with a masked edit control (me Zip) with a mask of
> "#####-####". In the process data is entered to this control is as 43065878.
> The data is then written to a record as part to a user defined type in a
> field defined as 'DateRec.ZipCode as string * 9' with the following statement
> 'DataRec.ZipCode = meZip.ClipText'.
>
> During the process the data is copied from the UDT field back to the
> original input control 'DataRec.ZipCode' with the statement
> 'meZip = format(DataRec.ZipCode,"#####-####"'. When the data field contains
> the entire 9 characters this works fine. However, if the original input was
> only the first 5 characters of zip code (43065) (zip without the last four
> characters) the value of the dataRec.ZidCode is '43065 ' and the statement
> does not work. I have tied many different means to get around this without
> success. Any ideas would be appreciated.
>
> Marv

I've always handled this using a normal textbox control and setting the
text format according to the length of the zip code. This is handled in
its Change event via a Select Case construct for 5, 6, or 9 character
zip codes. USA is 5 or 9 (5-4); Canada is 6 (3 3). Case Else handles
invalid inputs.

HTH

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Marv

5/23/2011 7:45:00 PM

0

On 5/22/2011 9:58 PM, GS wrote:
> Marv presented the following explanation :
>> I have a form with a masked edit control (me Zip) with a mask of
>> "#####-####". In the process data is entered to this control is as
>> 43065878. The data is then written to a record as part to a user
>> defined type in a field defined as 'DateRec.ZipCode as string * 9'
>> with the following statement 'DataRec.ZipCode = meZip.ClipText'.
>>
>> During the process the data is copied from the UDT field back to the
>> original input control 'DataRec.ZipCode' with the statement
>> 'meZip = format(DataRec.ZipCode,"#####-####"'. When the data field
>> contains the entire 9 characters this works fine. However, if the
>> original input was only the first 5 characters of zip code (43065)
>> (zip without the last four characters) the value of the
>> dataRec.ZidCode is '43065 ' and the statement does not work. I have
>> tied many different means to get around this without success. Any
>> ideas would be appreciated.
>>
>> Marv
>
> I've always handled this using a normal textbox control and setting the
> text format according to the length of the zip code. This is handled in
> its Change event via a Select Case construct for 5, 6, or 9 character
> zip codes. USA is 5 or 9 (5-4); Canada is 6 (3 3). Case Else handles
> invalid inputs.
>
> HTH
>
Yeah, I can do that. I just hoped there might be a better way. I liked
the idea that the original input field had the mask to guide the entry.

Marv

GS

5/23/2011 8:36:00 PM

0

Marv used his keyboard to write :
> On 5/22/2011 9:58 PM, GS wrote:
>> Marv presented the following explanation :
>>> I have a form with a masked edit control (me Zip) with a mask of
>>> "#####-####". In the process data is entered to this control is as
>>> 43065878. The data is then written to a record as part to a user
>>> defined type in a field defined as 'DateRec.ZipCode as string * 9'
>>> with the following statement 'DataRec.ZipCode = meZip.ClipText'.
>>>
>>> During the process the data is copied from the UDT field back to the
>>> original input control 'DataRec.ZipCode' with the statement
>>> 'meZip = format(DataRec.ZipCode,"#####-####"'. When the data field
>>> contains the entire 9 characters this works fine. However, if the
>>> original input was only the first 5 characters of zip code (43065)
>>> (zip without the last four characters) the value of the
>>> dataRec.ZidCode is '43065 ' and the statement does not work. I have
>>> tied many different means to get around this without success. Any
>>> ideas would be appreciated.
>>>
>>> Marv
>>
>> I've always handled this using a normal textbox control and setting the
>> text format according to the length of the zip code. This is handled in
>> its Change event via a Select Case construct for 5, 6, or 9 character
>> zip codes. USA is 5 or 9 (5-4); Canada is 6 (3 3). Case Else handles
>> invalid inputs.
>>
>> HTH
>>
> Yeah, I can do that. I just hoped there might be a better way. I liked the
> idea that the original input field had the mask to guide the entry.
>
> Marv

Well, you can also guide the entry. For example, entering digits only
for a phone number results to (###) ###-#### after the control loses
focus. It's just a matter of playing around in the right event proc for
the desired results. In your case you could even limit input to numeric
values only, but this won't facilitate Canadian zip codes as they're
alpha-numeric. I use the Like operator to validate the inputs for
Canadian zips or US 5-4 zips. This gives much more flexibility than the
Masked Edit controls gives.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Mike Williams

5/23/2011 9:16:00 PM

0

"Marv" <NoBdy@columbus.rr.com> wrote in message
news:ircd0o$gvv$1@speranza.aioe.org...

> I have a form with a masked edit control (me Zip) with a mask
> of "#####-####". The data is then written to a UDT record as
> 'DataRec.ZipCode = meZip.ClipText'. During the process the
> data is copied from the UDT field back to the original input
> control using 'meZip = format(DataRec.ZipCode,"#####-####"'.
> When the data field contains the entire 9 characters this works fine.
> However, if the original input was only the first 5 characters of zip
> code the statement does not work.

Try the following:

meZip.SelStart = 0
meZip.SelLength = 10
meZip.SelText = DataRec.ZipCode

Mike


Tony Toews

5/24/2011 12:33:00 AM

0

On Sun, 22 May 2011 21:24:40 -0400, Marv <NoBdy@columbus.rr.com>
wrote:

>I have a form with a masked edit control (me Zip) with a mask of
>"#####-####".

Presumably you will never, ever have a record which comes from outside
the USA?

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

dpb

5/24/2011 1:47:00 AM

0

On 5/23/2011 7:33 PM, Tony Toews wrote:
> On Sun, 22 May 2011 21:24:40 -0400, Marv<NoBdy@columbus.rr.com>
> wrote:
>
>> I have a form with a masked edit control (me Zip) with a mask of
>> "#####-####".
>
> Presumably you will never, ever have a record which comes from outside
> the USA?

There _is_ somewhere outside the USA??? :)

--

Tony Toews

5/24/2011 8:05:00 PM

0

On Mon, 23 May 2011 20:46:37 -0500, dpb <none@non.net> wrote:

>>> I have a form with a masked edit control (me Zip) with a mask of
>>> "#####-####".
>>
>> Presumably you will never, ever have a record which comes from outside
>> the USA?
>
>There _is_ somewhere outside the USA??? :)

Hehehehe

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/ac...
Tony's Microsoft Access Blog - http://msmvps.com/blo...
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeup...

David Kaye

5/26/2011 4:09:00 AM

0


"Marv" <NoBdy@columbus.rr.com> wrote

>I have a form with a masked edit control (me Zip) with a mask of
>"#####-####". In the process data is entered to this control is as
>43065878. [....]

I'd use a regular text box. I think the masked edit is annoying.



Mike Williams

5/26/2011 10:14:00 AM

0

"David Kaye" <sfdavidkaye2@yahoo.com> wrote in message
news:irkjoq$ccn$1@dont-email.me...
>
> "Marv" <NoBdy@columbus.rr.com> wrote
>
>>I have a form with a masked edit control (me Zip) with a mask of
>>"#####-####". In the process data is entered to this control is as
>>43065878. [....]
>
> I'd use a regular text box. I think the masked edit is annoying.

Personally I don't know why the OP has not responded to my own previous
suggestion of using the SelText property of the Mask EditBox. It does
exactly what the OP asked for. This is because in a Mask EditBox the SelText
property (unlike the Text property which the OP is currently using) behaves
exactly as though the user had entered the SelText characters into the Mask
EditBox manually. It is fully documented in the help files.

Mike



Marv

5/26/2011 7:34:00 PM

0

On 5/26/2011 6:14 AM, Mike Williams wrote:
> "David Kaye" <sfdavidkaye2@yahoo.com> wrote in message
> news:irkjoq$ccn$1@dont-email.me...
>>
>> "Marv" <NoBdy@columbus.rr.com> wrote
>>
>>> I have a form with a masked edit control (me Zip) with a mask of
>>> "#####-####". In the process data is entered to this control is as
>>> 43065878. [....]
>>
>> I'd use a regular text box. I think the masked edit is annoying.
>
> Personally I don't know why the OP has not responded to my own previous
> suggestion of using the SelText property of the Mask EditBox. It does
> exactly what the OP asked for. This is because in a Mask EditBox the
> SelText property (unlike the Text property which the OP is currently
> using) behaves exactly as though the user had entered the SelText
> characters into the Mask EditBox manually. It is fully documented in the
> help files.
>
> Mike
>
>
>
Mike, I appologize for not responding to your suggestion. I did try it
and it worked for the zip code field. I couldn't make it work for a
telephone field with a mask of ###-###-#### without first testing to see
if the area code was blank and then modifying the sel length to a value
of 4. Since I have a number of telephone numbers I went just went with
the suggestion of Dave Kaye and converted all the mask edit boxes to
straight text boxes.

I do however appreciate you response.