制作网页计算器网站脚本技术ASP NET课程设计.docx
- 文档编号:5994139
- 上传时间:2023-01-02
- 格式:DOCX
- 页数:20
- 大小:214.68KB
制作网页计算器网站脚本技术ASP NET课程设计.docx
《制作网页计算器网站脚本技术ASP NET课程设计.docx》由会员分享,可在线阅读,更多相关《制作网页计算器网站脚本技术ASP NET课程设计.docx(20页珍藏版)》请在冰豆网上搜索。
制作网页计算器网站脚本技术ASPNET课程设计
计算机网络技术专业专业代码:
590102
网站脚本技术课程设计
班级:
网络0856班
学号:
姓名:
hp52@
(排名不分先后)
课题:
制作网页计算器
指导教师:
答辩日期:
一、任务描述
制作网页计算器
二、任务分析
基本功能
v加法
v减法
v乘法
v除法
v求余
vX分之一
vBackspace退格
vClean清零
v次方
v平方
vX的y次方
v输入1~9
v输入小数点
v输入π
veq等于
界面要求
v美观大方即可
兼容性
v使用VB.NET脚本编写
v采用B/S构架,在Server端运行
v标准XHTML几乎兼容所有浏览器
三、任务解决过程及方法
最终效果图
(1):
InternetExplorer8
最终效果图
(2):
InternetExplorer6.0
未添加进制转换前的截图:
InternetExplorer8
脚本代码(有注释):
1)<%@pagelanguage="vb"%>
2)
3)Subpage_load()'页面加载
4)IfNot(Page.IsPostBack)Then'首次加载页面,给输出屏幕赋值
5)shuchu.Text="0"
6)jz16.Text="0"
7)jz8.Text="0"
8)jz2.Text="0"
9)jc.Text=""
10)zt.Text=""
11)EndIf
12)jc2.Text=""
13)EndSub
14)
15)PublicFunctionjinzhi()'进制转换函数
16)jc2.Text=Val(shuchu.Text)'16进制转换
17)jz16.Text=""
18)DoWhileVal(jc2.Text)>0
19)SelectCaseCStr(Val(jc2.Text)Mod16)
20)Case"10"
21)jz16.Text="A"&jz16.Text
22)Case"11"
23)jz16.Text="B"&jz16.Text
24)Case"12"
25)jz16.Text="C"&jz16.Text
26)Case"13"
27)jz16.Text="D"&jz16.Text
28)Case"14"
29)jz16.Text="E"&jz16.Text
30)Case"15"
31)jz16.Text="F"&jz16.Text
32)CaseElse
33)jz16.Text=Val(jc2.TextMod16)&jz16.Text
34)EndSelect
35)jc2.Text=Str(Val(jc2.Text)\16)
36)Loop
37)
38)jc2.Text=Val(shuchu.Text)'8进制转换
39)jz8.Text=""
40)DoWhileVal(jc2.Text)>0
41)jz8.Text=(Val(jc2.Text)Mod8)&jz8.Text
42)jc2.Text=Str(Val(jc2.Text)\8)
43)Loop
44)
45)jc2.Text=Val(shuchu.Text)'2进制转换
46)jz2.Text=""
47)DoWhileVal(jc2.Text)>0
48)jz2.Text=(Val(jc2.Text)Mod2)&jz2.Text
49)jc2.Text=Str(Val(jc2.Text)\2)
50)Loop
51)jc2.Text=""
52)
53)Ifshuchu.Text=0Then'如果当前值为“0”
54)jz16.Text=0
55)jz8.Text=0
56)jz2.Text=0
57)EndIf
58)EndFunction
59)
60)ProtectedSubzero_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“0”按钮时
61)Ifshuchu.Text<>"0"Then'如果当前输出为非“0”,则在字符串右边加上“0”
62)shuchu.Text=shuchu.Text&0
63)ElseIfshuchu.Text="0"Then'如果当前输出为“0”,则不在字符串右边加“0”
64)shuchu.Text=0
65)EndIf
66)jinzhi()'调用进制转换函数
67)EndSub
68)
69)ProtectedSubone_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单机“1”按钮时
70)Ifshuchu.Text<>"0"Then'如果当前输出为非“0”,则在字符串右边加上“1”
71)shuchu.Text=shuchu.Text&1
72)EndIf
73)Ifshuchu.Text="0"Then'如果当前输出为“0”,则直接赋值输出“1”
74)shuchu.Text=1
75)EndIf
76)jinzhi()'调用进制转换函数
77)EndSub
78)
79)ProtectedSubtwo_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
80)Ifshuchu.Text<>"0"Then
81)shuchu.Text=shuchu.Text&2
82)EndIf
83)Ifshuchu.Text="0"Then
84)shuchu.Text=2
85)EndIf
86)jinzhi()
87)EndSub
88)
89)ProtectedSubthree_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
90)Ifshuchu.Text<>"0"Then
91)shuchu.Text=shuchu.Text&3
92)EndIf
93)Ifshuchu.Text="0"Then
94)shuchu.Text=3
95)EndIf
96)jinzhi()
97)EndSub
98)
99)ProtectedSubfour_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
100)Ifshuchu.Text<>"0"Then
101)shuchu.Text=shuchu.Text&4
102)EndIf
103)Ifshuchu.Text="0"Then
104)shuchu.Text=4
105)EndIf
106)jinzhi()
107)EndSub
108)
109)ProtectedSubfive_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
110)Ifshuchu.Text<>"0"Then
111)shuchu.Text=shuchu.Text&5
112)EndIf
113)Ifshuchu.Text="0"Then
114)shuchu.Text=5
115)EndIf
116)jinzhi()
117)EndSub
118)
119)ProtectedSubsix_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
120)Ifshuchu.Text<>"0"Then
121)shuchu.Text=shuchu.Text&6
122)EndIf
123)Ifshuchu.Text="0"Then
124)shuchu.Text=6
125)EndIf
126)jinzhi()
127)EndSub
128)
129)ProtectedSubseven_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
130)Ifshuchu.Text<>"0"Then
131)shuchu.Text=shuchu.Text&7
132)EndIf
133)Ifshuchu.Text="0"Then
134)shuchu.Text=7
135)EndIf
136)jinzhi()
137)EndSub
138)
139)ProtectedSubeight_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
140)Ifshuchu.Text<>"0"Then
141)shuchu.Text=shuchu.Text&8
142)EndIf
143)Ifshuchu.Text="0"Then
144)shuchu.Text=8
145)EndIf
146)jinzhi()
147)EndSub
148)
149)ProtectedSubnine_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上……
150)Ifshuchu.Text<>"0"Then
151)shuchu.Text=shuchu.Text&9
152)EndIf
153)Ifshuchu.Text="0"Then
154)shuchu.Text=9
155)EndIf
156)jinzhi()
157)EndSub
158)
159)ProtectedSubdot_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“.”按钮时
160)IfVal(shuchu.Text)Mod1<>0Then'如果当前屏幕输出数值为小数,则不修改任何属性
161)EndIf
162)IfVal(shuchu.Text)Mod1=0Then'如果当前屏幕输出数值为整数,则在字符串的右边加上“.”
163)shuchu.Text=shuchu.Text&"."
164)EndIf
165)jinzhi()
166)EndSub
167)
168)ProtectedSubclean_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“C”按钮时
169)shuchu.Text=0'主屏幕输出数值归零
170)jc.Text=""'清除寄存数值
171)zt.Text=""'清除当前计算状态
172)jz16.Text=0
173)jz8.Text=0
174)jz2.Text=0
175)EndSub
176)
177)ProtectedSubeq_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“=”按钮时
178)SelectCase(zt.Text)
179)Case"+"'当前计算状态为"加法",把当前主屏幕数值和寄存器内数值“相加”,并由主屏幕输出
180)shuchu.Text=Str(Val(jc.Text)+Val(shuchu.Text))
181)Case"-"'当前计算状态为“减法”,把当前主屏幕数值和寄存器内数值“相减”,并由主屏幕输出
182)shuchu.Text=Str(Val(jc.Text)-Val(shuchu.Text))
183)Case"×"'当前计算状态为“乘法”,把当前主屏幕数值和寄存器内数值“相乘”,并由主屏幕输出
184)shuchu.Text=Str(Val(jc.Text)*Val(shuchu.Text))
185)Case"÷"'当前计算状态为“除法”,把当前主屏幕数值和寄存器内数值“相除”,并由主屏幕输出
186)shuchu.Text=Str(Val(jc.Text)/Val(shuchu.Text))
187)Case"%"'当前计算状态为“求余”,把当前主屏幕数值和寄存器内数值“求余”,并由主屏幕输出
188)shuchu.Text=Str(Val(jc.Text)ModVal(shuchu.Text))
189)Case"x^y"'当前计算状态为“X分之一”,把当前主屏幕数值和寄存器内数值“X分之一”,并由主屏幕输出
190)shuchu.Text=Str(Val(jc.Text)^Val(shuchu.Text))
191)EndSelect
192)shuchu.Text=Val(shuchu.Text)
193)jinzhi()
194)EndSub
195)
196)ProtectedSubsubtract_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'当单击“-”按钮时
197)jc.Text=Val(shuchu.Text)'把当前主数值存入寄存器
198)zt.Text="-"'更改状态为“-”
199)shuchu.Text=0'主屏幕清零
200)jinzhi()
201)EndSub
202)
203)ProtectedSubplus_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
204)jc.Text=Val(shuchu.Text)
205)zt.Text="+"
206)shuchu.Text=0
207)jinzhi()
208)EndSub
209)
210)ProtectedSubmultiply_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
211)jc.Text=Val(shuchu.Text)
212)zt.Text="×"
213)shuchu.Text=0
214)jinzhi()
215)EndSub
216)
217)ProtectedSubdivide_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
218)jc.Text=Val(shuchu.Text)
219)zt.Text="÷"
220)shuchu.Text=0
221)jinzhi()
222)EndSub
223)
224)ProtectedSubqiuyu_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
225)jc.Text=Val(shuchu.Text)
226)zt.Text="%"
227)shuchu.Text=0
228)jinzhi()
229)EndSub
230)
231)ProtectedSubxy_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
232)jc.Text=Val(shuchu.Text)
233)zt.Text="x^y"
234)shuchu.Text=0
235)jinzhi()
236)EndSub
237)
238)ProtectedSubpai_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“π”按钮时
239)shuchu.Text=3.1415926'给主屏幕数值赋值并输出
240)jinzhi()
241)EndSub
242)
243)ProtectedSubx2_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“x^2”按钮时
244)jc.Text=Val(shuchu.Text)'主数值放入寄存器
245)zt.Text="x^2"'更改计算状态为“x^2”
246)shuchu.Text=Str(Val(jc.Text)^2)'计算“x^2”
247)jinzhi()
248)EndSub
249)
250)ProtectedSubx3_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'同上
251)jc.Text=Val(shuchu.Text)
252)zt.Text="x^3"
253)shuchu.Text=Str(Val(jc.Text)^3)
254)jinzhi()
255)EndSub
256)
257)ProtectedSubx1_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“1/x”按钮时
258)jc.Text=Val(shuchu.Text)'主数值放入寄存器
259)zt.Text="1/x"'更改计算状态为“1/x”
260)shuchu.Text=Str(1/Val(jc.Text))'计算“1/x”
261)shuchu.Text=Val(shuchu.Text)
262)jinzhi()
263)EndSub
264)
265)ProtectedSubbackspace_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)'单击“←”按钮时
266)IfVal(shuchu.Text)/1.1<>0Then'若当前主屏幕输出数值不为个位数,则减去最右边的一位
267)shuchu.Text=Left(shuchu.Text,Len(shuchu.Text)-1)
268)EndIf
269)IfVal(shuchu.Text)/1.1=0Then'若当前主屏幕输出数值为个位数,则清零主屏幕输出数值
270)shuchu.Text=0
271)EndIf
272)jinzhi()
273)EndSub
274)
275)
网页代码(无注释):
1) //www.w3.org/1999/xhtml"> 2)
3)
4)
5)table#js{
6)margin:
0px;
7)padding:
0px;
8)background-color:
#aaaaaa;
9)}
10)td{
11)padding:
3px;
12)}
13).button{
14)width:
70px;
15)height:
50px;
16)font-size:
32px;
17)color:
#eeeeee;
18)background-color:
#111111;
19)}
20)
21)
22) center;background-color: #333333;margin-top: 50px;font-family: Arial;"> 23) 24) 25) 26) 27) 110px;Width: 100%;background-color: #222222;"> 28) 29) LabelID="jc"runat="server"style="overflow: hidden;"Height="19px"Font-Size="18px"ForeColor="#00ff00"/> 30) 如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。 copyright@ 2008-2022 冰点文档网站版权所有 经营许可证编号:鄂ICP备2022015515号-1