Normally, the Right() Function VB returns only the Length specified from the End. If you want to extract the Right portion from any index of the String you have to play with the Mid() Function. It’s very tedious to write a Mid() function for each of the above functionalities. The solution is to use the following function to extract the right portion of the string from any specified position.
Private Function MidR(strSource As String, StartIndex As Integer, LengthAs Integer)Dim StartPositon As Integer If StartIndex > Len(strSource) Then StartIndex = Len(strSource) StartPositon = StartIndex - Length + 1 If StartPositon > 0 Then MidR = Mid(strSource, StartPositon, Length) Else MidR = Mid(strSource, 1, StartIndex) End IfEnd FunctionUsage: StrValue=MidR("123456",5,2)Returns : 45