DO11: Script Data Typing

My VB experience to date has been largely limited to Excel macros. I am used to being able to define variable types, e.g.

Dim n As Integer
Dim s As String
Function MyFunc(Arg1 as String, Arg2 as Integer)

This does not appear to be supported in Opus @script vbscript code.


I can get round the issue by using conversion functions such as CInt(n) when necessary but would prefer not to have to. Is there a way of "typing" variables in Opus @script vbscript routines?

Regards, AB

VBScript and VB or VBA have a few differences, and that's one of them.

All variables in VBScript are variants; you can't restrict them to any particular type. Just use "Dim i" instead of "Dim i As Integer".

(This isn't specific to Opus. The VBScript interpreter is part of Windows.)

Another problem with VBScript compared to VB/VBA is it has abysmal error handling. Your options are the script exiting on error or the script ignoring errors completely (on error resume next). The VB/VBA ability to define an error handler (on error goto x) is missing.

Microsoft have a Key Differences Between Visual Basic for Applications and VBScript page, but it's fairly awful, unfortunately. I couldn't find a better resource from a quick search but there's probably one out there somewhere.

JScript seems to be a much better language than VBScript and is also built into Windows.