etm124
etm124

Reputation: 2140

Formatting an integer

I have almost a two part question. Firstly, I am trying to format a string that I have converted to an integer. I have the following code:

If Idx2 = 0 Then    
    response.Write(sName & vbKeyTab & " E01 " & vbKeyTab & CInt(oSplit(1)) & "</br>")
End If

This correctly displays my value in oSplit(1) as 75. I'd like to to display as 00075.00

I've tried this, but I get a 500 error:

Format(CInt(oSplit(1)), "00000.00")

My second question is regarding the CInt portion of my code. The data in my oSplit array is a string, and I am casting it to an integer. However, it seems as if CInt is rounding my values. Is there a parameter I can pass to CInt to prevent this?

Thank you.

Upvotes: 2

Views: 236

Answers (1)

BonyT
BonyT

Reputation: 10940

To handle .05 then you want to convert it to a decimal not an Int:

  Format(CDec(oSplit(1)), "00000.00")

Upvotes: 2

Related Questions