### Confused a little

Posted:

**Thu Nov 24, 2016 8:26 am**In an app for inventory control, I have a text field to enter Qty Sold and then an Extended amount is calculated i.e. QtySold * Price

However, the Math calculation doesn't execute if a period is entered first example .5 using code on Text Change Tab.

So I have attempted to check to see if first character is a period, if so add 0 to begin so math will execute.

But the routine keeps adding 0's each time I enter a new number. I believe the If clause should only act once.

What am I doing wrong? I tried StrIns with similar results.

Code below.

However, the Math calculation doesn't execute if a period is entered first example .5 using code on Text Change Tab.

So I have attempted to check to see if first character is a period, if so add 0 to begin so math will execute.

But the routine keeps adding 0's each time I enter a new number. I believe the If clause should only act once.

What am I doing wrong? I tried StrIns with similar results.

Code below.

- Code: Select all
`SetVar "[firstchar]" ""`

SubStr "[SoldQtyFld]" "1" "1" "[firstchar]"

If "[firstchar]" "=" "."

SetVar "[SoldQtyFld]" "0[SoldQtyFld]"

EndIf

Math "[SoldQtyFld]*[CostFld]" "2" "[SalesExtend]"