By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,558 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,558 IT Pros & Developers. It's quick & easy.

Array Refrencing

P: 1
I have an array as below:

Expand|Select|Wrap|Line Numbers
  1. .  A   B   C   D   E
  2. A  0   10  20  30  40
  3.  
  4. B  10  0   15  20  30
  5.  
  6. C  20  15  0   25  30
  7.  
  8. D  30  20  25  0   40
  9.  
  10. E  40  30  30  40  0
I also have 2 variables named;

(1) TOO (to indicate Row)
(2) FROM (to indicate column)

I want my variable to be the reference for my array
e.g if TOO= 1
FROM=2
would return 10 (A,B)

TOO= 3
FROM=4
would return 25 (C,D)


TOO= 3
FROM=5
would return 30 (C,E)

How can I do this please?
Dec 27 '07 #1
Share this Question
Share on Google+
2 Replies


RedSon
Expert 5K+
P: 5,000
I want my variable to be the refrence for my array
e.g if TOO= 1
FROM=2
would return 10 (A,B)

TOO= 3
FROM=4
would return 25 (C,D)


TOO= 3
FROM=5
would return 30 (C,E)

How can I do this Please
What if you did it like this: TOO = 'C' and FROM = 'D' and you made your array two dimensional? How easy would it be then? All you would have to do is access your array at index [TOO, FROM] and you would have your answer.
Dec 27 '07 #2

Expert 5K+
P: 8,434
I have an array as below ...
Your description basically sounds like the definition of a two-dimensional array.

However, are you saying that you actually have letters "A", etc. for the index values? If so, converting them to numbers is easy enough. There are various techniques you could employ, but probably the simplest is to subtract 64 (or 65) from the ASCII value of the letter. For example, try typing this in VB's immediate window...
Expand|Select|Wrap|Line Numbers
  1. PRINT ASC("A") - 64
The reason I mentioned 65 is that a number of people prefer to begin arrays at zero rather than one. I don't, but thought I should mention it.
Dec 28 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.