FireTextBox and value in scientific notation

Started by Jean-pierre Leroy, February 15, 2010, 06:19:37 PM

Previous topic - Next topic

Jean-pierre Leroy

Hi Paul,

I've an issue with the FireTextBox control when the value converted with FORMAT$() or STR$() used the scientific notation.

Let's take an example with this value 0.0328767123658934 store in an Extended-precision variable.
If this value is displayed in a textbox with the FORMAT$() function, the display will be 3.28767123658934E-2

If I use the new FF_FireTextBox_SetNumeric() function that I proposed some times ago the display will be -3,287671 (with a FireTextBox control defined with 6 decimal places).

I found a workaround with a function called WithoutScientificNotation() that rounded the value until there is no more scientific notation for the value; I'm pretty sure there is a more elegant to round directly the value in the FF_FireTextBox_SetNumeric() function; to do that we need to be able to retrieve the number of decimal places that has been defined for the FireTextBox control? is-it possible.

You will find a small project to illustrate this issue.

Thank you.
Jean-Pierre

Jean-pierre Leroy

... to complete my previous post ...

If you have to process numerical values that could be represented with the scientific notation (values below 0 with many digital places), I suggest to use this code when working with FireTextBox controls.


FF_FireTextBox_SetNumeric(HWND_FORM1_FIRETEXTBOX1, WithoutScientificNotation(lValue))


Instead of this one

FF_FireTextBox_SetNumeric(HWND_FORM1_FIRETEXTBOX1, lValue)


Here is the code for the WithoutScientifNotation() function.

Function WithoutScientificNotation(ByVal pValue As Extended) As Extended

    Local lNbDecimals As Long : lNbDecimals = 19
    Do   
        Decr lNbDecimals     
        pValue = Round(pValue,lNbDecimals)
        'zTrace("pValue after="+Str$(pValue)+"  rounded on "+Format$(lNbDecimals)+" decimal places")   
    Loop Until Instr(LTrim$(Str$(pValue)),"E") = 0   
    Function = pValue

End Function


Hope that helps
Jean-Pierre