Discussion in 'Questions (Windows Mobile)' started by JJM, Jul 27, 2007.

  1. JJM

    JJM Active Member Licensed User


    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.


    Thank you

    JJ M
  2. specci48

    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:

  3. JJM

    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
    the result is 500 !!!...

    Is it a bug of Basic4PPC?

    Thanks again and best regards

    JJ M
  4. Erel

    Erel Administrator Staff Member Licensed User

    Basic4ppc implicty converts strings to numbers as needed.
    It will not convert expressions to formulas.
    You should follow the link if you wish to convert expressions (not single numbers) to numbers.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice