【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《VB计算器源代码》,欢迎阅读!
文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。 VB计算器源代码
Private Data As Double Private lOperation As Long Private fClear As Boolean
Private Sub Command1_Click(Index As Integer) If fClear = True Then Text1.Text = "": fClear = False Text1.Text = Text1.Text & Index End Sub
Private Sub Command2_Click()
If InStr(1, Text1.Text, ".") <= 0 Then Text1.Text = Text1.Text & "." End Sub
Private Sub Command3_Click() If fClear = False Then Select Case lOperation Case 0
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data / Val(Text1.Text) End Select End If
1word格式支持编辑,如有帮助欢迎下载支持。
文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。 Data = Val(Text1.Text) fClear = True lOperation = 0 End Sub
Private Sub Command4_Click()
If Len(Text1.Text) > 0 Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub
Private Sub Command5_Click() If fClear = False Then Select Case lOperation Case 0
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data / Val(Text1.Text)
End Select End If
Data = Val(Text1.Text) fClear = True lOperation = 1 End Sub
Private Sub Command6_Click() If fClear = False Then Select Case lOperation Case 0
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data / Val(Text1.Text)
End Select End If
Data = Val(Text1.Text) fClear = True lOperation = 2 End Sub
2word格式支持编辑,如有帮助欢迎下载支持。
文档从互联网中收集,已重新修正排版,word格式支持编辑,如有帮助欢迎下载支持。 Private Sub Command7_Click() If fClear = False Then Select Case lOperation Case 0
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data / Val(Text1.Text)
End Select End If
Data = Val(Text1.Text) fClear = True lOperation = 3 End Sub
Private Sub Command8_Click() If fClear = False Then Select Case lOperation Case 0
Case 1: Text1.Text = Data + Val(Text1.Text) Case 2: Text1.Text = Data - Val(Text1.Text) Case 3: Text1.Text = Data * Val(Text1.Text)
Case 4: If Val(Text1.Text) = 0 Then MsgBox "除数不等于0": Exit Sub Else Text1.Text = Data / Val(Text1.Text)
End Select End If
Data = Val(Text1.Text) fClear = True lOperation = 4 End Sub
Private Sub Command9_Click() Text1.Text = "" lOperation = 0 End Sub
3word格式支持编辑,如有帮助欢迎下载支持。
本文来源:https://www.wddqxz.cn/7f8284f05b0102020740be1e650e52ea5418ce45.html