Is there a VB function that returns the number of elements in an array?

Posted by Bobble on Fri 02 Jan 2004 06:44 AM — 5 posts, 21,021 views.

Canada #0
Greets all,

I've been puttering around with VB for a while now and have gotten down many of the basics, but one thing I often stumble over is arrays.

Right now, I have a MUSHclient variable whose contents are the exits in the room I'm in.

So the variable "exits" will have the contents "north south in up".

One of the subroutines I have splits these into an array like so:

pitexits = split(world.getvariable ("exits"))

What I'd like to know is if there's a function that tells me how many elements in the array. So if the contents are "north sout in up" I'd want it to tell me that my array has 4 elements. Can anyone point me in the direction of the function I need?
Canada #1
Well, didn't take long for me to get one method of doing this:

ubound(arrayname)+1

Anyone know of another way to accomplish this?
Australia Forum Administrator #2
lbound (array) is the lower bound
ubound (array) is the upper bound

So, cycling between lbound (array) and ubound (array) is the correct way of working through it.
#3
LBound(array) is sorta redundant. If your array is a single dimension, the lower bound is always zero.
USA #4
Well.. Technically it can be 0 or 1 in true VB, depending on which you tell it to use. I think you can set this in VBScript as well, but I could be wrong.