Asp classic 从函数传回变量?
我在看一些古老的代码,下面是一行代码:Asp classic 从函数传回变量?,asp-classic,Asp Classic,我在看一些古老的代码,下面是一行代码: strResult = strResult + "<table>" & vbLf output = PrintTableHead("Field Office Code","1") strResult = strResult + PrintTableHead("Field Office Code","1") strResult = strResult + "<tr>" &
strResult = strResult + "<table>" & vbLf
output = PrintTableHead("Field Office Code","1")
strResult = strResult + PrintTableHead("Field Office Code","1")
strResult = strResult + "<tr>" & vbLf
Function PrintTableHead( TheTitle , TheColSpan )
strResult = "<tr><th colspan="
strResult = strResult + TheColSpan
strResult = strResult + " BGCOLOR=""#004D95"" align=center>" & vbLf
strResult = strResult + "<font face=""Time New Roman"" color=""#ffffff"" SIZE=3>" & vbLf
strResult = strResult + TheTitle
strResult = strResult + "</font></th></tr>" & vbLf
End Function
stresult=stresult+“”&vbLf
输出=打印表头(“现场办公室代码”,“1”)
STRESULT=STRESULT+打印表头(“现场办公室代码”,“1”)
strResult=strResult+“”&vbLf
功能打印表头(标题、颜色范围)
strResult=”“&vbLf
strResult=strResult+“”&vbLf
strResult=strResult+标题
strResult=strResult+“”&vbLf
端函数
当我尝试调试strResult时。它不附加PirnTableHead函数的内容。为什么这不起作用?如何将其重写为正确的追加
因此,在strResult=strResult+“”&vbLf
之后,strResult的值仍然只是:
“表>”
函数从不返回其值。您需要在
结束函数
之前添加以下行
PrintTableHead = strResult
请注意,您应该确保strResult也在函数中本地声明,以避免覆盖调用代码中使用的变量。整个函数如下所示:
Function PrintTableHead( TheTitle , TheColSpan )
Dim strResult
strResult = "<tr><th colspan="
strResult = strResult + TheColSpan
strResult = strResult + " BGCOLOR=""#004D95"" align=center>" & vbLf
strResult = strResult + "<font face=""Time New Roman"" color=""#ffffff"" SIZE=3>" & vbLf
strResult = strResult + TheTitle
strResult = strResult + "</font></th></tr>" & vbLf
PrintTableHead = strResult
End Function
函数打印表头(标题、颜色范围)
暗淡的结果
strResult=”“&vbLf
strResult=strResult+“”&vbLf
strResult=strResult+标题
strResult=strResult+“”&vbLf
PrintTableHead=strResult
端函数
函数从不返回其值。您需要在结束函数
之前添加以下行
PrintTableHead = strResult
请注意,您应该确保strResult也在函数中本地声明,以避免覆盖调用代码中使用的变量。整个函数如下所示:
Function PrintTableHead( TheTitle , TheColSpan )
Dim strResult
strResult = "<tr><th colspan="
strResult = strResult + TheColSpan
strResult = strResult + " BGCOLOR=""#004D95"" align=center>" & vbLf
strResult = strResult + "<font face=""Time New Roman"" color=""#ffffff"" SIZE=3>" & vbLf
strResult = strResult + TheTitle
strResult = strResult + "</font></th></tr>" & vbLf
PrintTableHead = strResult
End Function
函数打印表头(标题、颜色范围)
暗淡的结果
strResult=”“&vbLf
strResult=strResult+“”&vbLf
strResult=strResult+标题
strResult=strResult+“”&vbLf
PrintTableHead=strResult
端函数
谢谢!我以前尝试过“returnstrresult”,但出现了错误。让我试试看!p、 成功了:)谢谢!谢谢我以前尝试过“returnstrresult”,但出现了错误。让我试试看!p、 成功了:)谢谢!