Results 1 to 6 of 6

Thread: Crappy InstrRev > Give me another one

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs down

    Well the InstrRev from the MSDN site was really a joke, as it was frustrating slow, and it got slower the longer strings you put into it. (as it reversed the whole string). Can anyone do another one that doesn't reverse it and still search for my string, btw, i only need one char to search for so that should be pretty easy code for you to make.

    Thanks!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    I hope this is what your after. Not perfect i know, but i know you are more than capable of changing it.

    Code:
    Option Explicit
    
    Private Function myInstrRev(stString As String, stFind As String, Optional iStart As Long) As Long
        Dim iCtr As Long
        Dim iLen As Integer
        Dim iLoopStart As Long
        
        iLen = Len(stFind)
        
        If iStart > 0 Then
          If iStart > Len(stString) Then
            iStart = Len(stString)
          End If
          iLoopStart = iStart
        Else
          iLoopStart = Len(stString)
        End If
        
        For iCtr = iLoopStart To 1 Step -1
          If Mid$(stString, iCtr, iLen) = stFind Then
            myInstrRev = iCtr
            Exit Function
          End If
        Next iCtr
        
    End Function
    
    Private Sub Command1_Click()
        
        MsgBox myInstrRev(Text1.Text, Text2.Text, Val(Text3.Text))
        
    End Sub
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs up

    Thanks IAin, saved me alot of time!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    InStrRev

    Could you give a very simple example how this function works? ie: i would like to extract the file name from the many exclusive paths within a file.

    e:\netvespaweb\5.1.0.10\Customer\drivers\ComCtl32 5.80\50ComUpd.Exe
    e:\netvespaweb\5.1.0.10\Customer\drivers\ComCtl32 5.80\ReadMe.Txt
    e:\netvespaweb\5.1.0.10\Customer\drivers\DCOM v1.3 for Windows 95\dcom95.exe
    e:\netvespaweb\5.1.0.10\Customer\drivers\odbc\mdac_2.1.exe



    Many thanks.

  5. #5
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Righty ho. To start with that InStrRev function above is crap. I have written a much better one since then.

    InStrRev

    To use it to get a filename.

    Code:
    strFileName = Right$(strFullName, Len(strFullName) - InStrRev(strFullName, "\"))
    Iain, thats with an i by the way!

  6. #6
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    intrStrRev

    Sorted IT, thanks for reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width