Results 1 to 6 of 6

Thread: help with multidimensional arrays

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    Cordova, TN
    Posts
    60

    Unhappy help with multidimensional arrays

    I'm starting my first program in VB .NET, and it's just a simple address book (name, phone numbers, address, email and maybe a few dates). And i'm not really sure how to use arrays. The way i'm doing it is i'm gonna use a list box i think that displays the contacts and the phone numbers, and when you click on a name you can display that information. But i need to know how to save information to an array, access it at any given point in the array, and edit or delete infromation from the array. And i really have no clue on how to go about doing this. Any help would be greatly appreciated.
    How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemArrayClassTopic.htm

    Lots of discussion, many examples. At this time, as far as I understand it you still can't delete information from an array. You may want to look at Collections also, which support adding and deleting items:

    ms-help://MS.VSCC/MS.MSDNVS/vblr7/html/vaobjCollection.htm

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    Cordova, TN
    Posts
    60
    thanks, we never got to arrays in high school with this, and now that i'm in college i'm doing C so i'm not sure about much of vb now. But thanks for the help
    How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny

  4. #4
    Member BinaryAnge's Avatar
    Join Date
    Jun 2002
    Location
    Columbus,Ohio
    Posts
    51

    try this

    first of all, here is a multi dim array
    DIM MyArray( integer, integer) as string



    secondly, try using a structure, you like it for what you're doing.
    At the top in the module declarations area.

    private structure MyInfo
    dim MyFriendsName as string
    dim MyFriendsNumber as string
    whatever else you want
    end structure

    dim X(integer) as MyInfo
    then type X. and look at what you get.



    thirdly, arrays. if you dont know how many you want, dont declare it with an amount, do it this way
    DIM MyArray() as string

    then use redim preserve.

    redim preserve MyArray(integer)
    it should be an integer 1 more than the what your array is declared at so to start, integer would be 1 and so on.
    redim - redims it; preserve keeps whatever info was in the lesser parts of the array. example if your array is 10 big with info in all ten parts and you redim. you will lose that info. if you preserve it. it stays. if you redim preserve 1 higher, you keep all the old info, and expand your array 1 more. (if you use multi dim arrays, you can only redim the last dim.)
    redim MyArray(cant change, can change)


    hope this was helpful
    The Programmers Credo -
    Protect dumb-ass from himself.

  5. #5
    Member BinaryAnge's Avatar
    Join Date
    Jun 2002
    Location
    Columbus,Ohio
    Posts
    51

    oops

    where i told you to type x.

    you will need to specify which item in the array you want. type this

    X( an integer ). <------ a dot after the )
    The Programmers Credo -
    Protect dumb-ass from himself.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    Cordova, TN
    Posts
    60
    Yes that was very helpful, i wasn't sure if vb had structures in it or not. Unfortunately for me, structures is one of the reasons i failed my last programming class (wrong teacher for the class that didn't know how to explain the stuff very well). But then again it was in "C" too, but even though. Since i split up the first and last name, i will just concatenate them together, to make one item. I got visual studio .net for dummies, but in the vb part it didn't get into structures at all. So i'm gonna have to find some more books to help me read up on this stuff. I think the list box is gonna give me as much trouble as this, but i don't want to give up cuz i gotta learn But that was very helpful, thanks
    How come it's a penny for your thoughts, but you have to put your 2 cents in? Somebody's makin' a penny

Posting Permissions

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



Click Here to Expand Forum to Full Width