Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADDING ITEMS TO A 2D ARRAY - HELP PLEASE!!

Status
Not open for further replies.

mjurcisin

Programmer
Dec 11, 2001
2
US
I am trying to create a single array that is 155 x 5. Is there an easier way than adding each item individually?? Can you add an entire row (5 items) with one command?

I would appreciate any input/alternative ideas that anyone may have. Thanks!!!!
 
Are these items already existing in a table somewhere? If so, you could populate them from the table via a database connection. Then you could loop through the items row by row and create a recordset that you then manipulate.
hth
mark
 
No, the items don't exist in a table. They must be hard coded due to system specs. If you have any ideas i'm all ears. Thanks!!
 
YIKES! Do these parts (or whatever) change often? If they do...that's gonna get UGLY as far as updating goes if they change. Does your system not allow you to access outside tables (legacy software?)? About the only thing I can think of that might be of any value is to look into possibly using a dictionary object or possibly an include file (depending on how you want to approach it and manipulate it). Possibly a HUGE case statement but...any way you go, sounds like A LOT of entry so that you have something to start with and work from. Sorry not more helpful.
hth
mark
 
I can't think of a command to add them one at a time. You can populate an array entirely when you dimension it, but other than that, you'll have to go 1X1.

:-(
penny.gif
penny.gif
 
A bit late I know, but I was struggling with this last December too, but not subscribed to Tek-Tips then! Assuming like me you want to populate the array entirely on the client side, you can improve on "one by one" by using the Array function to help populate a row (or column) at a time. Unfortunately the array function only supports one dimension.

e.g:
Code:
Sub FillRow(MainArray, RowNumber, TempArray)
	Dim i
	for i=0 to ubound(TempArray)
		MainArray(RowNumber,i) = TempArray(i)
	next
End Sub

Dim TempArray(3), MainArray(3,3)

TempArray = Array("A","B","C")
Call FillRow(MainArray,1,TempArray)

TempArray = Array("D","E","F")
Call FillRow(MainArray,2,TempArray)

TempArray = Array("G","H","I")
Call FillRow(MainArray,3,TempArray)
This way you save a lot of code space as you have reduced the data to CSV format.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top