程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> VB5裡面實現VB6的InstrRev()和Split()一樣的替換函數

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

編輯:VB綜合教程

  

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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved