CharEnumerator

CharEnumerator


Used to enumerate the characters in a string from start to end.


Remarks

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.

Example

 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

See Also

Project VBCorLib Overview | Constructors | IEnumerator

Implements:

IEnumerator 
IObject 

Public:

Properties:

NameDescription
 Current (get)This returns the current item of the enumeration. The current item is called after a successful MoveNext. 

Methods:

NameDescription
 EqualsReturns a boolean indicating if the value and this object instance are the same instance. 
 GetHashCodeReturns a pseudo-unique number identifying this instance. 
 MoveNextRequests 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. 
 ResetRequests the enumerator resets itself to begin enumerating from the beginning. 
 ToStringReturns a string representation of this object instance.