|
如果每串字符之间的间隔为2空格的话, 可以按下面的方法进行
Function GetStr(L As Integer)
Dim str, str1, I As Integer, J As Integer, rs(99)
str = "4 4- 5 5- 6 6- 7 7- 8 8- 9 9- 10 10- 11 11- 12 12- 13 13- 1 1- 2 2- 3 3-"
str = (Replace(str, " ", ",")) & ","
For I = 1 To Len(str)
If Mid(str, I, 1) = "," Then
J = J + 1
rs(J) = I
End If
Next I
I = 1
If L > 1 And L <= J Then
GetStr = Mid(str, rs(L - 1) + 1, rs(L) - rs(L - 1) - 1)
ElseIf L = 1 Then
GetStr = Left(str, rs(L) - 1)
ElseIf L > J Then
MsgBox "超出数据范围"
End If
End Function
'//取得字符串
Function ds()
MsgBox GetStr(2) '2表示第2个字符
End Function |
|