如何将消息框中的内容,读如数据库时保留其原有的格式?

renger 2002-07-27 10:05:29
即再次从库中调出时能以其输入时的排版格式进行显示?
...全文
27 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huguangwu 2002-07-29
  • 打赏
  • 举报
回复
写一个函数嘛

function strreplace(str)
str=replace(str,",",",")
str=replace(str,"%","%")
str=reaplce(str,"<br>",vbnewline)
...
'加上你自己要的语句
strreaplce=str
end function

....

msgbox(reaplace(yourstring),vbokonly,"hello")
freezwy 2002-07-29
  • 打赏
  • 举报
回复
使用下面的这个函数就可以了,同时可以屏蔽HTML代码攻击。
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
JavaCoffee 2002-07-29
  • 打赏
  • 举报
回复
使用Vbscript中,你可以试试下面的代码:
testStr=replace(testStr,"<br>",vbCrLf)
msgbox testStr

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧