CountFieldsB

From Xojo Documentation
Jump to: navigation, search
Method

Returns the number of values (fields) in the string passed that are separated by the separator string passed.

Syntax

result=CountFieldsB(source, separator)

Part Type Description
result Integer The number of values in source that are separated by separator.
source String The original string.
separator String The character or characters that separates the values in source. Separator can be of any length.

Notes

CountFieldsB is identical to CountFields, except that it treats the source string as a series of raw bytes. Use this instead of CountFields if you need the function to be case-sensitive.

The CountFieldsB function is useful for reading columns of data from a text file where the columns (fields) are delimited with a specific character or characters.

If the separator is not found within source, CountFieldsB returns 1. If source is null, CountFieldsB returns zero.

Examples

The example below returns 5.

Dim count As Integer
Dim s As String
s = "Dan*Smith*11/22/69*5125554323*Male"
count = CountFieldsB(s, "*")

The following example returns three because it counts the null "field" after the (unnecessary) final field delimiter.

Dim count As Integer
Dim s As String
s = "Dan*Smith*"
count = CountFieldsB(s, "*")


See also the example that illustrates how to populate a PopupMenu control.

See Also

CountFields, NthFieldB, SplitB functions; TextInputStream object example.

Personal tools
Namespaces

Variants
Actions
Main
Content
Starting Out
Dig Deeper
More Help
Toolbox
About