Graphics

 View Only
  • 1.  Scripting version of Visual Logic-Format Float

    Posted 02-14-2020 17:01

    Is there a script that will do the same thing as Format Float in Visual Logic? I only want to use it when my stat is represented as a percentage and I want to limit to 1 decimal point.

     

    Thanks



  • 2.  RE: Scripting version of Visual Logic-Format Float

    Posted 03-04-2020 01:05

    Hi Malcolm,

     

    You could use something like this:

    dim content as string
    dim value as double
    dim txtObj as xpTextObject

    Self.getObjectByName("Text1", txtObj)
    value = Convert.ToDouble(txtObj.Text)

    content = string.Format("{0:0.0}", value)

    Self.getObjectByName("Text2", txtObj)
    txtObj.Text = content


    ' {0:0.0} = 1.1
    ' {0:0.00} = 1.12
    ' {0:0.000} = 1.123

    In this case I'm using Text1 as a dummy-value or hidden field to put the actual value in, which will be converted into your chosen format and placed in Text2

     

    Hope it helps.


    #XPression


  • 3.  RE: Scripting version of Visual Logic-Format Float

    Posted 03-04-2020 18:02

    Kenneth,

    This is exactly what I needed. Every script I wrote had no impact. Thank you very much.


    #XPression