Search Tools Links Login


Posted: 2002-06-01
By: ArchiveBot
Viewed: 81

Filed Under:

VB6 Code Cache

No attachments for this post

Visual Basic 6 has a new function called InStrRev, which searches a string from right to left. I found it very usefeul, so much so that a project of mine relies completely on it. When I tried to work on the project at another location on VB5 I found that the function did not exist. So, I wrote it.
I left out the compare method, you can add it if you want

Original Author: Shane Presley


RevInStr(String1 As String, String2 As String)


let positon = RevInStr("Http://","/")
In this case position would be 22, not 1


The Integer returned is the postion of the String 2 in String 1.

API Declarations



Public Function RevInStr(String1 As String, String2 As String) As Integer
  Dim pos As Integer
  Dim pos2 As Integer
  Let pos2 = Len(String1)
    Let pos = (InStr(pos2, String1, String2))
    Let pos2 = pos2 - 1
  Loop Until pos > 0 Or pos2 = 0
  Let RevInStr = pos
End Function

Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.