Results 1 to 11 of 11

Thread: Can anyone provide these codesnippets?

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Question

    (as i have vb5 and not vb6)

    Split
    Join
    Rinstr (the opposite to instr)
    Replace

    Thanks
    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.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    Ooh come on man! Those functions are cake to implement.
    -Shickadance

  3. #3
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    go to the msdn site and do a search on vb 6 string functions.

    they have replacements for them there.

  4. #4

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    i hate searching in big sites, can anyone give me a link
    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.

  5. #5
    Guest
    What's Rinstr? I thought the opposite was called InstrRev

  6. #6
    Guest
    I went looking for a link and found one. They are pretty easy to find.

    http://support.microsoft.com/support.../Q188/0/07.ASP

  7. #7

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yeah yeah yeah, meg, i wasn't sure, I though it was like "Right instr", ok, thanks for the link meg
    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.

  8. #8
    Guest
    Now you can add it to your template directory. That's what I did. I just saved the module as VB6 Functions and put it in the module template directory.

  9. #9
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    Try these, I think I got them all:
    Code:
    Public Function Split(Expression As String, Optional Delimiter) As Variant
        Dim aSections() As String
        Dim sTemp As String
        Dim nPos As Long
        
        sTemp = Expression
        ReDim aSections(0)
        nPos = InStr(sTemp, Delimiter)
        Do
            nPos = InStr(sTemp, Delimiter)
            If nPos Then
                aSections(UBound(aSections)) = Left(sTemp, nPos - 1)
            Else
                aSections(UBound(aSections)) = sTemp
            End If
            ReDim Preserve aSections(UBound(aSections) + 1)
            sTemp = Mid(sTemp, nPos + Len(Delimiter))
        Loop While nPos
        
        If UBound(aSections) Then
            ReDim Preserve aSections(UBound(aSections) - 1)
            Split = aSections
        Else
            Split = Array()
        End If
    End Function
    
    Public Function Join(SourceArray, Optional Delimiter) As String
        If IsMissing(Delimiter) Then Delimiter = ""
        Dim sTemp As String
        Dim nIndex As Long
        If InStr(LCase(TypeName(SourceArray)), "()") Then
            For nIndex = LBound(SourceArray) To UBound(SourceArray)
                sTemp = sTemp & SourceArray(nIndex) & Delimiter
            Next
        End If
        Join = Left(sTemp, Len(sTemp) - Len(Delimiter))
    End Function
    
    Public Function InStrRev(StringCheck As String, StringMatch As String, Optional Start As Long = -1) As Long
        Dim sTemp As String
        Dim nChar As Long
        Dim nPos As Long
        
        sTemp = Space(Len(StringCheck))
        For nChar = 0 To Len(StringCheck) - 1
            Mid(sTemp, nChar + 1, 1) = Mid(StringCheck, Len(StringCheck) - nChar, 1)
        Next
        If Start <= Len(StringCheck) Then
            nPos = InStr(IIf(Start = -1, 1, Len(StringCheck) + 1 - Start), sTemp, StringMatch)
        End If
        InStrRev = IIf(nPos, (Len(StringCheck) + 1) - nPos, 0)
    End Function
    
    Public Function Replace(Expression As String, Find As String, ReplaceWith As String, Optional Start As Long = 1, Optional Count As Long = -1) As String
        Dim sTemp As String
        Dim sNew As String
        Dim nChar As Long
        Dim nPos As Long
        Dim nBegPos As Long
        Dim nCount As Long
        
        sTemp = Mid(Expression, Start)
        sNew = Left(Expression, Start - 1)
        nPos = Start - 1
        Do
            nPos = InStr(sTemp, Find)
            If nPos Then
                nCount = nCount + 1
                sNew = sNew & Left(sTemp, nPos - 1) & ReplaceWith
                sTemp = Mid(sTemp, nPos + Len(Find))
            End If
        Loop While nPos <> 0 And (nCount < Count And Count > 0)
        
        Replace = sNew & sTemp
                
    End Function

  10. #10

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs up

    Thanks, Aaron, but that link worked too. Hey, you seem to able to answer me on my qwestions about file types:
    http://forums.vb-world.net/showthrea...threadid=18078
    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.

  11. #11
    Guest
    In my 1.11 years here, I have never seen him ask a question, only answer questions (with great detail too).

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