Public Class StringTokenizer
  Private s As String
  Private i As Integer
  Private sep As String       'separator
  Private sArray() As String
  '------
  Public Sub New(ByVal st As String)
    s = st                    'kopiuj łańcuch znaków
    set_separator(" ")        'domyślny separator
  End Sub
  '------
  Public Sub New(ByVal st As String, ByVal sepr As String)
    s = st
    set_separator(sepr)       'tworzy tablicę
  End Sub
  '-----
  Private Sub set_separator(ByVal sp As String)
    sep = sp                  'kopiuj separator
    'twórz nową tablicę
    sArray = s.Split(sep.ToCharArray)
    i = 0
  End Sub
  '------
  Public Sub setSeparator(ByVal sp As String)
    set_separator(sp)
  End Sub
  '------
  Public Function nextToken() As String
    Dim j As Integer
    j = i
    i = i + 1
    If j < sArray.Length Then
      Return sArray(j)
    Else
      Return ""
    End If
  End Function
End Class

