473,465 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array Refrencing

1 New Member
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
2 976
RedSon
5,000 Recognized Expert Expert
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
Killer42
8,435 Recognized Expert Expert
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

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

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
0
by: NathanV | last post by:
I have a class that I'm refrencing thats in a class library. VS.NET gives me an error when calling which states, 'Namespace does not exist in the class or namespace...'. The page compliles and...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.