<div class="meta" robots="noindex">

</div>

Method

# CountFieldsB

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `MemoryBlock</api/language/memoryblock>` as a replacement.

</div>

## Description

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

## Usage

*result* = **CountFieldsB**(*source*, *separator*)

| Part      | Type                               | Description                                                                                          |
|-----------|------------------------------------|------------------------------------------------------------------------------------------------------|
| result    | `Integer</api/data_types/integer>` | The number of values in *source* that are separated by *separator*.                                  |
| source    | `String</api/data_types/string>`   | The original string.                                                                                 |
| separator | `String</api/data_types/string>`   | The character or characters that separates the values in *source*. *Separator* can be of any length. |

## Notes

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

The <span class="title-ref">CountFieldsB</span> 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*, <span class="title-ref">CountFieldsB</span> returns 1. If *source* is null, <span class="title-ref">CountFieldsB</span> returns zero.

## Sample code

The code below returns 5.

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

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

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

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

## Compatibility

All project types on all supported operating systems.

## See also

`String.CountFields<string.countfields>`, `MemoryBlock</api/language/memoryblock>`, `String.SplitBytes<string.splitbytes>` functions; `TextInputStream</api/files/textinputstream>` object example
