谢谢,我用了自定义函数
Public Function MidX1(strInput As String, _
starnumber As Long, _
endnumber As Long) _
As String
'------------------------------------------------------------------------------------------
'为了取特定的空格之间的字符
'用法是midX(所选字段,第X次出现的空格,第y次出现的空格)
'例如 midx1("AA BBBB CC DDD",2,3) =CC
'例如 midx1("AA BBBB CC DDD",1,3) =BBBB CC
'------------------------------------------------------------------------------------------
strlong = Len(strInput)
i = InStr(1, strInput, " ", vbBinaryCompare)
If IsNull(i) Then
GoTo 2
Else
N = 0
End If
Do While i <> 0 ' InStrRev(strInput, " ", -1, 1)
N = N + 1
If N = starnumber Then starn1 = i
If N = endnumber Then
starn2 = i
GoTo 1
Else
End If
i = InStr(i + 1, strInput, " ", vbBinaryCompare)
Loop
If i = 0 And N < endnumber Then
MidX1 = Mid$(strInput, starn1 + 1, strlong - starn1)
Else
1
MidX1 = Mid$(strInput, starn1 + 1, starn2 - starn1)
2 End If
End Function
[此贴子已经被作者于2006-11-17 12:56:05编辑过]
|