Results 1 to 2 of 2

Thread: ***-----Split Another Function---***

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    is there another way of performing the same function as "split", but doing it in Visual basic 5

    since this Split(String, 2) function is only available in VB 6

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'Here's the split function:
    Public Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
        Dim sRead As String, sOut() As String, nC As Integer
        If sDelim = "" Then
            Split = sIn
        End If
        sRead = ReadUntil(sIn, sDelim, bCompare)
        Do
            ReDim Preserve sOut(nC)
            sOut(nC) = sRead
            nC = nC + 1
            If nLimit <> -1 And nC >= nLimit Then Exit Do
            sRead = ReadUntil(sIn, sDelim)
        Loop While sRead <> ""
        ReDim Preserve sOut(nC)
        sOut(nC) = sIn
        Split = sOut
    End Function
    'But this one (made by Iain) is a lot faster, especially for larger strings:
    Private Sub Mysplit(Source, searchs As String, ByRef Arr() As String)
        Dim pos As Long, pos2 As Long, x As Long
        pos = 0
        If Right(Source, Len(searchs)) = searchs Then
            Source = Mid$(Source, 1, Len(Source) - Len(searchs))
        End If
        Do
            pos = InStr(pos + 1, Source, searchs, vbTextCompare)
            If pos = 0 Then Exit Do
            ReDim Preserve Arr(x)
            Arr(x) = Mid(Source, pos + 1, pos + Len(searchs) - 2)
            x = x + 1
        Loop
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width