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.
Basically it is the combination of Visual Basic programming language and JavaScript language. VBScript was invented and maintained by Microsoft. It is used to develop dynamic web pages. It is much lighter compared to Visual Basic programming language but works as a scripting language like JavaScript.
You can use WScript. Echo to see exactly what VBScript passes out; if the string you see in the result of WScript. Echo works in a command-prompt window, it will work as the first argument for the Run method.
If you want to execute a VBScript in the command prompt, you can use cscript.exe. See an example below. You can use Wscript. Echo in the VBScript in order to print information that will be displayed in the command prompt.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With