VB5裡面實現VB6的InstrRev()和Split()一樣的替換函式 (轉)

gugu99發表於2007-10-13
VB5裡面實現VB6的InstrRev()和Split()一樣的替換函式 (轉)[@more@]

Private Function split_vb5(ByVal sstr As String, spstr As String) As Variant
Dim starstr, lenstr, cur As Integer
Dim backstr() As String
starstr = InStr(sstr, spstr)
cur = starstr + 1
lenstr = Len(sstr)
ReDim backstr(0)
backstr(0) = Left(sstr, starstr - 1)
For x = starstr + 1 To lenstr
    If Mid(sstr, x, 1) = spstr Then
        ReDim Preserve backstr(UBound(backstr) + 1)
        backstr(UBound(backstr)) = Mid(sstr, cur, x - cur)
        cur = x + 1
        De.Print backstr(UBound(backstr))
    End If
Next
split_vb5 = backstr()
End Function

'****************************** 

Private Function InStrRev_vb5(ByVal start As Integer, ByVal str1 As String, ByVal str2 As String)
str1 = revstr(str1)
str2 = revstr(str2)
start=Len(str1)-start
InStrRev_vb5 = Len(str1) - InStr(start, str1, str2)
End Function

Private Function revstr(str As String) As String
Dim x, lenstr As Integer
lenstr = Len(str)
For x = lenstr To 1 Step -1
  revstr = revstr & Mid(str, x, 1)
Next
End Function


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-976331/,如需轉載,請註明出處,否則將追究法律責任。

相關文章