Solved

Multidimensional Arrays

Posted on 2001-07-26
5
180 Views
Last Modified: 2013-12-18
I'm a little confused by multidimensional arrays.
Bear with me I'm currently going through the process of figuring out the boundaries of notes.
(which is a painful process)... I apologise if this is confusing to read, but I am confused in writing it.  :o)

i.e. If I have an array listed as MyArray(1,1)
With entries:
MyArray(0,0) = "Fred, Manly"
MyArray(0,1) = "Fred, Man"
MyArray(1,0) = "Rita, Womanly"
MyArray(1,1) = "Rita, Woman"

I have the following questions:
Can I change an entry without needing to define both values again?  Lets say I want to change Fred to Bob, must I enter
MyArray(0,0) = "Bob, Manly"
MyArray(0,1) = "Bob, Man"
Or is there a way to change only MyArray(0)Fred to Bob without needing to re-define the other entries?

Alternatively can they be accessed individually?  Output to a field on a form displaying Doc.Output = MyArray(1,0) would give:  Rita, Womanly  

Can I just access the second value?

Basically what I would like to achieve is that I could have one field representing the person i.e. Rita and another field representing the entries associated with her. i.e. Womanly  and  Woman.

Could someone please enligten my understanding (or lack thereof).


Thanks
David.
0
Comment
Question by:dc_sava
5 Comments
 
LVL 4

Expert Comment

by:sloeber
ID: 6321021
Hello David,

Little remark, if you dont want to start from 0, you can add Option Base 1
If your array is MyArray(1,1) then you have a two dimensional array.
For assigning a value to each element.
You do the follow
MyArray(0,0) = 1
MyArray(1,0) = 2
MyArray(0,1) = 3
MyArray(1,1) = 4
So, you have generate a table MyArray(x,y) where x are the rows and y are the columns.
So, if you want to specify a cell, you give the row and the column.
If you say MyArray(0,1) = "Fred, Man"
Then you give the first row, second cell, two values Fred and Man
It is not so that you have set two different cells, you've only set one cell.

I hope that it's now a little bit more clear to you.

Greets,
Sloeber
0
 
LVL 4

Accepted Solution

by:
sloeber earned 100 total points
ID: 6321034
example
what I've done before is this

   | 0  |  1
----------------
0  | 1  |  3
----------------
1  | 2  |  4

If you want

MyArray
   |  0   |  1     |   2
 --------------------------------
0  | Fred | Man    |   Manly
---------------------------------
1  | Rita | Woman  |   Womanly

MyArray(0,0) = "Fred"
MyArray(1,0) = "Rita"
MyArray(0,1) = "Man"
MyArray(1,1) = "Woman"
MyArray(0,2) = "Manly"
MyArray(1,2) = "Womanly"

So if you want to access Womanly, then
doc.output = MyArray(1,2)
...................

Greets,
Sloeber



0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6321093
Okay, here's the way you do it :
Let's say you have two people with 3 properties so you would have an array defined like this :
Dim MyArray(2,3) as String
To set the elements you would do the following :
MyArray(0,0)="Bob"
MyArray(0,1)="Manly"
MyArray(0,2)="Man"
MyArray(1,0)="Rita"
MyArray(1,1)="Womanly"
MyArray(2,1)="Woman"

Now let's say you want to change the name from Bob to Fred.
You only need to change MyArray(0,0) so the statement is
MyArray(0,0)="Fred"
Now you can put all individual values in different fields by using the correct index.

What this array does is actually create a virtual table :
(I hope this will display readable)
  | 0    | 1       | 2
----------------------------
0 | Bob  | Manly   | Man
1 | Rita | Womanly | Woman

You can reference any element in the table by using the correct coordinates, so for examplke MyArray(0,1) equals "Manly" and MyArray(1,2) equals "Woman".

So in short you will want to have every seperate element in a seperate row, column in your virtual table. Then you could look upon this as the first column, being all the names, the second column the first name property and the third column the second name property.

I hope this clears up things a bit for you. If you need any further assistance clarification, just let us know.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6322035
0
 

Author Comment

by:dc_sava
ID: 6332522
Sloeber,

Thank-you for your response. It makes thing a lot clearer.
Now I may actually be able to use them properly.

Thanks also to Jerrith your response was as equally understandable.

Cheers
David.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now