<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> SUB Application_OnStart dim maChats(15) 定义一个具有15个元素的数据. Application("gaChats")=maChats 存储谈话的内容. Application("giCounter")=0 存储已有的谈话数目. END SUB </SCRIPT>
<p align="center"><font size=5>一个简单的聊天室</font></p> <br> <% 处理输入 if Request.ServerVariables("Request_Method")="POST" then 标明讲话者 if len(Request("txtWho"))>0 then Session("ssWho")=Request("txtWho") end if 封锁Application对象 Application.Lock 创建本地引用指针 mlCounter=Application("giCounter") maChats=Application("gaChats") 如果写入的行数超过10,则重新开始记数. if mlCoundter>9 then mlCoundter=0 end if 增加用户的输入,计数器加1 maChat(mlChounter)=Session("ssWho")&":"&Request("txtCents") mlCounter=mlCounter+1 把局部变量设置为在应用范围内有效. Applicati "giCounter")=mlCounter Application("gaChats")=maChat 消除Application对象的封锁 Application.Unlock end if %> <% 写入TextArea if Application("giCounter")=0 then lstemp=Application("gaChats")(0) else for x=0 to Application("giCounter")-1 lstemp=lstemp&"<br>"Application("gaChats")(x) next end if Response.white lstemp %> <hr>