加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp经典 – 早期从经典ASP中的函数返回

发布时间:2020-12-15 23:16:37 所属栏目:asp.Net 来源:网络整理
导读:有没有办法从经典ASP中的函数提前返回,而不是运行函数的全长?例如让我说我有这个功能… Function MyFunc(str) if (str = "ReturnNow!") then Response.Write("What up!") else Response.Write("Made it to the end") end ifEnd Function 我可以这样写吗 Fun
有没有办法从经典ASP中的函数提前返回,而不是运行函数的全长?例如让我说我有这个功能…
Function MyFunc(str)
  if (str = "ReturnNow!") then
    Response.Write("What up!")       
  else
    Response.Write("Made it to the end")     
  end if
End Function

我可以这样写吗

Function MyFunc(str)
  if (str = "ReturnNow!") then
    Response.Write("What up!")       
    return
  end if

  Response.Write("Made it to the end")     
End Function

注意返回语句当然我不能在经典的ASP.有没有办法打破代码执行的那个return语句的位置?

解决方法

是使用退出功能.
Function MyFunc(str)
  if str = "ReturnNow!" then
    Response.Write("What up!")       
    Exit Function
  end if

  Response.Write("Made it to the end")     
End Function

我通常在从函数返回值时使用它.

Function usefulFunc(str)
   ''# Validate Input
   If str = "" Then
      usefulFunc = ""
      Exit Function
   End If 

   ''# Real function 
   ''# ...
End Function

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读