I'm a tech writer but have dabbled in coding for many years now. For work, I need to test about a hundred different ancient script samples. The samples are stored in our documentation. They are in written in Basic (technically, in Cypress Enable BASIC, but it's essentially very similar if not identical to Basic scripting). I need to test them and fix any that are broken.
I want to set up Visual Studio Code to run these because I love VSC as it has a lot of benefits over the very old and vanilla scripting editor included with our product that I've been using.
Mainly, I need to be able to copy and paste the code I want to test into VSC into a simple .bas file and then run and test the code inside VSC with code coloring, code running, and a debugger. Intellisense would also be helpful. I can get color coding, but getting it to run and debug isn't working.
I've already spent hours trying to set something up, but can't figure it out.
C:\Windows\Microsoft.NET\Framework64\v3.5
to my system's Path Environment Variable. (where <user>
is my user name).Something is wrong, as I consistently get errors. For example, with Code Runner extension installed, if I try to run this very simple vbscript to show a test message box...
Sub Main ()
Dim testString
testString = "Meh... Will it work?"
MsgBox testString
End Sub
...I get this result in my VSC Output window:
[Running] cscript //Nologo "d:\Temp\vbscripttest.bas"
[Done] exited with code=0 in 0.174 seconds
I find very little info searching on code=0 error that is useful.
My script is in my d:\temp folder. I don't know if that makes a difference. If I try running the .bas file from the File Explorer window directly by double-clicking on it, nothing happens. Though from the icon style, it appears to be mapped to VBScript.
I gather either Windows or vbcode or both can't find the vbscripting goodness that makes things work, though I thought pointing the path variable to C:\Windows\Microsoft.NET\Framework64\v3.5
would fix that.
After two days of pulling my eyebrows out using our product's internal script editor to test my scripts (my hair has long since gone), I am hankering for some good old fashioned debugging support in my favorite code editor!
What do you recommend I do to get things working? Thank you in advance for your help.
Your sample program is running successfully. In that file there is no code in the code path. VBScript in a top level language (unlike VBA). That means code runs outside of a sub or function.
So insert before the first line Main
to call Main
. Or lose the Sub ... End Sub
for VBScript. In VBA/VB6 you would choose Sub Main
as the startup sub in Properties.
While this is not your problem, just to be complete, if you start a script in CScript
or WScript
using //b
command line parameter then message boxes are not displayed. See CScript /?
.