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

Numeric data entry from right to left 2

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
508
Brasil
Hello colleagues!

I have a text box for inputing a currency value, for example 1234.95

When I use any calculator the numbers are displayed from right to left:
[pre]
1
12
123
1234
1234.
1234.9
1234.95
[/pre]
Is it possible to have the same behavior in a text box in VFP?


Thank you,
SitesMasstec
 
Just anecdotal: I played a bit with SelStart, to control the text cursor position. The idea for entering numbers from right to left involves the control of that text cursor position, so it is just before the decimal comma before you type the next ones digit. If I do that, entering a digit, VFP moves focus to the next control instead of extending the already typed in number.

So, in short: I bow my hat (perhaps also my head) to anybody trying to work against the default behavior of the textbox. It's really difficult. I think it would be necessary to do without the inputmask and completely program what it does with the help of keypress, interactivechange, gotfocus and lostfocus events, perhaps, and by introducing some alternative new properties for the configuration. Ideally, also working with the regional defaults, not just the US standard.

Chriss
 
Chris said:
And don't override any methods or events. If you write code in gotfocus or lostfocus or interactivechange you
likely sabotage what the class code does and break the class that way.

I pretty sure wrote code in those classes [sad]


Thank you,
SitesMasstec
 
If you put a class on a form, you're essentially creating a subclass. It's also true to say you create an instance, and those two terms are not meaning the same, but you don't really subclass a class by using it.

Just, when you go into any method or event, you don't see the class code, the editor is empty. When you write in code, you will need to call DODEFAULT() to call the class code, either before you let your own code work or afterwards, and which order is the better one will very much depend an why you put code into some events. If you want to react to a change of value in interactivechange, for example, doing DODEFUALT() as first action would let you react to the interactive change of the user and how the class reacted to that by perhaps changing the value itself.

The result you got with asterisks point out other reasons, though. Like the mask being too short.

Your first try should be using the class as is, but if the documentation asks you to provide an inputmask, do so, there might be things not told in the documentation, as they are very natural, like using a numeric textbox in context of a controlsource of a numeric field.

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top