怎样任意提取出字符串中的任何一个字符,如  在123456中,提出从右数第3个数字4 ,应该怎么写?用什么函数?

解决方案 »

  1.   

    你想干什么,提取出很多个字符串的某个位置的字符吗?字符串们的长短一样吗?...........请测试以下函数Private Function mGetString(ByVal mString As String, ByVal Start As Long, Optional ByVal mLeft As Boolean = True) As String    If mLeft Then
            mGetString = Mid(mString, Start, 1)
        Else
            mGetString = Mid(mString, Len(mString) - Start + 1, 1)
        End If
    End FunctionPrivate Sub Command1_Click()
    '取右起第一个
    Debug.Print mGetString("12345", 1, False)
    '取左起第一个
    Debug.Print mGetString("12345", 1, True)
    End Sub