1

In my .VBS file, whenever using any such declaration, I am getting error.Why so,any ideae?

Option Explicit

Dim vString as String

Error is : "Expected end of Statement"

I could not declare any variable with its required data types.

CodeLover
  • 1,054
  • 6
  • 24
  • 40
  • I found a VBS manual where that syntax Dim As was valid, but not in Microsoft's: [here](https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/scripting-articles/zexdsyc0(v=vs.84)) the only valid syntax is Dim . I couldn't find the newest Microsoft manual. – Corral Jan 30 '23 at 19:19

1 Answers1

3

In VBScript there is only variants so it would be Dim vString (remove the As String)

Fred
  • 5,663
  • 4
  • 45
  • 74
  • Okie..When i declared a Variable as Dim vNumber As Long. Also getting the same error. – CodeLover Dec 13 '12 at 08:29
  • All variable declarations are variants so none need the As xxx. Just `Dim VarName` no matter what data type you are storing in it. – Fred Dec 13 '12 at 08:31
  • Okie..one more query is, Suppose a scenario occurs where i need to store a long number to vNumber. In that case any chance to throw an error? – CodeLover Dec 13 '12 at 08:40
  • Not 100% sure I understand the question fully but you can store any data type (inc long) in vNumber and it wont throw an error. – Fred Dec 13 '12 at 08:42
  • There are types in VBScript but it is correct to say it defaults to variants https://stackoverflow.com/questions/3281355/get-the-type-of-a-variable-in-vbscript – Lime Aug 28 '20 at 20:58