Page 1 of 1

Text Entry Help

PostPosted: Tue Nov 23, 2004 6:41 pm
by Guest
I have a text entry field that will be used to input numbers. The number will always be a decimal (i.e. 0.065).

I would like the field to automatically add a zero in front of the decimal. This way the user can just enter .065

Without the zero in front of the decimal the calculations do not perform properly.

I do not want to use the validation mask (appearences). And besides this will still force the user to enter a zero.

Any help would be greatly appreciated.

PostPosted: Tue Nov 23, 2004 6:47 pm
by Guest
Place this code in the "text changed" action window:

SearchStr "0" "[textentryvalue]" "[decimal]"
if "[decimal]" "<>" "1"
setvar "[textentryvalue]" "0[textentryvalue]"
endif


This checks to see if the first digit of the value is 0, if not, it places a 0 in front of the value.

PostPosted: Tue Nov 23, 2004 11:40 pm
by Guest
Maybe a check for the decimal seperator should be added:

Code: Select all
SearchStr "0" "[textentryvalue]" "[decimal]"
SearchStr "." "[textentryvalue]" "[decisep]"
if "[decimal]" "<>" "1"
  if "[decisep]" "=" "1"
    setvar "[textentryvalue]" "0[textentryvalue]"
  endif
endif

PostPosted: Wed Nov 24, 2004 6:47 am
by Guest
Prepending a zero to any number does not change the number's value, so how about just:

Code: Select all
SetVar "[Value]" "0[Value]"

or even in the calculation itself:

Code: Select all
Math "0[Value]*1.234" "9" "[Result]"

If [Value] = .65, then 0[Value] = 0.65; if [Value] = 0.65, then 0[Value] = 00.65.

PostPosted: Fri Nov 26, 2004 10:39 pm
by Guest
Again, thanks a million...