I'm new to classic asp, all my experience is in c# .net and ColdFusion and php.
Anyway, this site I'm working on has this code all over the place
If (CInt("0" & myVar) > 0) Then
myNewCar = CInt("0" & myVar)
End If
What I don't understand is why the "0" is append to the var in the cint() input? Am I just missing something? Is it some kind of safety thing? Is it efficient?
On a side note, any classic asp books recommended?
Its an old hack to handle null values. Calling CInt on a null would result in an error. However concatenating a string with a null results in the string hence "0" & null returns "0". This prevents CInt from erroring when the value is null.
myVar might be nothing, an object, empty string, or non-numeric. Pre-pending "0" guarantees you'll get some valid integer back out no matter what.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With