Jump to content
Sign in to follow this  

Need some help with StringFormat and an integer

Recommended Posts


I'm having trouble using StringFormat to force the output of the decimal and two zero's behind the decimal of a variable that is an integer. It's not displaying the decimal and the zero's, only the integer. I'm obviously doing something wrong. Can anyone point out my errors? I'm attaching the relevant piece of code

Func _GetTotalDue($PaymentNode);---------------------
    Local $PaymentArray = _XMLGetValue($PaymentNode)
    Local $ret_val = 0
    Local $FilteredNumber[15]
    Local $FilteredNumberWithDecimal[15]
    If IsArray($PaymentArray) Then
        For $T = 1 to 14
            If $T = 1 Then
            $FilteredNumber[$T] = Number(StringReplace($PaymentArray[$T], ",", ""))
            $FilteredNumberWithDecimal[$T] = StringFormat("%.2f", $FilteredNumber[$T]); here's where i'm having the problem I think <---------------
            $ret_val += $FilteredNumberWithDecimal[$T]
            Send("Payment # " & $T & " is " & $FilteredNumberWithDecimal[$T] & " Running Total is " & $ret_val & @LF); I need to send the text to Word here
        Return $ret_val
        Return SetError(1,3,0)
EndFunc; _GetTotalDue-----------------------------------

any help would be greatly appreciated!

I'm an idiot.....answered my own question....the variable that was not showing the decimal and zeros was not $FilteredNumberWithDecimal[$T] it was $ret_val which I never used StringFormat on!


Edited by AvgGamerGuy

Share this post

Link to post
Share on other sites


As I can't know what the values are you have trouble with use this example to see how it works.

Then check with your values.

Dim $Values[7]

for $i=1 to 6
$S =StringFormat ("%.2f",$Values[$i])
MsgBox(0, "Result", $S)

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post

Link to post
Share on other sites

He said he answered his own question.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.