VB5里面实现VB6的InstrRev()和Split()一样的替换函数

来源:互联网 发布:襄阳程序员工资 编辑:程序博客网 时间:2024/06/06 03:59
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

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

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击