Counting Fields in a Delimited String (or Words in a String)
Version Compatibility: Visual Basic 6, Visual Basic 5
For example - the following string contains four fields (this routine would return a 4).
Roger Wilco, 02 9805 9809, Space Fleet Headquarters, Janitor
Since sentances are delimited by spaces, this routine could also be used to count the number of words in a string (by passing a single space as a delimiter).
This is especially useful for VB5, because in VB6 you can do a similiar thing with fewer lines of code using the Split function.
Instructions: Copy the declarations and code below and paste directly into your VB project.