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

If then else syntax with multiple variables? 1

Status
Not open for further replies.

SteveBabb

Technical User
Jul 30, 2002
2
GB
Hi,

we are trying to create what we thought was a quick if then else loop to convert a string to a number and then multiply the values. Can anyone see why the formula below won't run? It says "The remaining text does not appear to be part of the formula". It runs without error if I remove the else. But without the else it runs all the code. Can you help?

numbervar stepmeasacr;
numbervar stepmeasrou;
numbervar stepnoacr;
numbervar stepnornd;
numbervar totalacr;
numbervar totalrnd;
numbervar totalinch;

If

NumericText({TechnicalSpec.StepMeasAcr})
and NumericText({TechnicalSpec.StepMeasRnd})
and NumericText({TechnicalSpec.StepNoAcr})
and NumericText({TechnicalSpec.StepNoRnd})

then

stepmeasacr := CDbl ({TechnicalSpec.StepMeasAcr});
stepmeasrou := CDbl ({TechnicalSpec.StepMeasRnd});
stepnoacr := CDbl ({TechnicalSpec.StepNoAcr});
stepnornd := CDbl ({TechnicalSpec.StepNoRnd});
totalacr := stepmeasacr * stepnoacr;
totalrnd := stepmeasrou * stepnornd;
totalinch := (totalacr * totalrnd) / 25.4;

else

0;




 
You have a semicolon and lack of parenthesis problem.

I just tried this and it worked:

numbervar stepmeasacr;
numbervar stepmeasrou;
numbervar stepnoacr;
numbervar stepnornd;
numbervar totalacr;
numbervar totalrnd;
numbervar totalinch;

If

(NumericText("99999")
and NumericText("8888")
and NumericText("7777")
and NumericText("6666"))
then
(stepmeasacr := CDbl ("99999");
stepmeasrou := CDbl ("8888");
stepnoacr := CDbl ("7777");
stepnornd := CDbl ("6666");
totalacr := stepmeasacr * stepnoacr;
totalrnd := stepmeasrou * stepnornd;
totalinch := (totalacr * totalrnd) / 25.4)
else
0

Note the parens and lack of semicolons.

-k kai@informeddatadecisions.com
 
Many thanks for that answer. You've fixed it :))

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top