Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ VBscript
➜ Is there a VB function that returns the number of elements in an array?
|
Is there a VB function that returns the number of elements in an array?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Bobble
Canada (76 posts) Bio
|
| Date
| Fri 02 Jan 2004 06:44 AM (UTC) |
| Message
| 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? |
Open the watch. | | Top |
|
| Posted by
| Bobble
Canada (76 posts) Bio
|
| Date
| Reply #1 on Fri 02 Jan 2004 06:50 AM (UTC) |
| Message
| 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? |
Open the watch. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Fri 02 Jan 2004 08:41 AM (UTC) |
| Message
| 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. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Johnathan Allen
(49 posts) Bio
|
| Date
| Reply #3 on Sun 04 Jan 2004 07:02 PM (UTC) |
| Message
| | LBound(array) is sorta redundant. If your array is a single dimension, the lower bound is always zero. | | Top |
|
| Posted by
| Shadowfyr
USA (1,791 posts) Bio
|
| Date
| Reply #4 on Sun 04 Jan 2004 07:16 PM (UTC) |
| Message
| | 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. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
18,850 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top