带记录功能的计算器

 

侠侠计算器是最近本人无聊,写的一个简单的计算器。

我发现市面常规的计算器只有一个输入框,计算起来比较麻烦,并且不能保存输出结果,非常讨厌,因为不方便,很多时候就用excel来代替了,特此用VB写了个计算器来解决这个问题。

定制游戏脚本或者其他类的小程序可以联系本人工作QQ 1445793928.

下载地址:http://pan.baidu.com/share/link?shareid=271019&uk=2970051602

使用说明:

一:整体图片及操作说明:

1,数据1和数据2里面输入要运算的数字,点左下方区域的运算,自动把结果显示在“输出结果”的空白处。

2,提供了6个保存结果的地方可以临时存储计算的结果;

3,下面的“复制结果选择”是配合左上角的“复制结果”使用的,先点选好要复制那个位置的数字,点“复制结果”就可以复制给数据1和数据2.

4,字号大小位置填数字即可,可以改变数据1,数据2,输出结果里面的文字大小。

5,注意如果是空白处如果输字母和文字程序会报错退出,没有设置字符串防呆;

6,任意一个空白处均可以进行手动输入和更改数字,复制粘贴等操作。

带记录功能的计算器

二:附上源码供大家学习和讨论,请各位高手指点也希望各位高手使劲喷,大家一起提高。

Private Sub Command1_Click()
If Option9.Value = True Then
Text1.Text = Text3.Text
    ElseIf Option3.Value = True Then
    Text1.Text = Text4.Text
    ElseIf Option4.Value = True Then
    Text1.Text = Text5.Text
    ElseIf Option5.Value = True Then
    Text1.Text = Text6.Text
    ElseIf Option6.Value = True Then
    Text1.Text = Text7.Text
    ElseIf Option7.Value = True Then
    Text1.Text = Text8.Text
    ElseIf Option8.Value = True Then
    Text1.Text = Text9.Text
    End If
End Sub

Private Sub Command10_Click()
Text6.Text = Text3.Text
End Sub

Private Sub Command11_Click()
Text7.Text = Text3.Text
End Sub

Private Sub Command12_Click()
Text8.Text = Text3.Text
End Sub

Private Sub Command13_Click()
Text9.Text = Text3.Text
End Sub

Private Sub Command14_Click()
If Text1.Text < 0 Then
MsgBox "开方不能有负数"
Else
Text3.Text = Sqr(Text1.Text)
End If
End Sub

Private Sub Command15_Click()
Text1.Text = 3.1415926
Text3.Text = 3.1415926
End Sub

Private Sub Command16_Click()
Text3.Text = Text1.Text ^ 2
End Sub

Private Sub Command17_Click()
Text3.Text = Val(Text1.Text) ^ Val(Text2.Text)
End Sub

Private Sub Command18_Click()
Text3.Text = Text1.Text ^ (1 / 3)
End Sub

Private Sub Command19_Click()
Text3.Text = Text1.Text ^ 3
End Sub

Private Sub Command2_Click()
If Option9.Value = True Then
Text2.Text = Text3.Text
    ElseIf Option3.Value = True Then
    Text2.Text = Text4.Text
    ElseIf Option4.Value = True Then
    Text2.Text = Text5.Text
    ElseIf Option5.Value = True Then
    Text2.Text = Text6.Text
    ElseIf Option6.Value = True Then
    Text2.Text = Text7.Text
    ElseIf Option7.Value = True Then
    Text2.Text = Text8.Text
    ElseIf Option8.Value = True Then
    Text2.Text = Text9.Text
    End If
End Sub

Private Sub Command20_Click()
If Text2.Text = "0" Or Text2.Text = "" Then
MsgBox "开多次方运算数据2不能为0或者空"
Else
If Text1.Text < 0 Then
MsgBox "数据1小于0不能开多次方"
Else
Text3.Text = Val(Text1.Text) ^ Val(1 / Text2.Text)
End If
End If
End Sub

Private Sub Command21_Click()
If Text2.Text = "0" Or Text2.Text = "" Then
MsgBox "被除数不能为0"
Else
Text3.Text = Val(Text1.Text) Mod Val(Text2.Text)
End If
End Sub

Private Sub Command22_Click()
Text3.Text = Sin(Text1.Text)
End Sub

Private Sub Command23_Click()
Text3.Text = Cos(Text1.Text)
End Sub

Private Sub Command24_Click()
Text3.Text = Tan(Text1.Text)
End Sub

Private Sub Command25_Click()
If Text1.Text <= 0 Then
MsgBox "数据1不能小于等于0,请重新输入"
Else
Text3.Text = Log(Text1.Text)
End If
End Sub

Private Sub Command26_Click()
Text1.Text = Int(Text1.Text)
If Text1.Text < 0 Then
MsgBox "负数无阶乘,请重新输入"
Else
If Text1.Text = 1 Or Text1.Text = 0 Then
Text3.Text = 1
Else
If Text1.Text = 2 Then
Text3.Text = 2
Else
Text3.Text = 2
For i = 3 To Text1.Text
Text3.Text = Text3.Text * i
Next
End If
End If
End If
End Sub

Private Sub Command27_Click()
If Text2.Text = "" Or Text2.Text = "0" Or Text1.Text = "0" Or Text1.Text = "" Then
MsgBox "求对数数据1和数据2均不能为0或者空"
Else
If Text1.Text = "1" Then
MsgBox "除数为0不能计算"
Else
Text3.Text = Log(Text2.Text) / Log(Text1.Text)
End If
End If
End Sub

Private Sub Command28_Click()
MsgBox "1,数据1数据2输入数字,点左下方区域的运算;" & Chr(13) & "2,<保存结果>可临时存储计算结果;" & Chr(13) & "3,<复制结果选择>配合左上角“复制结果”使用;" & Chr(13) & "4,<字号大小>可以改变数据1,数据2,输出结果的文字大小;" & Chr(13) & "5,空白处只支持数字输入,填汉字或字母会报错;" & Chr(13) & "6,任意空白处框可手动输入、更改、复制、粘贴等"
End Sub

Private Sub Command3_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

Private Sub Command4_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub

Private Sub Command5_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub

Private Sub Command6_Click()
If Text2.Text = "0" Or Text2.Text = "" Then
MsgBox "被除数不能为0"
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub

Private Sub Command7_Click()
Text3.Text = ""
End Sub

Private Sub Command8_Click()
Text4.Text = Text3.Text
End Sub

Private Sub Command9_Click()
Text5.Text = Text3.Text
End Sub

Private Sub Form_Activate()
Text1.SetFocus
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text10_Change()
If Text10.Text = "" Then
Text1.FontSize = "30"
Else
Text1.FontSize = Text10.Text
End If
End Sub


Private Sub Text11_Change()
If Text11.Text = "" Then
Text2.FontSize = "30"
Else
Text2.FontSize = Text11.Text
End If
End Sub

Private Sub Text12_Change()
If Text12.Text = "" Then
Text3.FontSize = "30"
Else
Text3.FontSize = Text12.Text
End If
End Sub

原文地址:https://www.cnblogs.com/firecode/p/3165176.html