Re: Init. Multi-dimensional String Arrays VB vs. VBA
- From: "Jonathan West" <jwest@xxxxxxxx>
- Date: Mon, 28 Apr 2008 23:01:17 +0100
"cushlomokree" <cushlomokree@xxxxxxxxxxxxxxxx> wrote in message
news:Onq01VXqIHA.3680@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I'm having a little syntax nightmare.
I am trying to initialize a small 2-dimensional string array in VBA 6.5
(Word 2003).
I'm using syntax that works OK in Visual Studio 2005 VB, but VBA keeps
giving me an error (Compiler error ...expected expression.)
Here's the code:
Dim bookends(,) As String = {{"(", ")"}, {"[", "]"}, _
{"{", "}"}, {"<", ">"}}
Can anyone shed some light on this?
Yes, you are working under the misapprehension that VB.NET is the same
language as VB. The language was substantially changed in the transition
from VB6 to VB.NET. (Take a look at http://classicvb.org/ if you want to
understand more about this.)
Essentially, you have to regard VB.NET and VBA as two completely different
languages. Even their Integers aren't the same!
In VBA, you can't dimension and initialise a string array in a single
statement. You need to separate the dimension and initialisation.
Dim bookends(3, 1) As String
bookends(0, 0) = "("
bookends(0, 1) = ")"
bookends(1, 0) = "["
bookends(1, 1) = "]"
bookends(2, 0) = "{"
bookends(2, 1) = "}"
bookends(3, 0) = "<"
bookends(3, 1) = ">"
--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
.
- Follow-Ups:
- Re: Init. Multi-dimensional String Arrays VB vs. VBA
- From: cushlomokree
- Re: Init. Multi-dimensional String Arrays VB vs. VBA
- References:
- Init. Multi-dimensional String Arrays VB vs. VBA
- From: cushlomokree
- Init. Multi-dimensional String Arrays VB vs. VBA
- Prev by Date: Re: Print with VBA
- Next by Date: open with command in windows exporer to open template
- Previous by thread: Init. Multi-dimensional String Arrays VB vs. VBA
- Next by thread: Re: Init. Multi-dimensional String Arrays VB vs. VBA
- Index(es):
Relevant Pages
|