Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP/VBScript "Gotchas"

I'm supporting/enhancing a web application written in Classic ASP/VBScript. It has been about 10 years since I have used either in a day to day capacity. I just ran across an issue that I would consider a "gotcha" and was wondering if others had similar things that I should learn to be aware of.

My issue:
I had to convert a Column in a SQL Table from float to decimal. It turns out that decimal isn't a type that is really supported (or supported well) in vbscript. So the following code:

Dim var1, var2

var1 = rs("DecimalField1").Value
var2 = rs("DecimalField2").Value

If (var1 <> var2) Then
    'Do Something'
End If

Would blow up with a Type Mismatch error on the line:

If (var1 <> var2) Then

After much searching I found out that:

var1 = CDBL(rs("DecimalField1").Value)
var2 = CDBL(rs("DecimalField2").Value)

resolves the issue. But that didn't seem like an obvious thing and it took me a while to figure out why the heck I was getting a Type Mismatch on that line.

So my question to everyone is, what other little quirks like this have you run across? What are some things within ASP/vbscript that you would think of as "gotchas" that I should be on the lookout for?

like image 546
pfunk Avatar asked Nov 13 '08 16:11

pfunk


2 Answers

Repeat after me: All good VB programmers use Option Explicit

It will keep you from accidentally declaring a new variable and using it - thus throwing off whatever you are doing.

Beyond that, it depends on what you're doing.

like image 109
AnonJr Avatar answered Oct 27 '22 04:10

AnonJr


Beware anytime you see the following line:

On Error Resume Next

That would be my caution in using classic ASP.

like image 26
JB King Avatar answered Oct 27 '22 03:10

JB King