InstrRev Function

Results 1 to 2 of 2

Thread: InstrRev Function

  1. #1
    Join Date
    Dec 1969

    Default InstrRev Function

    Hi,<BR><BR>I don&#039;t really understand the InstrRev function. As I see it, it&#039;s supposed to compare a character within a string starting from the end of the string; so in other words it moves backwards down the string until it finds a match. Is this correct?<BR><BR>I&#039;ve done some tests but I always get a value from the beginning of the string.<BR><BR>Dim x, y<BR><BR>x = "this is / a test"<BR>y = InstrRev(x, "/", -1, 1)<BR><BR>with the above example it return 9. How do I get it to start at the end so it returns 8?<BR><BR>thanks for any help

  2. #2
    Join Date
    Dec 1969

    Default RE: InstrRev Function

    Nooooooo....<BR><BR>Slight misunderstanding. It&#039;ll still return the character position from the START of the string, but if there are multiple matches then it returns the one nearest to the end...<BR><BR>strHi = "Hello to the world"<BR>InStr(strHi, " ") would pick up the space between "hello" and "to" (character 5 or whatever).<BR>InStrRev(strHi, " ") would pick up the space between "the" and "world" (character 12 or so).<BR><BR>If you want the characters from the end, then you&#039;ll need to do some maths with the string length.<BR><BR>Craig.

Posting Permissions

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