Re: Init. Multi-dimensional String Arrays VB vs. VBA

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Jonathan
I was afraid that was the answer!
I sure was deluded. I thought VBA was a working subset of VB (without the
ability to create .exe's and .dll's)
When I "program" I usually use unmanaged C++ (not .NET), so all this
confusion over VB is my own fault.
I've seen the petition before and I agree with its intent, but somehow I
think MS is not listening.
Seems absurd that serious developers who have a huge codebase of linked,
binary executables (vs. CLR) would suddenly be deprived of that option for
extending their products.
As a macro language, I thought WordBasic was fine(Yes . I still keep a copy
of Word95 on my machine because it's faster, and it's NOT using wide
characters). It was actually simple enough for nonprogrammers to accomplish
a lot. Now you're telling me that VBA is just "OfficeBasic."
Has anyone documented the syntactical differences btw. VB (6), VB (.Net),
and VBA? Are there "gotcha's" if you choose to bypass VBA and create a
"Word.Application" object in VB (I attempted this, and it seems to work OK.
The main disadvantage in VB when working with the Word object is that
Intellisense does not seem to work.)? You mentioned the integer size
issue...
Thanks again,
Mike
"Jonathan West" <jwest@xxxxxxxx> wrote in message
news:%23ymAL2XqIHA.5416@xxxxxxxxxxxxxxxxxxxxxxx

"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




.



Relevant Pages

  • Re: Starting with VB2005 and SQL Server 2008 Express Edition
    ... As far as a "Development Platform" you are at the cross-roads of several ... soul-proprietors of the language and they can do with it as they will. ... VBA is a sub-set of VB "Visual Basic" the original VB ... This included versions VB1.1 to VB6. ...
    (microsoft.public.vb.database)
  • Re: Why to use VBA?
    ... c# is not suited to be the only language to write eneterprise Apps or system Programms! ... 1- use existing vba apps with new versions of office ... If Microsoft were to rewrite Office using the .NET platfrm instead of the ActiveX platform it uses now, they would probably be 4 years doing the rewrite with no features added. ...
    (microsoft.public.word.vba.general)
  • Re: Late binding Access from Excel
    ... programming language afterall VB is VBA's big brother, ... An Automation infrastructure. ... VBA is hosted by other COM-based applications to ...
    (microsoft.public.access.modulesdaovba)
  • Re: Language suggestions for beginners
    ... biology students how to program and also teach the CS ... the Excel VBA seems like ... Best language I used... ... Loop, ...
    (comp.ai.genetic)
  • Re: Newbie
    ... The "=" was highlighted on the second line of script, ... I searched the Help for "VBScript" and found that it is somehow ... scripting language than VBA. ... used by any language that has the ability to call COM libraries. ...
    (microsoft.public.data.ado)