如何取得这个sub的值

saint271828 2009-08-11 11:40:58

sub position_pro(cateid)
dim str
set position=server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,3

if not position.eof then
if position("ParentID")<>0 then
str=str&" >> <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&"</a>"
else
str=str&"<a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&"</a>"
end if
position_pro position("ParentID")

end if
response.Write str
end sub


如何用变量取得它的值,或者改成function的话要怎么改呢
...全文
107 点赞 收藏 10
写回复
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
saint271828 2009-08-11
我的SUB里边有个position_pro position("ParentID") ,不知道你们注意到没有,所以上边的function和我的SUB得出的结果都不同
回复
hookee 2009-08-11

<%
Function position_pro(cateid)
str = ""
set position = server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,1
if not (position.eof and position.bof) then
if position("ParentID") <>0 then
str=str&" >>  <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
else
str=str&" <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
end if
end if
position_pro = str
position.close
set position= nothing
end Function
%>


回复
saint271828 2009-08-11
我要取“str”
回复
saint271828 2009-08-11
position_pro = 返回值
这个是什么?
回复
hookee 2009-08-11
取 position("ParentID")?

<%
Function position_pro(cateid)
set position = server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,1
if not (position.eof and position.bof) then
position_pro = position("ParentID").value
else
position_pro = null
end if
position.close
set position= nothing
end Function
%>
回复
hztgcl1986 2009-08-11

function position_pro(cateid)
dim str
set position=server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,3

if not position.eof then
if position("ParentID") <>0 then
str=str&" >>  <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
else
str=str&" <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
end if
position_pro position("ParentID")

end if
response.Write str

position_pro = 返回值
end function

回复
Function position_pro(cateid) 
dim str
set position=server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,3

if not position.eof then
if position("ParentID") <>0 then
str=str&" >>  <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
else
str=str&" <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
end if
position_pro position("ParentID")

end if
position_pro=str
end Function
回复
saint271828 2009-08-11
不过我这样读出来的结果是反的
回复
saint271828 2009-08-11
楼上的有点小错误好像,我改下就没问题
Function position_pro(cateid)
position_pro = ""
set position = server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,1
if not (position.eof and position.bof) then
if position("ParentID") <>0 then
position_pro=position_pro&" >>  <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
else
position_pro=position_pro&" <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
end if
position_pro = position_pro & position_pro(position("ParentID").Value)
else
position_pro = ""
end if
position.close
set position= nothing
end Function
回复
hookee 2009-08-11

<%
Function position_pro(cateid)
str = ""
set position = server.CreateObject("adodb.recordset")
position.open "select * from category where categoryid="&cateid,conn,1,1
if not (position.eof and position.bof) then
if position("ParentID") <>0 then
str=str&" >>  <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
else
str=str&" <a href='cat.asp?catid="&position("categoryid")&"'>"&position("category")&" </a>"
end if
position_pro = str & position_pro(position("ParentID").Value)
else
position_pro = ""
end if
position.close
set position= nothing
end Function
%>

回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告