Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array length

Status
Not open for further replies.

RycherX

Programmer
Mar 18, 2002
20
US
When I use length, it gives me the capacity of the BlockList. Is there any way to check if an array contains values that are not equal to "nothing".



Dim BlockList() as String

if BlockList.length > 0 then

end if
 
I haben't ever seen property of array ".length()".
Anyway : Dim BlockList(..) As String - each element of the string array has preset value the empty string ""
Dim BlockList(..) As Integer, same way default value is zero.


Maybe you want this: msgbox UBound(BlockList) that gives the upper bound of the array. If it is i.e. 6 the indexs are 0 to 5. If it's 0 there is no array

?
 
Try the VB.net Forum forum796

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
>>If it's 0 there is no array

Huh?

Code:
Dim strArray(0) as string

Debug.print UBound(strArray)

Does this mean there is no array?
 
Ok i'll answear my question.

You can store only one string value, so why not use a simple string variable?

Now you could tell me that with this (dim myarr(0) as string) you can have a dynamically increased/decreased size array: ReDim Preserve myarr(5) as string !

If you had thought of this.... ok I loose :):):):):)
 
UBound does not return how many values there is in the array. UBound gives the Upper Boundary of the array.

Depending on your option base (or the way you declared your array) you can use it to determine how many values are in the array... but it is not reliable.

There has been a discussion in full on this forum (I believe even more than once) on how to correctly get the number of elements in the array. See thread222-836312

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top