function cutstr(byval str1 as string,byval StartStr as string,byval EndStr as string) as string
dim i as integer,j as integer,L1 as integer,L2 as integer
l1=len(startstr)
l2=len(endstr)
i=instr(str,startStr)
j=instr(str,endStr)
if (l1*l2=0) or (i*j=0) or (j-i<1) then '如果指定起始字符串与结束字符串有一个为空,或者有一个不存在,或者前后位置不正确,返回源字符串
cutstr=str1
exit function
c 字符串截取else
cutstr=mid(str1,i+l1,j-l1-i)
end if
end function
dim str as string ,s1 as string ,s2 as string,s3 as string
str="[name]ASDADASDSA[year]123456789[number]123456"
s1="[name]"
s2="[year]"
s3="[number]"
msgbox cutstr(str,s1,s2)
msgbox cutstr(str,s2,s3)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。