Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Masked Edit Textbox cliptext problem

Status
Not open for further replies.

EagleTempest

Technical User
Jun 15, 2004
125
0
0
CA
VB6

If have a masked edit box with
Code:
mtxPhoneNum.mask="(###) ###-####"
and I save the .cliptext value such as "3065860336" to a DB.

If I wish to retrieve this value and load it back into my masked edit box such as
Code:
mtxPhoneNum.text="3065860336"
I get an error unless I set
Code:
mtxPhoneNum.mask=""

To get this all to work I then save the .text value and not the .cliptext value which saves the input as "(306) 586-0336". This is fine but any blank phone numbers are now saved as "(___) ___-____"

What is .cliptext used for if it's value can not just be plugged back into a masked edit box? (A little long winded sorry)

 
I suppose the obvious thing would be to reformat the cliptext value such as:
Code:
mtxPhoneNum.text=FORMAT("3065860336","(###) ###-####")

Like duh (to myself)!!!
 
Except now I'm trying to figure out the code to format a postal code. I keep getting an "Invalid propety value" when I try:
Code:
mtxPostalCode.text=FORMAT("S4S3L1","&#& #&#") 'or variations like "@#@ #@#"
Sure one little space doesn't make a big difference but it's the principal of the whole the thing.
All I want is S4S 3L1
 
Why not use the componant Microsoft Mask Edit Control with a mask of ">?#? #?#". the ">" will force Alpha characters to uppercase and the "?" only allows Alpha Characters to be inputed and the "#" only allows Numeric Characters to be inputed.

 
The Mask Edit control is what's causing my grief. To set it's text property, the value must match it's mask property. I've got the phone number to work and I tried ">?#? #?#" for the postal code but I still get the error.

Just to recap:
Code:
Form_Load
medPostalCode.mask=">C9C 9C9" 'Works fine for input
gstrPostalCode="S4S3L1"

cmdLoad_Click
medPostalCode.text=Format(gstrPostalCode,">?#? #?#")
One quirk is the code to format the mask in a mask edit box is different than the Format function. It's obviously easy to get the value out of the mask edit box but into one, at present, is tricky.
 
Form_Load
medPostalCode.Mask = ">?#? #?#"


cmdLoad_Click
gstrPostalCode = Format("s4s3l1", "!@@@ @@@")
medPostalCode.Text = gstrPostalCode
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top