function htmlencode(str)
on error resume next
dim result
dim l
if isnull(str) then
htmlencode=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ""
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(13)