+ Reply to Thread
Results 1 to 5 of 5

[SOLVED] Declaring 2 dimensional arrays

  1. #1
    Dan
    Guest

    [SOLVED] Declaring 2 dimensional arrays

    I want to have an array - Item(100,2) where the first column is a string and
    the second column is an integer.

    Is this possible? If so how do I declare the variable.

    Dan



  2. #2
    Chip Pearson
    Guest

    Re: Declaring 2 dimensional arrays

    Declare the array type as Variant. It can hold any data type.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "Dan" <[email protected]> wrote in message
    news:O%[email protected]...
    >I want to have an array - Item(100,2) where the first column is
    >a string and
    > the second column is an integer.
    >
    > Is this possible? If so how do I declare the variable.
    >
    > Dan
    >
    >




  3. #3
    Dan
    Guest

    Re: Declaring 2 dimensional arrays

    Thanks, I thought there was a way.

    Dan
    "Chip Pearson" <[email protected]> wrote in message
    news:[email protected]...
    > Declare the array type as Variant. It can hold any data type.
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "Dan" <[email protected]> wrote in message
    > news:O%[email protected]...
    >>I want to have an array - Item(100,2) where the first column is a string
    >>and
    >> the second column is an integer.
    >>
    >> Is this possible? If so how do I declare the variable.
    >>
    >> Dan
    >>
    >>

    >
    >




  4. #4
    Alan Beban
    Guest

    Re: Declaring 2 dimensional arrays

    For the particular case you describe, I believe you can also use

    Dim Item(100,2) As String

    I have no view on whether that is "better" than declaring it as a
    Variant type.

    Alan Beban

    Dan wrote:
    > Thanks, I thought there was a way.
    >
    > Dan
    > "Chip Pearson" <[email protected]> wrote in message
    > news:[email protected]...
    >
    >>Declare the array type as Variant. It can hold any data type.
    >>
    >>
    >>--
    >>Cordially,
    >>Chip Pearson
    >>Microsoft MVP - Excel
    >>Pearson Software Consulting, LLC
    >>www.cpearson.com
    >>
    >>
    >>"Dan" <[email protected]> wrote in message
    >>news:O%[email protected]...
    >>
    >>>I want to have an array - Item(100,2) where the first column is a string
    >>>and
    >>>the second column is an integer.
    >>>
    >>>Is this possible? If so how do I declare the variable.
    >>>
    >>>Dan
    >>>
    >>>

    >>
    >>

    >
    >


  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,881
    For my own education, what would be advantages and disadvantages to using a user-defined type for this kind of situation?

    Type myitems
    a as string
    b as integer
    End Type

    Sub test()
    Dim item(100) as myitems
    [code]
    End sub

    where the variable is referenced using item(i).a="somestring" and item(i).b=someinteger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1