473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access arrays via for next loop

I have 5 arrays, named array1 array2 array3 array4 array5. They are integer arrays each with 5 elements in them. I want to access all the elements in all the arrays using a for next loop,the pseudo code goes something like this:

Expand|Select|Wrap|Line Numbers
  1. for i = 1 to 5  'this loop calls each array
  2.  for j = 0 to 4 ' this loop calls each element
  3.      if array (i,j) then 
  4.         ' code goes here 
  5.     end if
  6.  next j
  7. next i
  8.  
  9.  
How would i do that please? Again, thanks for all and any help.
May 20 '09 #1
3 1711
tlhintoq
3,525 Expert 2GB
You seem to have a handle on it. What part exactly are you having a problem with? Is it that you don't know the actual syntax for a 'for loop' in VB?

Welcome to learning a programming language! It's always good to have people join the ranks. You will find a LOT of introductory 'how to' websites by doing a little googling. But your most valuable resource for Microsoft languages such as VB or C# would be the MSDN itself.
May 20 '09 #2
Hi and thanks for your reply. My struggle is with the syntax in this line of pseudo code

Expand|Select|Wrap|Line Numbers
  1.  
  2. if array (i,j) 
  3.  
  4.  
Instead of having to name each array directly in the loop, I want the loop counter to be used so that the above line is saying at the first pass of the i loop,
Expand|Select|Wrap|Line Numbers
  1. if array1 , element j
  2.  
then on each subsequent pass of the i loop the array in question becomes
array2 array3 array4 array5 . Thats the bit I'm not sure about. Hope I've explained myself clearly and if you can help then many thanks.
May 20 '09 #3
tlhintoq
3,525 Expert 2GB
if you have five different arrays, then the nested loop approach you have is how you do it.

If you have a single array, five elements wide, then you could do it with a couple index counters

ArrayName[Index1, Index2, Index3, Index4, Index5]
May 20 '09 #4

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

Similar topics

2
by: Bryce Maschino | last post by:
hello, i am trying to make a java program that will take several different arrays and search through them in a loop suchs as: for (i=0; i < 5; i++) { if (firstarray<such and such { blah blah
35
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 **********...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
3
by: Jeremy | last post by:
I have a predefined array that looks something like Private RemoveWords() As String = {"a", "b", "c" and I want to take an input string, and remove the words from the string that are in the...
0
by: mark | last post by:
I have found that deployed "RELEASE" versions of applications employing matrix multiplications perform much more efficiently (1.5 to 2 X) when the algorithm accesses the data in inner loop of the...
2
by: jccorreu | last post by:
I'm taking in data from multiple files that represents complex numbers for charateristics of different elements. I begin with arrays of doubles and interpolate to get standard values in real and...
12
by: divya | last post by:
1. If The size of the array is unknown during programming time then how is such array declared?? Suppose there is an Array named arrClashname(size unknown at start), Now when the clash occurs...
1
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
0
ADezii
by: ADezii | last post by:
If you want to visit each item in an Array, you have two alternatives: Use a For Each..Next loop, using a Variant to retrieve each value in turn. Use a For...Next loop, looping from the Lower...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
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,...

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.