Counting members in array? (<=>not the length)

Wirloff

Member
Joined
Mar 2, 2005
Messages
19
Location
Belgium
Programming Experience
1-3
Hi,
is there any way that I can count the number of elements in an array? methods Length & Get Upperbounds return the length of the array (=how many elements could I place in the array), not how many places are allready taken....

Niko
 
No such method with arrays :s

I'm afraid there's no such method to use with arrays :(...
I know trying to solve it with indexof method (and look for empty elements..)but I still wonder if there is no other way..:s
 
VB.NET:
Dim Element as String  'Assuming this is a string array
Dim intCounter as Integer = 0

For Each Element in strArray
  intCounter += 1
Next Element
and when it's done there ya go, the number of elements in your array have been counted

to not count empty elements:
VB.NET:
 Dim Element as String  'Assuming this is a string array
 Dim intCounter as Integer = 0
 
 For Each Element in strArray
  If Element <> "" Then
	   intCounter += 1
  End If
 Next Element
 
Last edited:
Back
Top