Reputation: 6605
i am looking at some ancient code and there is the following line of code:
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
when i try to debug strResult. it does not append the contents of the pIrntTableHead function. why isn't this working? how can i rewrite this to append correctly?
so after strResult = strResult + "<tr>" & vbLf
the value of strResult is still just :
"table><tr>"
Upvotes: 0
Views: 612
Reputation: 72860
The function never returns its value. You'd need the following line just before the End Function
.
PrintTableHead = strResult
Note that you should make sure strResult is declare locally within the function as well, to avoid overwriting the variable you are using in the calling code. The whole function would look like this:
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
Upvotes: 5