什么按键啊
我编了一个
把代码给你吧
Public p As String
Public f As Double
Public s As Double
Dim X
Dim a
Dim b
Dim c
Dim d
Private Sub cmdAbs_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> 0 Then
f = txtScreen.Text
s = f
s = Abs(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdAtn_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Atn(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdClean_Click()
txtScreen = ""
f = 0
s = 0
End Sub
Private Sub cmdClear_Click()
txtScreen.Text = ""
f = 0
s = 0
txtScreen2.Text = ""
txtGH.Text = ""
cmdSpr.Enabled = True
cmdXmY.Enabled = True
cmdCos.Enabled = True
cmdSin.Enabled = True
cmdMi.Enabled = True
cmdAbs.Enabled = True
cmdds.Enabled = True
cmdAtn.Enabled = True
cmdeN.Enabled = True
cmdLog.Enabled = True
cmdTan.Enabled = True
cmdspr2.Enabled = True
cmdGHH.Enabled = True
End Sub
Private Sub cmdCos_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Cos(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdDigit_Click(Index As Integer)
txtScreen.Text = txtScreen.Text & cmdDigit(Index).Caption
s = txtScreen.Text
End Sub
Private Sub cmdDivide_Click(Index As Integer)
If p = "" Then
txtScreen.Text = ""
p = "/"
f = s
s = 0
End If
End Sub
Private Sub cmdds_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> 0 Then
f = txtScreen.Text
s = f
s = 1 / f
txtScreen.Text = s
txtScreen2.Text = s
Else
MsgBox "分子不能为零。"
End If
End Sub
Private Sub cmden_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Exp(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdEnd_Click()
Unload Form1
Unload Calc1
End Sub
Private Sub cmdEqual_Click(Index As Integer)
On Err GoTo e1
If p = "" Then
s = s
txtScreen.Text = txtScreen.Text
txtScreen2.Text = txtScreen.Text
ElseIf p = "+" Then
s = f + s
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "-" Then
s = f - s
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "*" Then
s = f * s
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "^" Then
cmdSpr.Enabled = True
cmdXmY.Enabled = True
cmdCos.Enabled = True
cmdSin.Enabled = True
cmdMi.Enabled = True
cmdAbs.Enabled = True
cmdds.Enabled = True
cmdAtn.Enabled = True
cmdeN.Enabled = True
cmdLog.Enabled = True
cmdTan.Enabled = True
cmdspr2.Enabled = True
s = f ^ s
If s < 0 Then
txtScreen.Text = 0 & txtScreen & Text
txtScreen2.Text = 0 & txtScreen & Text
End If
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "spr" Then
cmdSpr.Enabled = True
cmdXmY.Enabled = True
cmdCos.Enabled = True
cmdSin.Enabled = True
cmdMi.Enabled = True
cmdAbs.Enabled = True
cmdds.Enabled = True
cmdAtn.Enabled = True
cmdeN.Enabled = True
cmdLog.Enabled = True
cmdTan.Enabled = True
s = f ^ (1 / s)
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "spr" And s = 0 Then
s = 1
If s < 0 Then
txtScreen.Text = 0 & txtScreen & Text
txtScreen2.Text = 0 & txtScreen & Text
End If
txtScreen.Text = s
txtScreen2.Text = s
s = s
ElseIf p = "/" And s <> 0 Then
s = f / s
If s < 0 Then
txtScreen.Text = 0 & txtScreen & Text
txtScreen2.Text = 0 & txtScreen & Text
End If
txtScreen.Text = s
txtScreen2.Text = s
s = s
Else
MsgBox "除数不能为零"
End If
If s < 0 Then
txtScreen.Text = 0 & txtScreen & Text
txtScreen2.Text = 0 & txtScreen & Text
End If
Exit Sub
e1:
If Err = 6 Then
MsgBox "数值溢出!!!"
End If
End Sub
Private Sub cmdGHH_Click()
s = s ^ 2
txtGH.Text = s
If txtGH.Text <> "" And txtGH.Text <> "0" Then
cmdGHH.Enabled = False
ElseIf txtGH.Text = "" And txtGH.Text = "0" Then
cmdGHH.Enabled = True
End If
End Sub
Private Sub cmdLog_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Log(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdMi_Click()
On Err GoTo r1
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = s ^ 2
txtScreen.Text = s
txtScreen2.Text = s
End If
Exit Sub
r1:
If Err = 6 Then
MsgBox "数值溢出!!!"
End If
End Sub
Private Sub cmdMinus_Click()
If p = "" Then
txtScreen.Text = ""
p = "-"
f = s
s = 0
End If
End Sub
Private Sub cmdMutiply_Click(Index As Integer)
If p = "" Then
txtScreen.Text = ""
p = "*"
f = s
s = 0
End If
End Sub
Private Sub cmdPi_Click()
txtScreen.Text = "3.1415926535897932384626433832795"
f = 3.14159265358979
s = f
End Sub
Private Sub cmdPlus_Click()
If p = "" Then
txtScreen.Text = ""
p = "+"
f = s
s = 0
End If
End Sub
Private Sub cmdPoint_Click(Index As Integer)
If txtScreen.Text = "" Then
txtScreen = "0."
Else
txtScreen.Text = txtScreen.Text & "."
End If
End Sub
Private Sub cmdSave1_Click()
If txtScreen.Text = "" Then
MsgBox "请输入数字。"
mnuA.Enabled = False
Else
a = txtScreen.Text
mnuA.Enabled = True
End If
End Sub
Private Sub cmdSave2_Click()
If txtScreen.Text = "" Then
MsgBox "请输入数字。"
mnuB.Enabled = False
Else
b = txtScreen.Text
mnuB.Enabled = True
End If
End Sub
Private Sub cmdSave3_Click()
If txtScreen.Text = "" Then
MsgBox "请输入数字。"
mnuC.Enabled = False
Else
c = txtScreen.Text
mnuC.Enabled = True
End If
End Sub
Private Sub cmdSave4_Click()
If txtScreen.Text = "" Then
MsgBox "请输入数字。"
mnuD.Enabled = False
Else
d = txtScreen.Text
mnuD.Enabled = True
End If
End Sub
Private Sub cmdSin_Click()
If txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Sin(s)
txtScreen.Text = s
txtScreen2.Text = s
Else
MsgBox "请输入数字"
End If
End Sub
Private Sub cmdSpr_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text >= 0 Then
f = txtScreen.Text
s = f
s = s ^ (1 / 2)
txtScreen.Text = s
txtScreen2.Text = s
Else
MsgBox "底数不能小于零。"
End If
End Sub
Private Sub cmdspr2_Click()
cmdSpr.Enabled = False
cmdXmY.Enabled = False
cmdCos.Enabled = False
cmdSin.Enabled = False
cmdMi.Enabled = False
cmdAbs.Enabled = False
cmdds.Enabled = False
cmdAtn.Enabled = False
cmdeN.Enabled = False
cmdLog.Enabled = False
cmdTan.Enabled = False
If txtScreen.Text <> "" Then
txtScreen.Text = ""
p = "spr"
f = s
s = 0
Else
cmdSpr.Enabled = True
cmdXmY.Enabled = True
cmdCos.Enabled = True
cmdSin.Enabled = True
cmdMi.Enabled = True
cmdAbs.Enabled = True
cmdds.Enabled = True
cmdAtn.Enabled = True
cmdeN.Enabled = True
cmdLog.Enabled = True
cmdTan.Enabled = True
MsgBox "请输入数字!"
End If
End Sub
Private Sub cmdTan_Click()
If txtScreen.Text = "" Then
MsgBox "无数字,无法计算"
ElseIf txtScreen.Text <> "" Then
f = txtScreen.Text
s = f
s = Tan(s)
txtScreen.Text = s
txtScreen2.Text = s
End If
End Sub
Private Sub cmdXmY_Click()
cmdSpr.Enabled = False
cmdCos.Enabled = False
cmdSin.Enabled = False
cmdMi.Enabled = False
cmdAbs.Enabled = False
cmdds.Enabled = False
cmdAtn.Enabled = False
cmdeN.Enabled = False
cmdLog.Enabled = False
cmdTan.Enabled = False
cmdspr2.Enabled = False
p = "^"
txtScreen.Text = ""
f = s
s = 0
End Sub
Private Sub Command1_Click()
If txtScreen.Text = "" Then
txtScreen.Text = "-"
Else
txtScreen.Text = "-" & txtScreen & Text
End If
End Sub
Private Sub Form_Load()
mnuA.Enabled = False
mnuB.Enabled = False
mnuC.Enabled = False
mnuD.Enabled = False
End Sub
Private Sub mnuA_Click()
If a <> "" Then
txtScreen.Text = a
s = a Or f = a
Else
MsgBox "数据导入时出错!存储器A中无数据"
End If
End Sub
Private Sub mnuARR_Click()
calcAbout.Show
End Sub
Private Sub mnuB_Click()
If b <> "" Then
txtScreen.Text = b
s = b Or f = a
Else
MsgBox "数据导入时出错!存储器B中无数据"
End If
End Sub
Private Sub mnuC_Click()
If c <> "" Then
txtScreen.Text = c
s = c Or f = c
Else
MsgBox "数据导入时出错!存储器C中无数据"
End If
End Sub
Private Sub mnuCopy_Click()
If Clipboard.GetFormat(vbCFText) = False Then
Clipboard.SetText txtScreen.SelText, vbCFText
mnuZT.Enabled = True
Else
mnuZT.Enabled = False
End If
End Sub
Private Sub mnuD_Click()
If d <> "" Then
txtScreen.Text = d
s = d Or f = d
Else
MsgBox "数据导入时出错!存储器D中无数据"
End If
End Sub
Private Sub mnuKX_Click()
mnuPT.Checked = False
mnuKX.Checked = True
Unload Form1
Calc1.Show
End Sub
Private Sub mnuPT_Click()
mnuKX.Checked = False
mnuPT.Checked = True
Unload Calc1
Form1.Show
End Sub
Private Sub mnuSC_Click()
a = ""
b = ""
c = ""
d = ""
mnuA.Enabled = False
mnuB.Enabled = False
mnuC.Enabled = False
mnuD.Enabled = False
End Sub
Private Sub mnuZT_Click()
txtScreen.SelText = Clipboard.GetText(vbCFText)
End Sub