InStr(3,"abcdefghijkl","cde")
Mid("abcdefghijkl",3,5)
此代码取"cde"字符串,相应的,把字符串替换为你的字符串,即可截取相应的字符串。
望采纳,手机答题
dim s1 as string 前面的字符“abc1”
dim s2 as string 后面的字符 “ef”
dim s3 as string 字符串“abc123def”
dim s4 as string 结果
s4 = Mid(s3, InStr(s3, s1) + Len(s1)) 把前面的去掉s4=“23def”
s4 = Mid(s4, 1, InStr(s4, s2) + 1) 把后面的去掉s4="23d"
变量a,b,c类型是string
要在a中找b和c之间的字符串
你要找的字符串d就是
d=Mid(a, InStr(a, b) + Len(b), InStr(a, c) - InStr(a, b) - Len(b))
方法太多,除了楼上各位的,我也来一个:
function GetStr(s as string,s1 as string,s2 as string) as string
s=split(s,s1,2)(1)
GetStr=split(s,s2,2)(0)
end function
msgbox GetStr("abc123def","abc1","ef")
Private Function findStr(str1 As String, str2 As String, str3 As String)
Dim intStart, intEnd As Integer
If InStr(1, str1, str2) = 0 Or InStr(1, str1, str3) = 0 Then Exit Function
intStart = InStr(1, str1, str2) + Len(str2)
intEnd = InStr(1, str1, str3)
findStr = Mid(str1, intStart, intEnd - intStart)
End Function
Private Sub Form_Load()
MsgBox findStr("abcd123def", "abcd2", "ef")
End Sub