×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Numeric data entry from right to left
2

Numeric data entry from right to left

Numeric data entry from right to left

(OP)
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:
      1
     12
    123
   1234
  1234.
 1234.9
1234.95
 
Is it possible to have the same behavior in a text box in VFP?

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

There's the alignment property, but there's more to it, because when a right aligned textbox has focus the number within is still not displayed right aligned.

Download and try this: https://www.levelextreme.com/Home/ShowHeader?Activ...

Chriss

RE: Numeric data entry from right to left

Do you own a copy of 1001 Things You Wanted to Know about Visual FoxPro (aka KiloFox)? If so, you will find a complete calculator-style textbox which will do what you want - along with a discussion on why this style of data entry is so difficult in VFP.

This is on page 93 onwards. Unfortunately, the code is much too long for me to post it here, even leaving aside copyright issues.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

(OP)
Chris, I downloaded the file and will test it, thank you.

Yes, Mike, I have 1001 Things... and I have just opened in the page you directed me (this book, has been on of my bedside -indeed my desktop side also- in the last few months) as I am diving in a new project. I'll also take a look at the thread you advised. Thank you and Chris, both have helped me a lot.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

SitesMasstec,

Let us know if you succeed with this. I'm sure others will be interested in the solution.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

(OP)
Of course, Mike. As soon as I implement the solution, I will let you know.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

(OP)
Hello colleagues!

Well, first of all, thank you Chris and Mike, for showing me two solutions, for about entering values in a text box, the numbers appearing from right to left, as in calculators. I tested both and each solves the problem I presented (because I saw an old program in Visual Basic with this behaviour in text box, and would like to implement it in a VFP program).

But as my users are accustomed to enter numeric values in VFP text boxes (from Standard class library) I think better not to adopt the calculator mode for data entry in numeric text boxes. Instead, I changed the Properties for data entry, for a clearer data entry:
Format: 999,999.99
InputMask: 999999.99 (I wrongly used 999,999.99 in this property)

Of course may be some situations which I will have to use the calculator mode for data entry.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

(OP)
I have done this, as I mentioned in the post above:
Format: 999,999.99
InputMask: 999999.99

When I put a value (example: 12345.67) in the text box and click on another object the value in the former text box does NOT show 12,345.67 as defined in the Format property.

Even if I put this.Format="999,999.99" in the LostFocus procedure it shows 12345.67 (and not 12,345.67 as desired!).sad

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

No, this.Format="999,999.99" won't work.

The Format property is a single character that affects the entire field. The InputMask property contains a series of characters that affect the individual characters in the field. So it's the InputMask that you need to set to "999,999.99" in the LostFocus, not the Format. Just leave the Format blank.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

When you want output = input set Format to R and for numeric input use a # for any character that should be able to be a digit or +/- sign.

I wonder why you experiment with these properties, the calculator style numeric textbox class should offer all you need.

Chriss

RE: Numeric data entry from right to left

(OP)
Yes, Mike, as you advised, it works now!

I have to put this.InputMask="999999.99" in the GotFocus procedure, just in case the user need to be back to that text box. So now it is fine!

So, the InputMask overlaps anything in the Format?

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

Quote ('SitesMasstec)

So, the InputMask overlaps anything in the Format?

No, you still seem to interpret the Format property as the equivalent to an Outputmask, even though Mike Lewis already told you it is not. Never was and is not intended for that.

Quote (Mike Lewis)

this.Format="999,999.99" won't work.

The Format property is a single character that affects the entire field.

That alone should tell you that the format property works completely different than an input mask, even without knowing which options you have.

Forget about Format, or set it to "R".

In general, don't assume what properties are for, and if you realize they don't work as you expect, how about reading up on them? Then you'd know what they mean and how they work. I realize there's the difficulty of language barrier, perhaps, but sticking to assumptions when you're informed they don't apply is surely not getting you forward at all.

Chriss

RE: Numeric data entry from right to left

Good to see you have it working, SitesMastec.

It's not that the InputMask "overlaps" anything in the Format. The two properties serve different functions. Either or both can be applied to a given control. Your problem was that the characters 9, comma or full stop are not legitimate settings for Format. They do no harm, but they have no effect.

I don't blame you for being confused. It is a confusing topic. Even though I've been using these properties since the first version of VFP - and the equivalents for @SAY/GET in FoxPro 2.x - I still need to check the Help from time to time.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

Quote (SitesMasstec)

as my users are accustomed to enter numeric values in VFP text boxes (from Standard class library) I think better not to adopt the calculator mode for data entry in numeric text boxes.
So you changed your mind. Or is it the difficulty to chenge existing textboxes to the new class.

The calculator mode is not the only mode in Rick Borups "Enhanced Numeric Textbox Class" it also has a "machine style" mode.

Besides, you can use this textbox class wherever you want and only there, you don't have to change every textbox, wehn you don't want to. So is your problem more the indecision about what to use? Then that's something I fear nobody here can help you with.

Besides all that, you don't have to set the Inputmask in the GotFocus event, you can set it in the form designer at design time and at run time it just works all the time, once it is set and you don't have to wait for the control to get focus to set the inputmask, nor do you need to remove it when the control loses focus. It makes no sense to do that.

Chriss

RE: Numeric data entry from right to left

Quote:

you don't have to set the Inputmask in the GotFocus event .... nor do you need to remove it when the control loses focus.

That's a good point. If you keep the mask in force the whole time, the formatting (the dot and the commas) will be visible while the user is entering data, but they do not have to be explicitly typed. Just type the digits as usual.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

(OP)
I am still using the standard TextBox, and I am testing these options Mike and Chris presented. I have not dismissed them, I just want to undestand well how to apply them.

For now, for the standard TextBox I have set Format property to Z (yes, Mike, I had wrongly thought Format is like PICTURE '999..." in FoxPro DOS...).

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

Quote (SitesMasstec)

I have set Format property to Z
The help says, mainly:

Quote (help)

Displays the value as blank if it is 0,...

I that really helpful, is that what you need?

I advised to use R.

Quote (help)

R
Displays the format mask for the text box that is specified in the InputMask property.

The mask formats data for easier entry and clearer display. For example, if the mask is 99-999, the number 12345 is displayed as 12-345 but is not stored as part of the data. Use only with Character or Numeric data.

This is what you want. Despite, that the inputmask is the more important property anyway, which is not the first time we say this.

Chriss

RE: Numeric data entry from right to left

Besides this, the core thing Mike said in an older thread that was also linked to:

Quote (Mike Lewis)

...it's not simple. The explanation of how it works takes up eight pages. As Andy and Marcia say:

Quote (Andy and Marcia)


We set out to create a numeric text box, and discovered why none exists. It was HARD!


...It's just that it is a difficult problem to solve. Ideally, the behaviour you are looking for should have been built into VFP - it's not an unusual requirement - but that's all history now.

So, in short, use the classes you were pointed to, don't try to stick with the native Textbox and just some properties, especially if you still don't focus on what we point out. It takes a lot to get the numeric input in calculator style done and you better take what others already have finished instead of trying to get there on your own.

Chriss

RE: Numeric data entry from right to left

(OP)
Chris: After some days I give up (at least temporarily) using calculator style for numeric data entry in text box, for two reasons:
1) The textboxes classes from Level Extreme and Kilofox, I don't know why accepts only 123.45, if I enter 12345.67 they both presents 12,345.6 or ***,***.**.

I tried to understand the Kilofox class (CH04, yes there are 8 pages about its class...)

2) I used the VFP Standard Textbox class (not calculator style for numeric data entry), but I set its Format property to Z in the form, I am satisfied, because only when it GotFocus it presents the ImputMask property (999,999.99). And it is the same style I use in my programs, and it is better now because of using Format property = Z.

Thanks again for you and Mike for the valuable help you both provided me.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

1) Your description contradicts itself, but when the textbox classes don't act as you like, it's perhaps a misunderstanding about how to configure them. Well, you give up early.

2) Z only empties the textbox, when the value is 0, so it's not hiding the inputmask, always. Also, the inputmask is not shown as value, it is just guiding what can be entered, if the inputmask is shown, there's something wrong with how you setup the textbox.

Also: Set the controlsource to a numeric field or variable, or initialize the value to 0.00 or another number. Otherwise you'll get a string, not a number.

Chriss

RE: Numeric data entry from right to left

I just want to add to this whole discussion that the two properties InputMask and Format are used for the one thing that the Picture clause in pre-Visual FoxPro did. Format is for the part that used to come at the beginning and be preceded with "@"; InputMask is for the part that came at the end.

Tamar

RE: Numeric data entry from right to left

Yes, and you still have Format and Inputmask as a "picture" in Transform as the cFormatCodes parameter:

CODE

? Transform(0,'@Z 999,999,999.99')
? Transform(0,'@R 999,999,999.99')
? Transform(12345.67,'@Z 999,999,999.99')
? Transform(12345.67,'@R 999,999,999.99') 

SitesMasstex, and the topic of Transform also tells you in shich cases you get astrerisks, for example:

Quote (help)

When the expression value is longer than the width of the numeric field, Visual FoxPro forces the value to fit by performing the following steps:

Truncate decimal places and round the remaining decimal portion of the field.

If the value does not fit, store the field contents using scientific notation.

If the value still does not fit, replace the field contents with asterisks.

So your problem may have been you use the calculator style textbox but also set the inputmask and set it too short. You know better than us. I think the calculator style textbox was programmed for (almost) any length up to the range of floating point, 16 places. But if you use a class and change some properties the code might not work as expected any more. Just one possible explanation of why you didn't get what you want from the class.

Chriss

RE: Numeric data entry from right to left

(OP)
Yes, Chris, even if in the procedure LostFocus I use

CODE -->

this.InputMask='999,999.999,99'    && longer InputMask 

Then,when executing, if I enter 123456,78 (my decimal point is ','), I got this:



This is why I gave up about using calculator data entry mode (at least for now, until I completely understand the class or why it shows unexpected results, as the one showed above).

So, I will stick to the VFP TextBox (from Standard class library).

I am trying, in the standard TextBox, when it got focus, that nothing appears inside the TextBox (completely empty, no 0,00).
So that, just after I type 12345,67 inside it and go to another object (lost focus) it shows 12.345,67 in the TextBox.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

SitesMasstec,

you set the inputmask once and for all in the form designer before the form even runs.
It's static, you set it once and don't change it.

Also, you don't set the inputmak property at all, if you use the classes, the classe will handle that for themselves and if you write code in events and don't DODEFAULT(), then you break the class, as you override its behavior and of course they don't work, you're sabotaging them.

Chriss

RE: Numeric data entry from right to left

Quote (Tamar)

I just want to add to this whole discussion that the two properties InputMask and Format are used for the one thing that the Picture clause in pre-Visual FoxPro did.

Tamar, that reminds me of something that I have been meaning to mention to you for some time.

The entry for the Format property in HackFox includes this line in the example code:

CODE

ThisForm.txtSSN.Picture = "999-99-999" 

Somehow the word "Picture" has crept in, in place of "InputMask" - presumably left over from your 2.x doc.

I'm not suggesting this should be changed at this late stage of course, but I thought it worth pointing out.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Numeric data entry from right to left

Also, you have a wrong inputmask, again.

Quote (SitesMasstec)

this.InputMask='999,999.999,99'

a) you set this in the properties window in the form designer or b) if you absolutely want to write code, then write it in the INIT of the textbox.
b) The inputmask has to be 999,999,999.99

, for thousands separators and . for decimal point, even if the decimal point in your coutry is the , and the thousands separator is the . VFP will apply the regional settings omce you SET SYSFORMATS ON, but just like you need to use the . for decimal point in code, the meaning of it in the inputmask is the decimal point, that doesn't change with regionsl settings, what changes is that you get the . displayed as thousands separator and , as decimal point, even though that's the inverse of the inputmask. So the inputmaks is US format, just like numbers in code, except numbers in code can't have thousands separators at all.

ad a) I already told you this earlier:

Quote (SitesMasstec)

you don't have to set the Inputmask in the GotFocus event, you can set it in the form designer at design time and at run time it just works all the time, once it is set and you don't have to wait for the control to get focus to set the inputmask, nor do you need to remove it when the control loses focus. It makes no sense to do that.

And Mike already confirmed it

Quote (Mike Lewis)

That's a good point. If you keep the mask in force the whole time, the formatting (the dot and the commas) will be visible while the user is entering data, but they do not have to be explicitly typed. Just type the digits as usual.

When you set the inputmask while you deisign the form, you dopn't need any code at all setting it. It's just always present and does its job.

With an inputmask that has the decimal point used, the user can enter a number as is usual pressing the [,] key if the comma is the decimal point in your region, will put the text cursor to the place to enter the decimal places.

I already also told you:

Quote (myself)

Set the controlsource to a numeric field or variable, or initialize the value to 0.00 or another number. Otherwise you'll get a string, not a number.

If you first enter a numbmer and then apply a mask, it's no wonder you get nonsense. And that's what you do when you set it in Lostfocus. Especially when the textbox is unbound and the value will be a string, not a number. Applying an inputmask as aftermath to a string is not working correctly at all.

Chriss

RE: Numeric data entry from right to left

(OP)
Oh, I am sorry, I corrected it in the LostFocus property:

CODE -->

this.InputMask='999,999,999.99' 

But I got this bad result:


Thank you,
SitesMasstec

RE: Numeric data entry from right to left

Did you read all I said?

Quote:

Set the controlsource to a numeric field or variable, or initialize the value to 0.00 or another number. Otherwise you'll get a string, not a number.

To show an example:

CODE

_screen.addobject("Text1","Textbox")
_screen.Text1.Inputmask = '999,999,999.99' 
_screen.Text1.Value = 12345.67
_screen.Text1.visible = .t. 
Display in US format:
12,345.67

If instead you never set the value, the default value of a textbox is an empty string, not a number. And what happens, if you set the value to the same number as a string is that:

CODE

_screen.Text1.Value = "12345.67" 

Display in US format:
123,5.6, .
In short: nonsense

What did I tell you to do, SitesMasstec?

To take the stress out of it: We're all here to help, not to torture, but what would it do to you if you give advice to sombody, that is ignored? Multiple times?

You can also learn from this code, why the same inputmask creates differrent results, depending on what you feed in:

CODE

? Transform('12345.67','@Z 999,999,999.99')
? Transform(12345.67,'@Z 999,999,999.99') 


Chriss

RE: Numeric data entry from right to left

(OP)
I am trying to understand all these posts from Mike, Chriss (many thanks to both). It will take some time.

This is because, for now, I decided to use the standard TextBox packed in VFP.

Important to say, I will not adopt the calendar style anymore (entering data from right to left).

I just want to enter 123456.78 and after go out of the textbox it shows 123,456.78. When I use Format Z it shows the textbox empty. Thats's ok.
But when I enter in the textbox object to type a value, it shows 0.00. I am trying to have the textbox completely empty until I begin to type numbers.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

Quote (SitesMasstec)

I am trying to have the textbox completely empty until I begin to type numbers.

Aha, at least we're getting somewhere.

That's a very specific demand, I don't see how you get that. If you want a simple textbox without using a class with much code and want to use the inputmask feature of VFP, then you don't get around specifying a numeric value, and indeed, even with Format "Z", once you focus the textbox the display value will switch to 0.00. You could call it a bug perhaps, but you know there is nobody at Microsoft changing VFP, not even a little bit.

So, stick to your demand, then you likekly will to program for the special cases like that instance when the textbox get's first focus, and your code will get longer than even that of Kilofox from Andy Kramek and Marcia Atkins, two Foxpro experts that were MVPs. Every single one has more knowledge than me. Or you have to lower your demands.

It's not a solution to not use the inputmask, that's for sure, because without an inputmask, the characters the user can enter are not limited, and then you don't just have the problem that the inputmask can't be converted to the desired result, the input then is not restricted to only digits, one decimal point or comma and perhaps an overall size or range.

You only set textbox.value to 0.00 and the inputmask to 999,999,999.99 and you get the following behavior for free, without any line of code:
a) the user can enter a sign + or -, the user can enter any number of digits, when the number of digits rises to 4 a first thousands separator is shown, when you reach a 7 digit number the second thosands separator is shown. Now at any moment the user enters a decimal point (or comma), the nmumber entered so far is becoming shown right before the decimal point (or comma), the text cursor will jump right after the deicmal point (or comma) and the user types the decimal places. It's almost impossible to have any more comfortable input, ubnless you program an AI that predicts what the user will type in next.

You don't even imagine what code would be necessary without the inputmask property to get this guidance and helpful display of the number entered in a human readable format with the thousands separator as helpful assurance the number entered has the right magnitude and you don't error by a factor of 10 or even 100.

Now you come along and say you don't like the inital 0.00 to be shown. You don't show any decency, if you reject the whole system just because you don't like this one detail.

And yes, you can program a textbox that allows what you initially posted in all your steps, but what you write there is also merely a sketch of what the behavior is, you're then not even having the decency to detail what you want to have as the exact description of what someone should program. Instead, anything you're offered is rejected by you. You lost me.

Chriss

RE: Numeric data entry from right to left

Wow, Mike! Can't believe we missed that (and no one told us) through 3 versions.

I guess we ought to fix it in the online open source version. If only I remembered how. winky smile

Tamar

RE: Numeric data entry from right to left

(OP)
Chris:

When someone, mainly with less knowledge (as it is my case) wish to accomplish a task, during the task, even with the help of others (expert people like you, Mike and Tamar) can experience difficulties in learning what expert people are saying.

Well, I am very grateful for you and Mike for showing me classes from KiloFox and LevelExtreme to accomplish the task, which, I will be trying to understand reading all this posts again and again. It will take me some time to get out from errors I had with these two third party classes.

So, for now, I will be using the standard TextBox. Well, as I understood in your last post, it will be very difficult to get the 0.00 from the standard TextBox class as the focus is on it. So, I will not try it anymnore, also because in the last two hours I did not accomplish it.

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

Quote (siteMasstec)

it will be very difficult to get the 0.00 from the standard TextBox class as the focus is on it. So, I will not try it anymnore,

It's not impossible, you could set the forecolor to the backcolor so the 0.00 is not seen until the user enters the first digit and then set the forecolor to black in interactivechange.

That's even a completely untechnical solution, you just have to think about what you want and ways to achieve it, the textbox having no characters in it is only one way of so many more I could think of. If you'
re that unimaginative to not get any idea how to solve a problem, then I don't know what to say anymore.

That's OCD, and it's a fom of OCD that's not worth having empathy about. It's nuts. It's unreal, it's disconnection from reality.

I don't even know what thought process is behind this. A 0.00 is a hint to the user this box exepcts a numeric input. It's good that this is shown when the textbox becomes active. You can of course label the textbox, so it's unmistakably clear the user will need to enter a numeric value, true. but what's actually bad about a 0.00. Do you think a user confronted with a 0.00 appearing when the box was empty before will die from a shock of the surprise something appears? Do you think it will hinder them to enter a value as they see "Oh, this box is already filled". How do you think of your users?

Chriss

RE: Numeric data entry from right to left

Now things have settled a bit for me, let me guess what happened.

You didn't overlook what I was saying, you were trying the value=0.00, but were dissatisfied with the result. You were not coming back to tell this, but that's a thing that made me upset.

Instead you may have tried a ton of things. You didn't see that the difference of the inputmask result display value comes from the data type of the textbox being character/string instead of numeric. I can only tell you that, if you post feedback.

First you have to realize that the datatype of the textbox has to be numeric. and you can deduce that from me telling you that the claue has to be initialized to 0.00 or the textbox has to be set to a controlsource of a numeric field or variable. That's telling that. There is no other way of forcing the datatype to be numeric.

If you get stuck on such a detail, that 0,00 appears, you're losing the overall goal that the user should be able to enter a number with guidance of several helpful behaviors of the inputmak, not being able to enter a letter or other non numeric part of input, for example. And then overall look at the effect. The user can easily work with this textbox, can't he? So why insist on such a detail that is absolutely pointless. You're getting stuck at an unimportant detail while you alread yat the goal.

And the goal must be, to achieve what the classes achieve without much ado, but then you have to accept compromises, or you don't see the woods for the trees, because you still don't have comprehended that the massive code put into the numeric textbox class has its reasons in similar details, that don't work with a codeless textbox just with an inputmask set. You're not failing of knowing too little about Foxpro, you're failing on your perfectionism.

Chriss

RE: Numeric data entry from right to left

(OP)
My spirit is more clarified now, Chris, after reading your words, thanks.

So I stick to this standard TextBox, with some custom changes (I think this is better than what I had wished, calculator mode data entry):

Note: Decimal point is , and separator is . in my country.


Properties:

- Format: Z

- GotFocus:

CODE -->

this.InputMask='999999.99' 

- LostFocus:

CODE -->

this.InputMask='999,999.99' 

- Value: 0.00

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

I wonder why you do without the thousand separators while the textbox has focus, because I think that feedback is valuable to the user while entering the number, not just as aftermath. But if you're good with what you got by these means, I'm fine with that.

Chriss

RE: Numeric data entry from right to left

(OP)
Because it becomes confusing to the user.

Let's supose the user is going to enter 1234,56 (, is my decimal separator). The user is typing 1234, it is showing:

Only when the user finishes typing the whole number, it will show 1.234,56

Thank you,
SitesMasstec

RE: Numeric data entry from right to left

If your regional settings in Windows are reflecting that, he inputmask would not how that behavior, once you do
SET SYSFORMATS ON.

If not, you can explicitly set
SET POINT ','
SET SEPARATOR '.'

Maybe also check what the key on the numpad will be, dot or comma.

And then entering 1234,56 will cause these displays:

1
12
123
123.4 (here the first spearator dot is displayed)
1.234,
1.234,5
1.234,56

Okay, I understand you find this confusing, but once the decimal comma is entered, the number is adjusted correctly and the separator dot appears after the 1. Before you enter the comma, the length of the number is not yet fixed. Well, I think you would expect this as more appropriate, right?

1
12
123
1.234 (display the separator dot at the correct place interpreting the so digits entered so far as one thousand two hundred and thirty four)
1.234,
1.234,5
1.234,56

Okay, I understand why you don't like the handlig of separators. I'd still argue that the wrong display of 123.4 is better than 1234, even though 4 digits are still short enough to not misread the magnitude. 123.4 looks like VFP expects input of a 6 digit number. Well, yes, but you always get the correct positioning once you enter the decimal comma.

So, there are pros and cons, right?

For the matter of unwanted formatting I think you found a good compromise of not using separator characters in the inputmask during input. If the number entered would go to millions or billions I would consider the separators better, even if they are at preliminary wrong positions. But that's a matter of taste.

Chriss

RE: Numeric data entry from right to left

One last thing, since you got the weord results like 12,345.6 or ***,***.**. with the kilofox or the class by Rick Borup from levelextreme is applying what you learned here during this discussion.
1. Preset the value to 0.00 or set controlsource to a numeric field of a cursor or table
2. SET SYSFORMATS ON to get your country standard for separators and decimal comma or SET POINT TO ',' and SET SPEARATOR TO '.'

I'm pretty sure the classes will work, then.

Also: Only set the inputmask when the doczumentation of the class tells you to do that, for specifying a maximum range, maybe there are other class properties to be set.
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. Even if you see the methods empty, that's standard, you only see the class code, when you open the class in the class designer, when you add a class to a form that class code is only seen when you use the "view parent code" button of the code editor.

Chriss

RE: Numeric data entry from right to left

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

RE: Numeric data entry from right to left

(OP)

Quote (Chris)


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

RE: Numeric data entry from right to left

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close