IndexOf will give you the index of the first occurence of a character or substring, while LastIndexOf will give you the index of the last occurrence. You can use the results of those methods to calculate the parameters to pass to Substring, which is exactly how InStrRev is being used in the code you originally posted.