473,395 Members | 1,468 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,395 software developers and data experts.

My first multidimension array- Can I set up each line at once?

68
I'm writing my first 2 dimensional array-
I understand this for one dimension:
Expand|Select|Wrap|Line Numbers
  1. MyArray = Array("Name", "Date", "Error")
and also using the split function,

I like that you can do one line at a time, but for 2 dimension, I have only found this:
Expand|Select|Wrap|Line Numbers
  1. MyArray(0,1) = "Name"
  2. MyArray(0,2) = "Date"
  3. MyArray(0,3) = "Error"
  4. MyArray(1,0) = "Blah"
  5. MyArray(1,2) = "Blah2"
  6. MyArray(1,3) = "Blah3" 
which does each variable individually.
I have a 9x7 table and having to do that 63 times doesn't seem like it can be right.
How do I set up 1 array with 9 lines and 7 columns, one line at a time?
Thanks
Jun 3 '11 #1
2 2042
Mihail
759 512MB
Expand|Select|Wrap|Line Numbers
  1. Dim numRows As Integer
  2. Dim numCols As Integer
  3.     numRows = 9
  4.     numCols = 7
  5.  
  6. Dim MyArray() As Variant, i As Integer, j As Integer
  7.     ReDim MyArray(numRows, numCols)
  8.     For i = 1 To numRows
  9.         For j = 1 To numCols
  10.             MyArray(i, j) = "Row " & i & ", Col " & j
  11.             Debug.Print MyArray(i, j)
  12.         Next j
  13.     Next i
and a useful link to learn more about arrays:
http://msdn.microsoft.com/en-us/libr...ice.10%29.aspx
Jun 4 '11 #2
NeoPa
32,556 Expert Mod 16PB
What you've left out of your question is the declaration of MyArray, which must not be as an array, but as a variant that can take the form of an array when called upon to.

Expand|Select|Wrap|Line Numbers
  1. MyArray = Array("Name", "Date", "Error")
The above code doesn't work with properly defined (or dimensioned) array variables (which is pretty unfortunate as most of the powerful functions that help with array work fall into the same category).

I believe this to be a fundamental omission on the part of the designers, and the lack of reference to it in the Help system particularly confusing for beginners and the more experienced alike.

I'm afraid the use of multi-dimensional arrays pretty well excludes the use of such helpful array-returning functions as Split() and Array().
Jun 4 '11 #3

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

Similar topics

3
by: jcrouse | last post by:
I have a text file that is about 5000 line long. Each line begins with a TAB. I'm trying to loop through the file a line at a time and remove the TAB but can't figure out how. I tried a substring...
5
by: dean | last post by:
sSQL = " update SELECTED_NODES " " set LABEL_S = 'Y' " " where NODE_I in " " ( " " select NODE_I " " from " " ( " " select ONODE_I NODE_I from link " " union all "
7
by: Milsnips | last post by:
Hi there, Can anyone help me out on this one? i want to read each line entered in a multiline textbox and store it into an array. I cant find any properties for this in the control, the only...
12
by: Matt F | last post by:
I'm creating simple ping script that prompts a user for various parameters. However, I would like each line of the ping displayed as it is received. Currently, the result isn't displayed until...
0
by: DR | last post by:
is there any speed difference between a TVF CLR that returns an array vs yield as each result is ready? e.g. does returning the array all at once cause sql server to allocate more efficiently?
6
by: bmerlover | last post by:
I'm trying to read each line, character by character, to determine if a line has a semicolon in it. I'm trying to count the number of lines that have a semicolon. In all of the files in one...
6
by: kronus | last post by:
Hi everyone, This is my first time posting to the UNIX form and it might be a strange request, but I believe I have most of the pieces. Here's the overall goal -- I am trying to find the links...
2
by: Peter9588 | last post by:
I am trying to read in every line from a given file and check (amongst other things) that the 3rd character of every line is a ';' (a semi colon). The files i make to go into my database needs to...
2
by: Matt F | last post by:
I am trying to read a text file and store each line as a seperate entry in an array. I have tried searching for how to do this but I can only find how to store the whole file into a 1D array.
0
by: Greg Jackson | last post by:
Hello, I am attempting to recreate Dijkstra's algorithm in Python but everything is going wrong. Here is my code: def twoDArray(): network = sourceNode f =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.