如何取得这个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的话要怎么改呢
...全文
134 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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
%>

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧