CountFields

From REALbasicWiki

Jump to: navigation, search
Overall article skill Skill ranges from beginner (green) to expert (red)

CountFields returns the number of fields delimited by the passed separator in the passed string.

Contents

[edit] Prototype

Function CountFields(source as String, separator as String) as Integer

[edit] Discussion

CountFields is frequently used in conjunction with NthField to parse a string into fields.

[edit] Sample Code

Here, CountFields returns 4.

return CountFields("1 Infinite Loop,Cupertino, CA, 95014", ",")

You may use the Chr Function to specify other delimiters. For example, use Chr(9) for the tab character. Here CountFields returns 5.

return CountFields("A <tab> X <tab> B1 <tab> 0.04 <tab> 1.12", chr(9))

Use EndOfLine as the separator if you want to count the number of lines.

[edit] See also

Personal tools
related