>> <cfset var120 = "a string">
>> <cfset dtgVar = Val(Reverse(var120))>
>
>> The value of dtgVar is 21 instead of 021, 021 is correct.
>> I have workaround to circumvent the problem though.
>
>Well given the code above, the value of dtgVar should be 0 since you
>populated var120 with "a string", not "120"... since it's not numeric,
>it would return 0... if you populated var 120 with "120" then the 2nd
>line should produce 21, _not_ 021 as this is the expected behavior
>afaik not just from CF but from other languages which have a val()
>function. Val is a numeric function, the value "021" is a string, not
>a numeric -- the numeric equivalent of "021" is 21. The function
>NumberFormat() is used to convert the numeric value 21 into a
>specified string format, such as "021". DecimalFormat() and
>DollarFormat() do the same thing with pre-defined formats. So no...
>not buggy... the code you want is
>NumberFormat(Val(Reverse(var120)),000).
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

