Calculate

JJM

Active Member
Licensed User
Hi,

Could you help me?
If would like to write in a textbox for example 250*1.09 and get the result in msgbox(Format(textbox1.text,"n2")).
Every time i get an error saying to me that is not a good format.

In Basic4PPC i don't find function as "Val" or string to number as in VB6.

:sign0085:

Thank you

JJ M
 

specci48

Well-Known Member
Licensed User
Hi JJM,

I think what you are trying to do doesn't work at all.

As the name says, with a textbox you can enter a text as a string. So an input of "250*1.09" returns the string "250*1.09" for TextBox1.Text.
As the input for the format instruction has to be a number, and the string "250*1.90" is not a number (even the IsNumber function will return false) you will get a format exception.

I don't know why the format instruction works fine with an input like "2*3" because this string is not a number, too.

If you want to evaluate mathematical expressions (convert string input into a number result) you should have a look at this post from Erel: http://www.basic4ppc.com/forum/showthread.php?t=394


specci48
 

JJM

Active Member
Licensed User
Hi Specci48,

Thank you for the link.
I know that is not the good way i would like to use but try
that:
Textbox1.text="250"*"2"
Msgbox(Textbox1.text)
the result is 500 !!!...

Is it a bug of Basic4PPC?

Thanks again and best regards

JJ M
 
Top