I am having problems with the following bit of code:
The error message I am getting is:
Error Type:
Microsoft VBScript runtime (0x800A005E)
Invalid use of Null: 'Replace'
/forum/formatmessage.asp, line 20
If I change the Replace line to this:
... it works perfectly (replacing ":cool" with an html image tag).
Doing a Response.Write of strNewSource on the line before Replace shows that there is text in the string.
Please help me as this is very frustrating. Thank you.
[Thanks in advance|Hope I helped you]
Exodus300
Code:
Function FormatMessage(strSource)
strNewSource = strSource
'FormatMessage = strNewSource
'Exit Function
'Response.Write "Raw message is:<blockquote>" & strNewSource & "</blockquote>"
Set rs_format = Server.CreateObject("ADODB.RecordSet")
rs_format.Open "SELECT * FROM Smileys", db
Do While Not rs_format.EOF
strSmileyCode = rs_format("SmileyCode")
strFileName = rs_format("FileName")
strAltText = rs_format("Description")
' Replace the smiley code with the <img> tag
strHtml = "<img src=""images/smileys/" & strFileName & """ alt=""" & strAltText & """>"
'Response.Write strNewSource
strNewSource = Replace(strNewSource, strSmileyCode, strHtml)
'Response.Write "Message after processing " & strSmileyCode & " is: <blockquote>" & strNewSource & "</blockquote>"
rs_format.MoveNext
Loop
rs_format.Close
Set rs_format = Nothing
' Return the formatted message
FormatMessage = strNewSource
End Function
The error message I am getting is:
Error Type:
Microsoft VBScript runtime (0x800A005E)
Invalid use of Null: 'Replace'
/forum/formatmessage.asp, line 20
If I change the Replace line to this:
Code:
strNewSource = Replace("bla bla bla :cool", strSmileyCode, strHtml)
Doing a Response.Write of strNewSource on the line before Replace shows that there is text in the string.
Please help me as this is very frustrating. Thank you.
[Thanks in advance|Hope I helped you]
Exodus300