0

This may be obvious, but I can't find anything about it in my searching.

What is the difference between

MyVar() as String

and

MyVar as String()

I realise the first is an array made up of strings. But what is the second? What is a String Array? Or is it just the same?

Konrad
  • 63
  • 1
  • 7

2 Answers2

0

They both will produce the exact same result (create a string array) as in the duplicate post that sstan referred to.

But there's only one difference I can think of, which is: you can directly specify the number of elements that the array will consist of when using the first method..

Dim MyVar() As String 'An array of string (the number of elements aren't yet specified).
Dim MyVar As String() 'Same as above.
Dim MyVar(5) As String 'An array of string (consists of 6 elements).
Dim MyVar As String(5) 'Wrong (you'll get an error).

Hope that helps :)

  • That does help actually. I thought I was going crazy and couldn't see what the difference was. The error you mentioned is good to know! – Konrad Jun 23 '16 at 04:40
-1

Both MyVar() as String and MyVar as String() will create a string array

No difference

Sami
  • 3,686
  • 4
  • 17
  • 28