| CharEnumerator |
| ICloneable | |
| IEnumerator | |
| IObject |
| Name | Description |
|---|---|
Current (get) | This returns the current item of the enumeration. The current item is called after a successful MoveNext. |
| Name | Description |
|---|---|
Clone | Returns a clone of this instance of the enumerator. |
Equals | Returns a boolean indicating if the value and this object instance are the same instance. |
GetHashCode | Returns a pseudo-unique number identifying this instance. |
MoveNext | Requests the enumerator moves to the next item being enumerated. Returns True on success, False otherwise. This is called prior to Current. If this is successful, Current will be called. |
Reset | Requests the enumerator resets itself to begin enumerating from the beginning. |
ToString | Returns a string representation of this object instance. |
Each character in the string is treated as an Integer value. This equates to using AscW for each character. There is no Unicode conversion using a Code Page.
The return value is a 16-bit signed Integer. This means that characters above &H7fff (32767) with be negative. To change this to the corrisponding positive value, add &H10000 (65536) to the value.
Dim n As Variant
Dim s As String
s = "Hello"
' Iterate over a String using For..Each
For Each n In NewCharEnumerator(s)
Debug.Print n
Next n
' output
' 72
' 101
' 108
' 108
' 111
' Iterate over a String manually
Dim e As CharEnumerator
Set e = NewCharEnumerator(s)
Do While e.MoveNext
Debug.Print e.Current
Loop
' output
' 72
' 101
' 108
' 108
' 111