Private Sub Command1_click()
s = "vb 中如何从字符串的右端第n个位置开始截取指定长度的字符串?"
Print MidR(s, 10, 5) '从右边第10个开始向后取5个
Print StrReverse(Mid(StrReverse(s), 10, 5)) '从右边第10个开始向前取5个
End Sub
Function MidR(bString, ByVal bStart As Long, ByVal bLength)
If bLength < 1 Then bLength = Len(bString)
bStart = Len(bString) - bStart + 1
If bStart < 1 Then bStart = 1
MidR = Mid(bString, bStart, bLength)
End Function