This topic is locked
[SOLVED]

 don't truncate number on export

11/15/2010 3:40:16 PM
ASPRunnerPro General questions
T
Tim author

Hello,
Is there a way to ensure a number is always exported with 2 places to the right of the decimal, even if that number is zero?
Thanks,

Tim

Sergey Kornilov admin 11/16/2010

I guess you can use BeforeExportRecord event for this purpose: http://xlinesoft.com/asprunnerpro/docs/before_export_record.htm
In this event you can check the current field value and format it accordingly i.e.

if values("FieldName")=0 then

values("FieldName")="0.00"

end if
T
Tim author 11/18/2010

Sorry, I didn't do a good job of explaining this. Basically I want to keep the trailing zeros. So 2.10 should export as 2.10, not 2.1
The database is SQL 2005 and the field type is money, if that makes any difference.
Thanks,

Tim

Sergey Kornilov admin 11/18/2010

The same approach - use 'View as' type 'Custom' to ensure two digits after comma.
Check FormatNumber function:

http://www.w3schools.com/vbscript/func_formatnumber.asp

T
Tim author 11/18/2010

Thank you! "View As" type "Custom", then:
strValue = (FormatNumber(data("SalePrice"),2))
did the trick for me.
You're the best!