是取得指定标号到下个标号之间的内容吗,若是就是这样 Option ExplicitFunction GetString(str As String, xh As Integer) As String Dim i As Integer, iPos As Integer, iPosNext As Integer
iPos = InStr(1, str, CStr(xh)) If iPos = 0 Then GetString = "" Exit Function End If
iPosNext = InStr(iPos, str, CStr(xh + 1)) If iPosNext = 0 Then iPosNext = Len(str) + 1 End If
GetString = Mid(str, iPos + 1, iPosNext - iPos - 1) End FunctionPrivate Sub Command1_Click() Dim str As String
str = "1zwltop2gogogo3userid" MsgBox GetString(str, 1) End Sub
若是取得指定标号到字符串末尾则是这样 Function GetString(str As String, xh As Integer) As String Dim i As Integer, iPos As Integer iPos = InStr(1, str, CStr(xh)) If iPos = 0 Then GetString = "" Exit Function End If
GetString = Mid(str, iPos + 1) End FunctionPrivate Sub Command1_Click() Dim str As String
str = "1zwltop2gogogo3userid" MsgBox GetString(str, 2) End Sub
Option ExplicitFunction GetString(str As String, xh As Integer) As String Dim i As Integer, iPos As Integer, iPosNext As Integer
iPos = InStr(1, str, CStr(xh))
If iPos = 0 Then
GetString = ""
Exit Function
End If
iPosNext = InStr(iPos, str, CStr(xh + 1))
If iPosNext = 0 Then
iPosNext = Len(str) + 1
End If
GetString = Mid(str, iPos + 1, iPosNext - iPos - 1)
End FunctionPrivate Sub Command1_Click()
Dim str As String
str = "1zwltop2gogogo3userid"
MsgBox GetString(str, 1)
End Sub
Function GetString(str As String, xh As Integer) As String
Dim i As Integer, iPos As Integer iPos = InStr(1, str, CStr(xh))
If iPos = 0 Then
GetString = ""
Exit Function
End If
GetString = Mid(str, iPos + 1)
End FunctionPrivate Sub Command1_Click()
Dim str As String
str = "1zwltop2gogogo3userid"
MsgBox GetString(str, 2)
End Sub