I have start playing with VBScript a couple of days ago and there is a problem that is irritating me. I have tried to test simple hello world program:
Module Hello
Sub Main()
MsgBox("Hello, World!") ' Display message on computer screen.
End Sub
End Module
When I run it with cscript "hello world.vbs"
, from cmd. I'm getting an error:
M:\hello world.vbs(6, 1) Microsoft VBScript compilation error: Expected statement
When I change code to only:
MsgBox("Hello, World!") ' Display message on computer screen.
Code is running normally. There is a popup message and there are no errors.
I'm using Win 7 SP1, Sublime text 3 and I have installed .Net 4.5; 4.6.
I'm a bit noob to .VBS so please don't be harsh. Thank you xD.
The entry point for VBScript is the global area at the top of the script file.
You do not need to declare a containing structure like a Module
and a Main
function as an entry point.
Since it looks like you tried to adopt from Visual Basic (for Applications) I recommend Visual Basic for Applications Features Not In VBScript as a reference.