• Welcome to Valhalla Legends Archive.
 

Getting the upper bound of a array on a array (vb)

Started by Zeller, January 29, 2004, 06:19 PM

Previous topic - Next topic

Zeller

I made an array that holds arrays of strings. ex:


dim myArray(100)() as string
for i = 0 to 100
   myArray(i) = textbox1.split("Y")
next


Now in my real program each string array of strings would be a different size.

The problem im having is getting the upper bound of the second array (the array already on the array). Can some one post an example on how to retrieve it

drivehappy


Zeller

That function returns the upper bound for a single multidimensional array. If you looked, both arrays only have 1 dimension.

Zeller

Anyway I decided to solve the problem by putting my arrays in an arraylist object so I dont need help anymore.

MyndFyre

For future reference....

Drivehappy was close.  We need to realize that when utilizing a two-dimensional array, we can really envision an array of arrays.

So, you could do something like:


Dim i As Integer
For i = 0 to 100
 Console.WriteLine("Line length {0}, Upper boundary {1}.", myArray(i).Length, myArray(i).Length - 1)
Next


Why add yet another level of indirection when you can use something rather fast and simple?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Zeller

I guess that would work, I never saw a length used like that (exept when debugging). +1 for you  ;)

btw I honestly did not understand you last sentence

MyndFyre

What I meant was that with an arraylist, you will end up adding another reference type, and hence essentially another pointer, and thus another level of indirection.  Those take more time to access than simply using arrays, because arrays just use the offset you specify.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Zeller

You still lost me with your pointers and indirection crap. If your trying to say using an arraylist would slow my program down, I can sacrafice a couple miliseconds