Count

Returns the number of items in a collection.

Syntax

Collection.Count

Return Value

    Returns a Long value.

Example

Response.Write "We have " & Family.Childrens.Count & " kids and they are named:<br>"

For iItem = 0 to Family.Childrens.Count-1
  Response.Write Family.Childrens(iItem) + "<br>"
Next

The same could be written using the For Each syntax:

For Each child In Family.Childrens
  Response.Write Family.Childrens(child) + "<br>"
Next

Remarks

Because numbering for members of a collection begins with zero, you should always code loops starting with the zero member and ending with the value of the Count property minus 1. In VBScript it is preferable to use the For Each ... Next syntax.

Applies To

Collection Object



©2001-2015 eMill. All trademarks property of their owners.