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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

three dimensional array 1

Status
Not open for further replies.

adev111

Programmer
Jul 8, 2004
44
CA
Here is my array
==============
- vretdata Array of Variant
- vretdata[0] Array of Variant
vretdata[0][0] "job_posting_seq" String
vretdata[0][1] "applicant_seq" String
vretdata[0][2] "First_nm" String
vretdata[0][3] "Last_nm" String
vretdata[0][4] "apply_dt" String
vretdata[0][5] "job_title_EN" String
vretdata[0][6] "posting_opened_dt_EN" String
vretdata[0][7] "posted_by_EN" String
vretdata[0][8] "applicant_pool" String
vretdata[0][9] "job_category_seq" String
vretdata[0][10] "posting_status_nm_EN" String
vretdata[0][11] "job_function_seq" String
- vretdata[1] Array of Variant
- vretdata[1][0] Array of Variant
vretdata[1][0][0] 8 Long
vretdata[1][0][1] 8 Long
vretdata[1][0][2] 8 Long
vretdata[1][0][3] 8 Long
vretdata[1][0][4] 8 Long
vretdata[1][0][5] 8 Long
- vretdata[1][1] Array of Variant
vretdata[1][1][0] 78 Long
vretdata[1][1][1] 77 Long
vretdata[1][1][2] 76 Long
vretdata[1][1][3] 4 Long
vretdata[1][1][4] 1 Long
vretdata[1][1][5] 2 Long
- vretdata[1][2] Array of Variant
vretdata[1][2][0] "asd" String
vretdata[1][2][1] "asdf" String
vretdata[1][2][2] "asdfa" String
vretdata[1][2][3] "Asif" String
vretdata[1][2][4] "George" String
vretdata[1][2][5] "George" String
- vretdata[1][3] Array of Variant
vretdata[1][3][0] "asdf" String
vretdata[1][3][1] "asdf" String
vretdata[1][3][2] "asdf" String
vretdata[1][3][3] "Khan" String
vretdata[1][3][4] "Evink" String
vretdata[1][3][5] "Evink" String
- vretdata[1][4] Array of Variant
vretdata[1][4][0] #6/15/2004 2:29:00 PM# Date
vretdata[1][4][1] #6/15/2004 1:32:00 PM# Date
vretdata[1][4][2] #6/15/2004 1:16:00 PM# Date
vretdata[1][4][3] #6/10/2004 5:05:00 PM# Date
vretdata[1][4][4] #6/8/2004 1:22:00 PM# Date
vretdata[1][4][5] #1/1/2004# Date
- vretdata[1][5] Array of Variant
vretdata[1][5][0] "job title two" String
vretdata[1][5][1] "job title two" String
vretdata[1][5][2] "job title two" String
vretdata[1][5][3] "job title two" String
vretdata[1][5][4] "job title two" String
vretdata[1][5][5] "job title two" String
- vretdata[1][6] Array of Variant
vretdata[1][6][0] #1/1/2003# Date
vretdata[1][6][1] #1/1/2003# Date
vretdata[1][6][2] #1/1/2003# Date
vretdata[1][6][3] #1/1/2003# Date
vretdata[1][6][4] #1/1/2003# Date
vretdata[1][6][5] #1/1/2003# Date
- vretdata[1][7] Array of Variant
vretdata[1][7][0] "posted by you" String
vretdata[1][7][1] "posted by you" String
vretdata[1][7][2] "posted by you" String
vretdata[1][7][3] "posted by you" String
vretdata[1][7][4] "posted by you" String
vretdata[1][7][5] "posted by you" String
- vretdata[1][8] Array of Variant
vretdata[1][8][0] False Boolean
vretdata[1][8][1] False Boolean
vretdata[1][8][2] False Boolean
vretdata[1][8][3] False Boolean
vretdata[1][8][4] False Boolean
vretdata[1][8][5] False Boolean
- vretdata[1][9] Array of Variant
vretdata[1][9][0] 13 Long
vretdata[1][9][1] 13 Long
vretdata[1][9][2] 13 Long
vretdata[1][9][3] 13 Long
vretdata[1][9][4] 13 Long
vretdata[1][9][5] 13 Long
- vretdata[1][10] Array of Variant
vretdata[1][10][0] "Open" String
vretdata[1][10][1] "Open" String
vretdata[1][10][2] "Open" String
vretdata[1][10][3] "Open" String
vretdata[1][10][4] "Open" String
vretdata[1][10][5] "Open" String
- vretdata[1][11] Array of Variant
vretdata[1][11][0] 4 Long
vretdata[1][11][1] 4 Long
vretdata[1][11][2] 4 Long
vretdata[1][11][3] 4 Long
vretdata[1][11][4] 4 Long
vretdata[1][11][5] 4 Long
==============
I need to access all the elements of it. I know we usually do ArrayName(index1,indexj) for two dimensional arrays. But i do not know how do i access or print the value in the three dimensional array. For instance the one above. I tried doing <%=vretdata(1,11,1)%> but got nothing. Can some one please tell me how to print the value for the above three dimensional cell. I tried to do this:

For iDataStart = iRowStart-1 to UBound(vRetData(1),2)
For iCol = 1 to UBound(vRetData(1),1)
'Do not know how to get the value here
Next
Next

Can someone please help me on this please.
Thanks
 
Hi Robert,

Thanks for your answer. However, i have tried doing myarray(1,2,3) already but it doesn't work. As to the links, they do not mention anything about printing the particular element of the array. Any other ideas?

Thanks

adev
 
also,
I need to print this on an asp page, and i am not using vb at all!
Thanks
 
asp is any combo of script language, so means to an end is no different in the end. perhaps try the same way you assign them, response.write myvar[1][2][3]

[thumbsup2]DreX
aKa - Robert
 
Hi,

I have tried these combinations to print the array.
myarray((1,1),0)
myarray(1,1,0)
myarray((1),(1),(0)) -- looks bizarre
and these don't work!

Is there some other way to print them or traverse through the whole array?

Thanks
 
did you try it with the same square brackets you used to assign them ?


[thumbsup2]DreX
aKa - Robert
 
Hi Robert,

No, i had put a watch on this array. When i looked into the watch the values were displayed with square brackets. Dim myarray = someFunctionToGetValueFromDataBase
retrieves values from a database. These values being are stored into the variable myarray, which in turn becomes an array like structure.

Hope that answered your question

Thanks
 
I have to admit that the layout of your array is bothering me. The fact that it isn't consistent is going to be a problem.

My best guss on printing this thing (without seeing your declaration to see ho it is setup) is going to be:
Code:
Dim x, y, z

For x = 0 to UBound(vretdata)
   If isArray(vretdata(x)) Then
      For y = 0 to UBound(vretdata(x))
         If isArray(vretdaya(x)(y)) Then
            For z = 0 to UBound(vretdata(x)(y))
               Response.Write "[" & x & "," & y & "," & z & ]: " & vretdata(x)(y)(z) & "<br>"
            Next
         Else
            Response.Write "[" & x & "," & y & "]: " & vretdata(x)(y) & "<br>"
         End If
      Next
   Else
       Response.Write "[" & x & "]: " & vretdata(x) & "<br>"
   End If
Next

That should be capable of printing your entire array if I have guess the way it is setup correctly (arrays of arrays, not 3 dimension array).

If anyone else wants to mess around with this, here is some code to duplicate the arays in the first post:
Code:
vretdata = Array( _
	Array("job_posting_seq", "applicant_seq", "First_nm", "Last_nm", "apply_dt", "job_title_EN", "posting_opened_dt_EN", "posted_by_EN", "applicant_pool", "job_category_seq", "posting_status_nm_EN", "job_function_seq"), _
	Array( _
		Array(8,8,8,8,8,8), _
		Array(78,77,76,4,1,2), _
		Array("asd","asdf","asdfa","Asif","George","George"), _
		Array("asdf","asdf","asdf","Khan","Evink","Evink"), _
		Array(#6/15/2004 2:29:00 PM#, #6/15/2004 1:32:00 PM#, #6/15/2004 1:16:00 PM# ,#6/10/2004 5:05:00 PM#, #6/8/2004 1:22:00 PM#, #1/1/2004#), _
		Array("job title two", "job title two", "job title two", "job title two", "job title two", "job title two"), _
		Array(#1/1/2003#, #1/1/2003#, #1/1/2003#, #1/1/2003#, #1/1/2003#, #1/1/2003#), _
		Array("posted by you", "posted by you", "posted by you", "posted by you", "posted by you", "posted by you"), _
		Array(False, False, False, False, False, False), _
		Array(13, 13, 13, 13, 13, 13), _
		Array("Open", "Open", "Open", "Open", "Open", "Open"), _
		Array(4, 4, 4, 4, 4, 4)))

As I said earlier, this is not a 34 dimensional array, but arrays embedded in arrays. A 3 dimensional array would not allow you to assign values to second dimension indexes like it's done in vretdata[0]

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
tarwn is correct,
it is not a 3 dimensional array, it is a jagged array.
I didn't even realize VBS supported jagged arrays

blink.gif
 
VBS supports jagged arrays, but changing their values/structure is real pain in the #$*.

Anyway, this is recursive implementation. Should work for any level of nesting and all generic data types (sorry, no classes):
Code:
blah vRetData, ""

Sub blah( vData, sIndex )
	If IsArray( vData ) Then vValue = "" Else vValue = vData
	Response.Write "<li>" & sIndex & " <b>" & vValue & "</b><i> (" & TypeName(vData)  & ")</i></li>"
	
	If IsArray( vData ) Then
		i = 0
		Response.Write "<ul style='margin-top: 0px;'>"
		For Each vElem in vData
			blah vElem, sIndex & "[" & i & "]"
			i = i + 1
		Next
		Response.Write "</ul>"
	End If	
End Sub
 
My suggestion would be to lose the array altogether and ose a dictionary. Dictionaries are always preferable to arrys when dealing with complex data structures.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
My suggestion would be to lose the array altogether and use a dictionary. Dictionaries are always preferable to arrys when dealing with complex data structures.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
vongrunt: Nice, almost word for word what I was thinking before I decided I had posted enough already :)

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
are you making an array in vbscript:
Dim myarray = someFunctionToGetValueFromDataBase

and then trying to access the array in Javascript?
can you do that? vbscript arrays are simply referenced by the notation myarray(x,y,z)

Can you get out anything from the array at all? Can you find its ubound?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top