西安科技大学
可视化编程语言实验报告
题目:科学计算器
班级:
学号:
姓名:
2010年11月
复杂型科学计算器的设计与实现实验目的
1.通过本实验,进一步理解Visual Basic的编程方法。
2.提高运用Visual Basic编程的能力。
3.培养对所学知识的综合运用能力。
实验类型
综合型。
实验内容与步骤
一.界面设计。
Command5Caption=
三.程序代码:
Dim num1 As Single, num2 As Single
Dim fu As Integer
Dim sign As Integer
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0 To 9
sign = Index + 20
Case 10
sign = Index + 20
fu = 1
Case 11 To 14
sign = Index + 20
End Select
= ""
End Sub
Private Sub Command2_Click(Index As Integer)
Select Case Index
Case 0 To 9
= & Index
If fu = 0 Then
num1 = Val
Else
num2 = Val
Case 10
= & "-"
Case 11
= & "."
Case 12 To 18
= ""
sign = Index fu = 1
End Select
End Sub
Private Sub Command3_Click() If =”” then
else
= Left$, Len - 1)
End if
End Sub
Private Sub Command4_Click() = ""
End Sub
Private Sub Command5_Click() Dim n As Integer, cf As Single fu = 0: cf = 1
Select Case sign
Case 12
= num1 & "+" & num2
= num1 + num2
Case 13
= num1 - num2
Case 14
= num1 * num2
Case 15
= num1 / num2
Case 18
For n = 1 To num2 cf = cf * num1
Next n
= cf
Case 20
= Sin(num1)
Case 21
Case 22
= Tan(num1)
Case 23
= 1 / Cos(num1)
Case 24
= 1 / Sin(num1)
Case 25
= 1 / Tan(num1)
Case 26
= Sqr(num1)
Case 27
= 1 / num1
Case 28
= Atn(num1)
Case 29
= Atn(num1) + 2 * Atn(1)
Case 30
= Log(num2) / Log(num1)
Case 31
= Log(num1)
Case 32
= (Exp(num1) - Exp(-num1)) / 2 Case 33
= (Exp(num1) + Exp(-num1)) / 2 Case 34
= Abs(num1)
End Select
End Sub
四.保存工程并生成exe可执行文件。