vb计算器 简单程序(包含 进制转换 )
- 格式:doc
- 大小:51.00 KB
- 文档页数:8
vb计算器简单程序(包含进制转换 ).txt如果青春的时光在闲散中度过,那么回忆岁月将是一场凄凉的悲剧。杂草多的地方庄稼少,空话多的地方智慧少。即使路上没有花朵,我仍可以欣赏荒芜。Option Explicit
Dim s1 As Integer, N As Single, r As Integer
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Index
End Sub
'CE
Private Sub Command11_Click()
Text1.Text = ""
End Sub
Private Sub Command12_Click()
Text1.Text = (Text1.Text) ^ 2
End Sub
Private Sub Command17_Click()
Text1.Text = " "
End Sub
Private Sub Command18_Click()
Text1.Text = (Text1.Text) ^ 3
End Sub
Private Sub Command20_Click()
If Text1.Text = "" Then
MsgBox ("操作错误")
Else
Text1.Text = Val(Text1.Text) * (-1)
End If
End Sub
Private Sub Command21_Click()
If InStr(Text1.Text, ".") Then
MsgBox ("小数点已存在")
Else
Text1.Text = Text1 & Chr(46)
End If
End Sub
Private Sub Command23_Click()
If N = 1 Then
If Text1.Text = 0 Then
MsgBox "除数不能为零"
Else
Text1 = s1 / Text1.Text
End If
ElseIf N = 2 Then
Text1 = s1 * Text1.Text
ElseIf N = 3 Then
Text1 = s1 - Text1.Text
ElseIf N = 4 Then
Text1 = s1 + Text1.Text
End If
End Sub
Private Sub Command24_Click()
Text1.Text = 1 / Text1.Text
End Sub
Private Sub Command25_Click(Index As Integer) Select Case Index
Case 0
Text1.Text = Text1.Text & "A"
Case 1
Text1.Text = Text1.Text & "B"
Case 2
Text1.Text = Text1.Text & "C"
Case 3
Text1.Text = Text1.Text & "D"
Case 4
Text1.Text = Text1.Text & "E"
Case 5
Text1.Text = Text1.Text & "F"
End Select
End Sub
Private Sub Command4_Click(Index As Integer) Select Case Index
Case 0
N = 1
s1 = Text1.Text
Text1.Text = ""
Case 1
N = 2
s1 = Text1.Text
Text1.Text = ""
Case 2
N = 3
s1 = Text1.Text
Text1.Text = ""
Case 3
N = 4
s1 = Text1.Text
Text1.Text = ""
End Select
End Sub
Private Sub Command5_Click()
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1) End Sub
Private Sub Command6_Click()
Text1.Text = Sqr(Text1.Text)
End Sub
Private Sub Form_Load()
r = 10
End Sub
'十六进制
Private Sub Option1_Click()
Command25(1).Enabled = True
Command25(0).Enabled = True
Command25(2).Enabled = True
Command25(3).Enabled = True
Command25(4).Enabled = True
Command25(5).Enabled = True
Command1(6).Enabled = True
Command1(9).Enabled = True
Command1(2).Enabled = True
Command1(3).Enabled = True