Code Snippets


Public Sub Str_ToArray(ByVal sText As String, _ 
                       ByRef vArrayName As Variant, _
                       Optional ByVal sSeparateChar As String = ";")
Dim snextentry As String
Dim iarraycount As Integer
Dim inoofchars As Integer
   On Error GoTo AnError
   inoofchars = Str_CharsNoOf(sText, sSeparateChar)
   If inoofchars > 0 Then
      ReDim vArrayName(inoofchars, 1)
      iarraycount = 1
      Do While Len(sText) > 0
         If InStr(1, sText, sSeperateChar) = 0 Then
            snextentry = sText
            sText = ""
         Else
            snextentry = Left(sText, InStr(1, sText, sSeparateChar) - 1)
            sText = Right(sText, Len(sText) - Len(snextentry) - 1)
         End If
         vArrayName(iarraycount, 1) = snextentry
         iarraycount = iarraycount + 1
      Loop
   End If
   If gbDEBUG = False Then Exit Sub
AnError:
   Call Error_Handle("Str_ToArray", msMODULENAME, 1, _
        "split up the string" & vbCrLf & sText & vbCrLf & _
        "separated by " & sSeparateChar & " and place them in an array")
End Sub



© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

Prev