Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 14 of 14

Thread: decimal

  1. #1
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21

    decimal

    Hi
    Im trying to make some calculations within a program.
    What i understand i cant make an input in decimals like 1.2345 in an input box an convert it to a number like this:

    inputp1tom = Input.GetText("p1tom");
    inputp1tom = String.ToNumber(inputp1tom);

    so what do i need to do to make it take a 4 decimal number and make a calculation against another number and give a 4 decimal answer.

    This is my code:

    inputp1tom = Input.GetText("p1tom");
    inputp1tom = String.ToNumber(inputp1tom);

    inputp1vat = Input.GetText("p1vat");
    inputp1vat = String.ToNumber(inputp1vat);

    gramfargp1 = inputp1vat - inputp1tom
    Label.SetText("p1farg", gramfargp1);

  2. #2
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi. Sounds like Math.Round is the ticket. Here's a working example, hope that helps.

    http://www.indigorose.com/webhelp/am...d_Examples.htm

  3. #3
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21
    that is probebly right but i cant get it to work
    the 2 numbers that will be in the calculation is 4 decimals and when i do a calculation with decimals ill get the result 0

    take a look at this code should that work?

    inputp1tom = Input.GetText("p1tom");
    inputp1tom = String.ToNumber(inputp1tom);

    inputp1vat = Input.GetText("p1vat");
    inputp1vat = String.ToNumber(inputp1vat);

    gramfargp1 = Math.Round(inputp1vat - inputp1tom, 4);

    Label.SetText("p1farg", gramfargp1);

  4. #4
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi. You mean padding non-decimal numbers? Here's a working example attached. I set it up to only subtract since that's the example you posted. So in this file it will subtract number 2 from number 1 and pad/round the answer to 4 decimal places each time. All the actions are on the button, in the OnClick event. Hope that helps.
    Attached Files

  5. #5
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21
    Thanx for youre help Corey.
    Now i se what the problem is
    im from sweden and in sweden we use , as a devider (is devider the right name) and in the english language you use . is it posible to thell the app that , is the same as.

  6. #6
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Yes, what does a "divider" look like? Please show me the character and I will adjust the script.

  7. #7
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21
    What i ment was:
    in sweden it looks like this 0,1234 and in english it looks like this 0.1234 the diferens is ., my app dosent work with , instead of .
    when someone in sweden enters a number in p1tom and p1vat they will add it like this 0,1234 not 0.1234


    inputp1tom = Input.GetText("p1tom");
    inputp1tom = String.ToNumber(inputp1tom);

    inputp1vat = Input.GetText("p1vat");
    inputp1vat = String.ToNumber(inputp1vat);

    gramfargp1 = Math.Round(inputp1vat - inputp1tom, 4);

    Label.SetText("p1farg", gramfargp1);

  8. #8
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Hi. OK this attached example will handles inputs with commas as well as decimals and then delivers the answer with a comma instead of a decimal. Hope that helps.
    Attached Files

  9. #9
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21
    thank you now it works

  10. #10
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Glad to hear it's working.

  11. #11
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    Hello neighbour,

    Those of us living outside “the dot area” (US/CAN/UK...) have some additional challenges. The decimal symbol (dot or comma) is one of them, but we have more; the digit grouping symbol (comma, dot, space or single quote) and the list separator (comma or semicolon). All of these values can be found in the user’s Registry.

    I recommend Lorne’s great examples Function: Get the Valid Numeric Characters for the Current Locale and Function: Validate the Contents of an Input Object

    And don’t forget the letters outside the A-Z range. In Sweden Ä.Ö, Å ä, ö, å. Put the Swedish letters randomly into a table; execute Table.Sort(). The result is not what you expected. You should read Brett’s post Tip: Changing the Locale


    Yes Corey, it’s “Comma, comma, comma, chameleon” once again.

  12. #12
    Join Date
    May 2005
    Location
    Sweden
    Posts
    21

    Thumbs down

    Thank you csd214 I really appreciate all this kind of information.

  13. #13
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    You are welcome. We have similar problems; NO; I mean similar challenges. There are no problems; only solutions.

  14. #14
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Quote Originally Posted by csd214
    You are welcome. We have similar problems; NO; I mean similar challenges. There are no problems; only solutions.
    I once was told to say "setbacks" and not problems.

    Intrigued

Similar Threads

  1. Convert Hexadecimal to Decimal
    By csd214 in forum AutoPlay Media Studio 5.0
    Replies: 12
    Last Post: 04-05-2010, 02:26 AM
  2. Rounding decimal places
    By JackalopeJay in forum AutoPlay Media Studio 5.0
    Replies: 3
    Last Post: 07-19-2005, 02:32 PM
  3. Program: Binary Hex and Decimal Converter
    By Protocol in forum AutoPlay Media Studio 5.0 Examples
    Replies: 3
    Last Post: 07-15-2004, 12:11 PM
  4. Registry -- dword -- hex or decimal?
    By jassing in forum Setup Factory 6.0
    Replies: 2
    Last Post: 04-11-2003, 02:01 PM
  5. Converting hex value to decimal...can we do this in SF6??
    By Martin_SBT in forum Setup Factory 6.0
    Replies: 5
    Last Post: 02-06-2003, 02:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts