请教:烦请帮助诊断一下MID()函数
作了一个过程,用来遍历文档中的调用函数,代码如下:
Sub runsub(label)
' On Error Resume Next
Dim tmp1, tmp2, i
Dim tmpstr, para
tmp2 = 1
response.write "<br>G_p_show:" & G_P_Show & "此之前为G_P_show<br>"
response.write "InStr(tmp2,G_P_Show, label):" & InStr(tmp2,G_P_Show, label) & "<br>"
While InStr(tmp2,G_P_Show, label) > 0
tmp1 = InStr(tmp2, G_P_Show, label)
tmp2 = InStr(tmp1+1, G_P_Show, "$")
response.write "<br>Mid(G_P_Show,tmp1,tmp2-tmp1),G_P_Show=" & server.HTMLEncode(G_P_Show) & "<br>tmp1=" & cint(tmp1) & "<br>tmp2=" & cint(tmp2)
tmpstr = Mid( G_P_Show,tmp1,tmp2-tmp1)
tmpstr = Replace(tmpstr, "(", "")
tmpstr = Replace(tmpstr, ")", "")
tmpstr = Trim(Replace(tmpstr, label, ""))
para = Split(tmpstr, ",")
select Case label
Case "$NewsListtitle"
G_P_Show=Replace(G_P_Show,label&"("&tmpstr&")$",NewsListtitle(para(0),para(1),para(2),para(3)))
If Err Then
Response.Write "<br/>$NewsListtitle$标签有错误,请检查参数"
Response.Write Err.Description
Response.End()
End If
End select
tmp2 = 1
Wend
End Sub
上面的代码中,把G_p_show设为:G_p_show=“<P>test第一个模板作的专题.</P> <P>$NewsListtitle("行业新闻",3,5,15)$</P>”。运行测试中:
G_p_show:
test第一个模板作的专题.
$NewsListtitle("行业新闻",3,5,15)$
此之前为G_P_show
InStr(tmp2,G_P_Show, label):27
Mid(G_P_Show,tmp1,tmp2-tmp1),G_P_Show=<P>test第一个模板作的专题.</P> <P>$NewsListtitle("行业新闻",3,5,15)$</P>
tmp1=27
tmp2=56
Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: 'mid'
运行到MID函数时,就报错。请高手们帮助我诊断下,tmpstr = Mid( G_P_Show,tmp1,tmp2-tmp1)这句哪有错误。谢谢,在线等!