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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListCount in VBScript?

Status
Not open for further replies.

multiplex77

Programmer
Dec 25, 2001
302
SG
Hi,

Is there an equivalent to strObj.ListCount in VBScript? Basically i need to count the number of elements in a comma-delimited list of strings.

I'm actually really new to VBScript (I'm starting to code in ASP), but I'm more familiar with Visual Basic. After looking at the VBScript reference, I've discovered (to my disappointment) that VBScript doesn't have all the functions that Visual Basic has. Is this true? If so, what is the alternative so that my ASP pages can be equally powerful as a Visual Basic application?

Thanks very much for the advice... :)
 
Try this:

Dim str As String 'the string
Dim Pos, NElements As Integer

str = "Field1,Field2,Field3" 'a string of 3 elements

NElements = 1 ' there is always 1 element

Pos = InStr(1, str, ",") 'look for the first comma
While Pos
NElements = NElements + 1
Pos = InStr(Pos + 1, str, ",") 'next comma
Wend

Msgbox("Number of elements = " & NElements)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top