1,求以下表达式的值,写出你想到的一种实现方法:1-2+3-4+……+m.此处m需要手动输入,使用C#语言编写2.实现一记数器功能,如给出0~9所对应的图片分别为0.gif~9.gif,写出程序的主要代码(注:记数存放在counter.txt文件中)简单的ASP计数器counter.asp代码及注释:<%CountFile=Server.MapPath("counter.txt")Set FileObject=Server.CreateObject("Scripting.FileSystemObject")Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE)counter=Out.ReadLine//读取计数器文件中的值Out.Close//关闭文件SET FileObject=Server.CreateObject("Scripting.FileSystemObject")Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE)counter= counter + 1//计数器的值增加1Out.WriteLine(counter)Out.Close//关闭文件%>3.谈谈如何设计一个聊天室程序,并简要阐述实现过程(1)需求分析聊天室是实现用户之间即时通信的一种工具。
所以,聊天室应该具备用户的登录页面、用户的注册、用户的信息的修改、以及实现用户进行聊天的功能。
聊天室作为一种交流工具,应该具备简单易用,容易上手,对于使用者的要求不高,适合大众的需求。
同时聊天室还要有一些个性化的界面提供给用户不仅仅是聊天的乐趣,同时也带来全新的视觉效果。
(2)主要模块用户注册页面用户登录页面个人信息页面留言板页面(3)重要的代码程序:(1)登陆页面(login_in.aspx)的调用事件代码:Sub page_load(ByVal sender As Object, ByVal e As EventArgs)Session("user_name") = user_name.TextEnd SubSub Enter_Click(ByVal Sender As Object, ByVal E As EventArgs)'建立Connection对象Dim conn As NewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("chat.mdb"))'建立Command对象Dim cmd As New OleDbCommand("select * from user_infor", conn)conn.Open()Dim dr As OleDbDataReader = cmd.ExecuteReader()Do While dr.Read()If dr.Item("user_name") <> user_name.Text And dr.Item("password1") <> password1.Text ThenResponse.Write("用户名不正确!")ElseResponse.Write("欢迎登陆!")Response.Redirect("succ_register.aspx")conn.Close()End IfLoopEnd Sub(2)、注册页面(register.aspx)的调用事件代码:Sub Enter_Click(ByVal Sender As Object, ByVal E As EventArgs)'建立Connection对象Dim conn As NewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("chat.mdb"))'建立Command对象Dim strSql As StringstrSql = "Insert Intouser_infor(user_name,password1,sex,birthday1,email,intro) Values('" &user_name.Text & "','" & password1.Text & "','" & sex.SelectedItem.Text & "','" & birthday1.Text & "','" & email.Text & "','" & intro.Text & "')"Dim cmd As New OleDbCommand(strSql, conn)Dim Exp As ExceptionTry'执行操作,插入记录conn.open()cmd.ExecuteNonQuery()conn.close()Response.Redirect("succ_register.aspx") '正常添加后,返回首页Catch Expmessage.Text = "注册失败!"End TryEnd Sub(3)、聊天室的代码如下:统计访客人数:4-16.aspx的代码:Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)If Session("user_name") = "" ThenResponse.Redirect("login_in.aspx")End Ifmessage.Text = "欢迎" & Session("user_name") & "登陆聊天室!"Application.Lock()Application("user_number") = Application("user_number") + 1Application.UnLock()message1.text = "您是第" & Application("user_number") & "位访客"End Sub显示发言信息代码如下:Sub Enter_Click(ByVal Sender As Object, ByVal E As EventArgs)Dim username As Stringusername = Session("user_name")Application.Lock()Application("show") = username.ToString & "说:<br>" &Application("show")Application("show") = DateTime.Now.ToString & "<br>" &Application("show")Application("show") = Request.ServerVariables("remote_addr") & ":" & Application("show")Application("show") = pronunciation.Text & "<br>" & Application("show")Application.UnLock()pronunciation.Text = "" '将发言框清空End Sub(4)、修改信息调用事件重要代码如下:Sub BindData()Dim username As Stringusername = Session("user_name")Dim conn As NewOleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("chat.mdb")) '建立Connection对象Dim cmd As New OleDbCommand("select * from user_infor whereuser_name='" & username & "'", conn) '建立Command对象Dim adp As New OleDbDataAdapter(cmd) '建立DataAdapter对象Dim ds As New DataSet() '建立DataSet对象adp.Fill(ds, "user_infor") '填充DataSetMyDataGrid.DataSource = ds.Tables("user_infor").DefaultView '指定数据源MyDataGrid.DataBind()4.谈谈如何设计一个大学生课程管理系统,设计数据库,并简要哦阐述主要模块实现过程(1)设计思路:系统简介:本系统是一款以学校学生课程管理为主题,帮助学生随时管理自己大学所选的课程。