Option 1:
str = "ABCDEFG"
var = InStrRev(str, Right(str,1))
MsgBox var 'Return 7 - position of G
Option 2:
str = "ABCDEFG"
i = 0
Do Until str = ""
i = i+1
b = Left(str, 1)
str = Replace(str, b, "")
Loop
MsgBox i 'Return 7
...
str = "ABCDEFG"
var = InStrRev(str, Right(str,1))
MsgBox var 'Return 7 - position of G
Option 2:
str = "ABCDEFG"
i = 0
Do Until str = ""
i = i+1
b = Left(str, 1)
str = Replace(str, b, "")
Loop
MsgBox i 'Return 7
...
In 2nd solution, you will have problems if you have repeating characters rite?
ReplyDelete