Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

Visual Basic 6 array

This topic is 4602 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a function that returns a 2 dimensional array. How would i be able to check how many items are in the first element? the 2D array returns a certain number of points. ie: value(0,0) - x value for 1st point value(0,1) - y value for 1st point value(0,2) - z value for 1st point value(1,0) - x value for 2nd point etc... how would i be able to test the value to see if say there are a certain number of point. say i need to do if value has 5 points then for i = 0 to 4 do something with value(i,0) do something with value(i,1) do something with value(i,2) next i end if

Share this post


Link to post
Share on other sites
Advertisement
someone told me to do

on error resume next
then when i set a value for that point check to see if there's an error
if err.number = 0 then there is a point and continue, but there has to be a way to avoid errors, right?

if there's no other way i suppose doing that couldn't hurt...

Share this post


Link to post
Share on other sites
just use code like this:

Dim i As Integer
For i = 0 To UBound(value)
do something with value(i,0)
do something with value(i,1)
do something with value(i,2)
Next i

Share this post


Link to post
Share on other sites
ubound has a second optional argument that is the dimension you want to check - so for example:
for i = lbound(value, 1) to ubound(value, 1)
for j = lbound(value, 2) to ubound(value, 2)
do something with value(i,j)
next j
next i
end if

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!