I'm using the conversion function CStr in VBScript to convert a number of type Long开发者_StackOverflow into a String. The problem is after converting to a string the decimal point is lost eg 2.5 is converted to 2.
Does anyone know a way to preserve the decimal point using this conversion function?
Many Thanks,
Its probably that casting the number to Long is the problem as long is just a type that will contains bigger integers, and does not support decimals.
Maybe try a currency, single or double type for the numeric value before doing the CStr
Have you echoed out your CLng variable? CLng rounds decimals to the nearest even number so it is likely the CLng which is rounding your decimal places rather than CStr dropping them. Can you use CDbl rather than CLng?
精彩评论