VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seac

by DoctorMO (3 Submissions)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 2nd March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seach a string Backwards, forwards stop at any

API Declarations


Public Const IS_Mode_For = 0
Public Const IS_Mode_Back = 1
Public Const IS_Mode_Number = 2

Rate For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seac



Dim Z As Integer
Dim CN As Long, ChrSteping As Integer
Dim ChrFrom As Integer, ChrTo As Integer

'This is an Instr function without using ther VB InStr Function
'The InstrEx function includes the normal start Position,
'Input Main String and input Compair String, also includes
'Modes for Backwards or Forwards Checking and Charictor
'Number is multipul charictors are in the string

    CN = ChrNumber
    If CN = Null Or CN = 0 Then CN = 1
    CN = CN - 1
    
    If IS_Mode = IS_Mode_For Then
        ChrSteping = 1
        If StartPos = 0 Or StartPos = vbNull Then StartPos = 1
        ChrFrom = StartPos
        ChrTo = Len(String1)
    ElseIf IS_Mode = IS_Mode_Back Then
        ChrSteping = -1
        If StartPos = 0 Or StartPos = vbNull Then StartPos = Len(String1)
        ChrFrom = StartPos
        ChrTo = 1
    ElseIf IS_Mode = IS_Mode_Number Then
        ChrSteping = 1
        ChrFrom = 1
        ChrTo = Len(String1)
    End If
    
    For Z = ChrFrom To ChrTo Step ChrSteping
        
            Str1 = Mid(String1, Z, Len(String2))
        
        If Str1 = String2 Then
            If IS_Mode = IS_Mode_Number Then
                InStrEx = InStrEx + 1
            Else
                InStrEx = Z
                If CN = 0 Then
                    Exit Function
                Else
                    CN = CN - 1
                End If
            End If
        End If
        
    Next Z
    
End Function


Download this snippet    Add to My Saved Code

For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seac Comments

No comments have been posted about For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seac. Why not be the first to post a comment about For any one with VB5 and dosn't have the InStrRev function, this is now available InStrEx Will seac.

Post your comment

Subject:
Message:
0/1000 characters