用VB编程设计一个类似于Windows附件中的计算器,如图所示,可进行简单的算术运算、三角函数和自然对数运算
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/12 18:43:18
用VB编程设计一个类似于Windows附件中的计算器,如图所示,可进行简单的算术运算、三角函数和自然对数运算
求代码,如果每条代码后面有说明就更好了,可以追加100
求代码,如果每条代码后面有说明就更好了,可以追加100
我已帮你全部做好,工程下载地址我已发给你
Dim pi As Double
Dim temp As Double
Dim j As Integer
Dim te As String
Dim yf As String
Dim m As Boolean
Dim f As Boolean
Private Sub Command1_Click(Index As Integer)
If f = True Then Text1 = ""
If Index = 10 Then
Text1.Text = Text1.Text & "."
Else
Text1.Text = Text1.Text & Index
End If
f = False
End Sub
Private Sub Command2_Click(Index As Integer)
Call kl
temp = Text1
Text1 = ""
Text1 = Command2(Index).Caption
f = True
yf = Command2(Index).Caption
End Sub
Private Sub Command3_Click()
If m = True Then
Call kl
Else
Select Case yf
Case "+"
Text1 = temp + Val(Text1)
Case "-"
Text1 = temp - Val(Text1)
Case "*"
Text1 = temp * Val(Text1)
Case "/"
If Val(Text1) = 0 Then
MsgBox "除数不为0"
Else
Text1 = temp / Val(Text1)
End If
End Select
End If
End Sub
Sub kl()
If m = True Then
a = Val(Replace(Text1,te,""))
If te = "sin" Then
If Option1.Value = True Then
Text1 = Sin(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Sin(pi / a)
End If
ElseIf te = "sprt" Then
Text1 = Sqr(a)
ElseIf te = "1/x" Then
Text1 = 1 / a
ElseIf te = "%" Then
Text1 = a * 100
ElseIf te = "cos" Then
If Option1.Value = True Then
Text1 = Cos(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Cos(pi / a)
End If
ElseIf te = "tan" Then
If Option1.Value = True Then
Text1 = Tan(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Tan(pi / a)
End If
ElseIf te = "ln" Then '等号的ln计算
Text1 = Log(Val(Text1.Text))
End If
m = False
End If
End Sub
Private Sub Command4_Click()
Text1.Text = Mid(Text1,1,Len(Text1.Text) - 1)
End Sub
Private Sub Command5_Click()
Text1.Text = ""
temp = 0
m = False
End Sub
Private Sub Command6_Click(Index As Integer)
Text1.Text = Command6(Index).Caption
te = Command6(Index).Caption
m = True
End Sub
Private Sub Command7_Click()
End
End Sub
Private Sub Command8_Click()
Text1 = "π/"
End Sub
Private Sub Form_Load()
pi = 4 * Atn(1)
End Su
Dim pi As Double
Dim temp As Double
Dim j As Integer
Dim te As String
Dim yf As String
Dim m As Boolean
Dim f As Boolean
Private Sub Command1_Click(Index As Integer)
If f = True Then Text1 = ""
If Index = 10 Then
Text1.Text = Text1.Text & "."
Else
Text1.Text = Text1.Text & Index
End If
f = False
End Sub
Private Sub Command2_Click(Index As Integer)
Call kl
temp = Text1
Text1 = ""
Text1 = Command2(Index).Caption
f = True
yf = Command2(Index).Caption
End Sub
Private Sub Command3_Click()
If m = True Then
Call kl
Else
Select Case yf
Case "+"
Text1 = temp + Val(Text1)
Case "-"
Text1 = temp - Val(Text1)
Case "*"
Text1 = temp * Val(Text1)
Case "/"
If Val(Text1) = 0 Then
MsgBox "除数不为0"
Else
Text1 = temp / Val(Text1)
End If
End Select
End If
End Sub
Sub kl()
If m = True Then
a = Val(Replace(Text1,te,""))
If te = "sin" Then
If Option1.Value = True Then
Text1 = Sin(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Sin(pi / a)
End If
ElseIf te = "sprt" Then
Text1 = Sqr(a)
ElseIf te = "1/x" Then
Text1 = 1 / a
ElseIf te = "%" Then
Text1 = a * 100
ElseIf te = "cos" Then
If Option1.Value = True Then
Text1 = Cos(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Cos(pi / a)
End If
ElseIf te = "tan" Then
If Option1.Value = True Then
Text1 = Tan(a * pi / 180)
Else
a = Val(Replace(Text1,"π/",""))
Text1 = Tan(pi / a)
End If
ElseIf te = "ln" Then '等号的ln计算
Text1 = Log(Val(Text1.Text))
End If
m = False
End If
End Sub
Private Sub Command4_Click()
Text1.Text = Mid(Text1,1,Len(Text1.Text) - 1)
End Sub
Private Sub Command5_Click()
Text1.Text = ""
temp = 0
m = False
End Sub
Private Sub Command6_Click(Index As Integer)
Text1.Text = Command6(Index).Caption
te = Command6(Index).Caption
m = True
End Sub
Private Sub Command7_Click()
End
End Sub
Private Sub Command8_Click()
Text1 = "π/"
End Sub
Private Sub Form_Load()
pi = 4 * Atn(1)
End Su
用VB编程设计一个类似于Windows附件中的计算器,如图所示,可进行简单的算术运算、三角函数和自然对数运算
利用VB编程设计一个类似于Windows附件中的计算器程序,要求可进行简单的算术运算、三角函数和自然对数运算
利用c语言设计开发一个简单计算器,可进行加减乘除运算.
C#编写简单计算器简单计算器:完成简单的计算器,可以进行(+,-,*,/,^(乘方),sqrt(平方根))的算术运算.+
用C语言编写一个简单的可以进行加减乘除运算混合运算的计算器
vb简单编程:求自然对数e的近似值,当任意项的值小于10^(-4)是结束运算.用公式e=1+1/1!+1/2!+1/n
用C语言设计一个简单计算器程序,能根据键盘输入的运算指令和数据,做简单的加减乘除运算.
界面如下图,请模拟计算器设计一个完成简单算术运算功能的计算器程序.该程序应该具有下列功能:
设计一个计算器程序 要求:①有计算器界面,计算器可进行四则运算和部分函数运算;②可以输入浮点数;③通
用C语言编写一个简单的可以进行四则运算混合运算的计算器!
求一个电脑上用的计算器,可以进行对数运算,而且对数的底数是自己输入的,就像新版卡西欧计算器上的.
用C语言设计一个简单的计算器,要求能够对输入的数 1.进行+,-,*,/,运算; 2.可以带括号( ); 5