Dim x%
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
Label1 = Label1 + "0"
Case 1
Label1 = Label1 + "1"
Case 2
Label1 = Label1 + "2"
Case 3
Label1 = Label1 + "3"
Case 4
Label1 = Label1 + "4"
Case 5
Label1 = Label1 + "5"
Case 6
Label1 = Label1 + "6"
Case 7
Label1 = Label1 + "7"
Case 8
Label1 = Label1 + "8"
Case 9
Label1 = Label1 + "9"
Case 12
Label1 = Label1 & "+"
Case 13
Label1 = Label1 & "-"
Case 14
Label1 = (Label1 & "×") * 1
Case 15
Label1 = Label1 & "÷" / 1
Case 16
Label1 = Left$(Label1, Len(Label1) - 1)
Case 17
Label2 = Label1
End Select
End Sub
Private Sub Command4_Click()
Label1.Caption = ""
End Sub
我做的就不太会了,大家帮帮忙帮我做完,谢谢了,每段代码加上解释,谢谢!
Option Explicit
Dim num2, num1 As Variant
Dim flag, hflag, ff As Boolean
Dim c, t As Long
Const pi = 3.1415926535898
Private Sub backspace_Click()
'退格键
If flag = False Then
Exit Sub
End If
If flag = True Then
If Len(Text.Text) <= 1 Then
Text.Text = "0."
Exit Sub
Else
t = Mid(Text.Text, 1, Len(Text.Text) - 1)
Text.Text = t
num1 = ""
End If
End If
End Sub
Private Sub ccos_Click()
'余弦
Dim scos As Double
scos = Val(Text.Text)
If hflag = True Then
Text.Text = Sin(scos)
Else
Text.Text = Cos(pi * scos / 180)
End If
hflag = False
'标示进行过运算
flag = False
End Sub
Private Sub ce_Click()
'清零键
Text.Text = "0."
num1 = ""
num2 = ""
flag = True
End Sub
Private Sub Command1_Click(Index As Integer)
'加减乘除——控件数组
num2 = num1
Text.Text = ""
num1 = ""
c = Index
End Sub
Private Sub Command2_Click()
'结果键
Select Case c
Case 0
If Val(Text.Text) = 0 Then
MsgBox "被除数不能为零", vbExclamation, "错误"
Else
Text.Text = Str(Val(num2) / Val(num1))
End If
Case 1
Text.Text = Str(Val(num2) * Val(num1))
Case 2
Text.Text = Str(Val(num2) - Val(num1))
Case 3
Text.Text = Str(Val(num2) + Val(num1))
End Select
flag = True
End Sub
Private Sub Form_Load()
hflag = False
flag = True
ff = True
Wp.URL = "C:\TDdownload\水边的阿狄丽娜.mp3"
End Sub
Private Sub hudulflag_Click()
'弧度角度切换键(togglebutton)
If ff = True Then
hudulflag.Caption = "弧度"
ff = False
Else
hudulflag.Caption = "角度"
ff = True
End If
hflag = hudulflag
'角度弧度转换
'If hudulflag.Tag = "1" Then
'hudulflag.Caption = "弧度"
'hflag = True
'Else
'hflag = False
'hudulflag.Caption = "角度"
'End If
'MsgBox hudulflag
End Sub
Private Sub num_Click(Index As Integer)
'数字键0-9,控件数组
If Text.Text = "0." Then
Text.Text = ""
Else
If Val(Text.Text) > 4294967295# Then
MsgBox "别再按了,再按下去数据就溢出了"
Exit Sub
End If
End If
num1 = num1 + num(Index).Caption
Text.Text = num1
End Sub
Private Sub pf_Click()
'平方键
Text.Text = Val(Text.Text) * Val(Text.Text)
'标示进行过运算
flag = False
End Sub
Private Sub point_Click()
If InStr(num1, ".") Then
Exit Sub
Else
num1 = num1 + "."
Text.Text = num1
End If
End Sub
Private Sub sinn_Click()
'正弦
Dim ssin As Double
ssin = Val(Text.Text)
If hflag = True Then
Text.Text = Sin(ssin)
Else
Text.Text = Sin(pi * ssin / 180)
End If
hflag = False
'标示进行过运算
flag = False
End Sub
Private Sub sq_Click()
'开方
If Val(Text.Text) >= 0 Then
Text.Text = Sqr(Val(Text.Text))
End If
'标示进行过运算
flag = False
End Sub