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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Mask

Status
Not open for further replies.

Imaginecorp

IS-IT--Management
Jan 7, 2007
635
US
This is driving me nuts, The annoying default 0 (zero) in a numeric field display

Input Mask of 999,999,999 and a Format of "K".
When the textbox gets the focus via Tab and the whole textbox is highlighted, there is no problem But when the textbox is entered via the mouse and a value is being entered a 0 (zero) shows up as the last number. When I enter say 500, the zero is still there and the 500 now becomes 5,000

If I remove the comma in the input mask then everything is ok, But I need the damn comma.

I have tried with format = KR, KRZ etc but no luck.
Any and All suggestions would be greatly appreceated
Thanks
 
This is a familiar problem.

This is what I do: In the GotFocus, store the mask in a custom property. Then clear the mask. Restore the mask in the LostFocus.

It means the user won't see the comma or whatever while they're editing, but it's better than having the user-entered values multipied by 10.

By the way, if you want Select On Entry, set the SelectOnEntry property to .T. rather than setting it through the mask. It won't intefere with any other mask settings in force.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Thanks Mike, does not seem to work for me...I do want the user to see the comma as when entering large numbers, its confusing. I do have the Select on Entry set as .t.
When tabbing evry thing works as expected, but its when the user enters via a mouse click... Unfortunately I cannot do a Setfocus() in the click() due to the insertion point problem.
I knew this was a VFP thing, was just hoping somebody here had a workaround...
 
You could try putting the following in the click event method for the field to force the cursor position to be at the front of the field instead of where the user clicks....

Code:
KEYBOARD '{BACKTAB]' PLAIN
KEYBOARD '{TAB}' PLAIN

Kind of kludgy but it might work.....

Andy Snyder
SnyAc Software Services Hyperware Inc. a division of AmTech Software
 
The behavior you don't like is correct Windows behavior. Think about it this way... you key in a number, only to find you missed a zero somewhere. You simply want to click the mouse where you want that zero to go.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
Try it like this:

subclass the textbox and add a property nClickcount and make it 0

In the lostfocus put
Code:
this.nClickcount=0

In the clickevent put
Code:
this.nClickcount = this.nClickcount + 1
IF this.nClickcount==1
   this.selstart = 0
   this.sellength = 20
ENDIF

That should mimic entering the textbox via a tab

good luck,

Stefan
 
Thanks Guys, appreciate the suggestions but unfortunately, in my situation they will not work.
Example: the number in the field is 900,000,000.00, the user wants to change it to 900,000,100.00, with the mouse clicks or keyboard suggestions, when the mouse is clicked between 0, 0 the whole field will be highlighted, when the 1 is inserted it will clear the whole field to put the 1 in. It will definitely work when the field is empty. The textbox is a class and it would involve too much of coding for different situations.
I know this is VFP thing. The only way, which I don’t want to do, is to display the numeric field as a Character…
 
I agree with Imaginecorp. I don't think this is normal Windows behaviour, and it's not what the user would expect.

I still feel it's better to remove the mask during editing, rather than risk the user entering values that weren't intended. That's been my approach since I started with VFP, and I don't recall any negative feedback.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Gents,
Here in Holland with electronic banking one have solved this kind of data-input problems by forcing you to use two seperate input boxes. One for the Euro's and one for the Euro-cents.
Would this be a solution here?
-Bart
 
Bart,

It's the same here. My company's bank does that. It solves the problem, but I hate using it. It's so easy to forget that you have two separate fields, especially as this particular bank issues a really unfriendly message when you get it wrong.

But that's just my two Eurocents worth.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Bart: the 2 input boxes are unfortunately not an option, too much coding and for me to change 0ur code now would be horrendous.
Mike: I agree with your suggestion of removing the Input & Format mask prior to entry, saving them in the Tag property, but removing the commas defeats the purpose as these are very large numbers (account numbers with an average of 25 digits)… By the way, here in the USA, most electronic banking input forms use your principle …
 
Craig; the problem is not inserting a number, but the annoying default behavour, with an input mask in place, in a numeric field where the Zero popups up.
When you click in, and enter a 500 the zero still remains and when you move out it gets added i.e. 5000.
In a fast data entry, this could very easly be overlooked...
 
Imaginecorp,

but removing the commas defeats the purpose as these are very large numbers

So are you saying that the user will acutally type the commas? Why would they do that?

I can understand why they would want to see the commas once the value has been entered.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top