Classic asp cint

asp-classic

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?

Best Answer

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.

Related Topic