Source language: Translate to:

Text Entry Help

Questions or information that don't quite fit anywhere else

Moderator: Neosoft Support

Text Entry Help

Postby Guest » Tue Nov 23, 2004 6:41 pm

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.
Guest
 

Postby Guest » Tue Nov 23, 2004 6:47 pm

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.
Guest
 

Postby Guest » Tue Nov 23, 2004 11:40 pm

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
Guest
 

Postby Guest » Wed Nov 24, 2004 6:47 am

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.
Guest
 

Postby Guest » Fri Nov 26, 2004 10:39 pm

Again, thanks a million...
Guest
 


Return to Misc. Questions and Information

Who is online

Users browsing this forum: No registered users and 0 guests