VB5 inside the VB6 InStrRev () and split () the same substitution function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.