[中学教育]用VB设计一个简单的计算器
VB大作业
报告
软件系统测试报告下载sgs报告如何下载关于路面塌陷情况报告535n,sgs报告怎么下载竣工报告下载
程序功能介绍:
计算器可以进行简单的。加、减、 乘、除、乘方、开方、阶乘、取余和清零。
主要源程序:
设置程序从form2启动。
首先出来一个展示界面,内容包括自己的姓名、班级和所做的课
题
快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题
。等待时间是3秒。
Private Sub Form_Load()
Label4.Caption = "3"
End Sub
Private Sub Timer1_Timer() “倒计时,当倒计时为0时,一界面隐藏弹出二界面” Label4.Caption = Label4.Caption - 1 If (Label4.Caption = "0") Then Form1.Hide
Form2.Show
End If
End Sub
解释:定时器以一定的时间间隔产生Timer事件从而执行相应的时间
过程。当form2消失后,form3开始运行。 用户名与密码正确时form3消失form出现。进入计算器的主要界面。
Private Sub Command1_Click()
If Text1.Text <> "******" Then
MsgBox "用户名错误, 请重新输入"
Text1.SetFocus
End If
If Text2.Text <> "123" Then
MsgBox "密码不正确,请重新输入"
Text2.SetFocus
ElseIf Text1 = "******" And Text2 = "123" Then
Form2.Hide
Form3.Show
End If
End Sub
Private Sub Text1_Change() End Sub
解释:利用Msgbox判断输入数据的正确性,否则不允许登录。
然后进入计算器界面:
Private Sub Command1_Click()
Text3.Text = Str(Val(Text1.Text) + Val(Text2.Text)) “加法运算”
End Sub
Private Sub Command2_Click()
Text3.Text = Str(Val(Text1.Text) - Val(Text2.Text))“减法运算”
End Sub
Private Sub Command3_Click()
Text3.Text = Str(Val(Text1.Text) * Val(Text2.Text))“乘法运算”
End Sub
Private Sub Command4_Click()
Text3.Text = Str(Val(Text1.Text) / Val(Text2.Text))“除法运算”
End Sub
Private Sub Command6_Click()
Text3.Text = Str(Val(Sqr(Text1.Text)))“开方运算”
End Sub
Private Sub Command5_Click()
Text1.Text2 = Str(Val(Text1.Text) * Val(Text1.Text)) “乘方运算”End Sub
Private Sub Command7_Click() Text1 = ""
Text2 = "" “清零” Text3 = ""
End Sub
Private Sub Command8_Click() Dim a#, s#
s = 1
a = Val(Text1)
For i = 1 To a “阶乘运算” s = s * i
Text3 = s
Next i
End Sub
Private Sub Command9_Click() Text3 = Str(Val(Text1) Mod (Text2)) “除法取余”
End Sub
Private Sub Text1_Change()
End Sub