vbscriptsyntaxwsh

Checking VBScript syntax


Any good utilities out there for verifying VBScript syntax without actually running the script?

What I'm getting at is if I do something like:

If (year == "2005" && type == 1) Then
...
End If

Is there a tool that will tell me that the '&&' really should be 'And' and the '==', just '='?


Solution

  • Actually, I think there is a way. The Script Control includes an Execute method similar to HTML VBScript's Eval method. You can give it a string and it will syntax check it.

    You can still get it from here. http://www.microsoft.com/downloads/details.aspx?FamilyID=d7e31492-2595-49e6-8c02-1426fec693ac&displaylang=en

    This old MSDN article describes how to add Scripting to your Apps. http://msdn.microsoft.com/en-us/magazine/cc302278.aspx

    MSDN Article on the Script Control http://msdn.microsoft.com/en-us/library/aa227633(VS.60).aspx

    Something like this.. (not sure of the instantiation)

    Dim ScriptControl1 as New MSScript
    ScriptControl1.ExecuteStatement “If (year == "2005" && type == 1) Then..End If”