Extracting numbers from end of string (1 Viewer)

Malcy

Registered User.
Local time
Today, 01:31
Joined
Mar 25, 2003
Messages
586
I have a string which is a combination of numbers and letters. I want to extract the end digit (always a number), or, if it is greater than 9, then the two digits. The format of the string is along the lines 18G003-2-4 (they are agar plate codes for refining fungal cultures). So I am trying to catch the final "4" which works fine using
strCode2 = Right(strPlateCode, 1)
However, if the string were 18G003-2-11 then I want to catch the "11" not just the final "1".
The initial code may well only have one "-" in it rather than the two in the example I have given.
Any insights into understanding this would be most appeciated.
Thanks

Malcy
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 10:31
Joined
Jan 20, 2009
Messages
12,854
Code:
Mid([string], InstrRev([string],"-") + 1)
 

Malcy

Registered User.
Local time
Today, 01:31
Joined
Mar 25, 2003
Messages
586
Brilliant. Thank you very much. Worked a treat.
 

Users who are viewing this thread

Top Bottom