《VB计算器源代码.doc》由会员分享,可在线阅读,更多相关《VB计算器源代码.doc(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Dim sum As DoubleDim flag1 As IntegerDim flag2 As IntegerPublic wen As DoublePrivate Sub Command19_Click() Command24_Click Operator = Index NewEntry = TrueEnd SubPrivate Sub Command1_Click(Index As Integer)Select Case Index Case 0 wen = 0 Label1.Caption = Case 1 Text1.Text = Str(wen) Case 2 If Text1
2、.Text = Then wen = 0 Label1.Caption = Else wen = Val(Text1.Text) Label1.Caption = M End If Text1.Text = Case 3 wen = Val(Text1.Text) + wen Label1.Caption = M End SelectEnd SubPrivate Sub Command12_Click()If Text1.Text Then Text1.Text = Text1.Text * -1Else MsgBox 输入不能为空!, vbOKOnly, 警告 Text1.SetFocus
3、End IfEnd SubPrivate Sub Command16_Click()If InStr(Text1.Text, .) = 0 ThenText1.Text = Text1.Text & .ElseExit SubEnd IfEnd SubPrivate Sub Command21_Click()Text1.Text = Str(Sqr(Val(Text1.Text)End SubPrivate Sub Command22_Click()sum = Text1.Textflag1 = 5flag2 = 1End SubPrivate Sub Command23_Click()Tex
4、t1.Text = Str(Val(Text1.Text / 1)flag2 = 0End SubPrivate Sub Command24_Click()Select Case (flag1)Case 1Text1.Text = sum + Text1.TextCase 2Text1.Text = sum - Text1.TextCase 3Text1.Text = sum * Text1.TextCase 4If Text1.Text = 0 Thendf = MsgBox(除数不能为零!请重新输入., vbOKOnly + vbInformation, 警告)Text1.Text = T
5、ext1.SetFocusExit SubElseText1.Text = sum / Text1.TextEnd IfCase 5If Text1.Text = 0 Then df = MsgBox(余数不能为零!请重新输入., vbOKOnly + vbInformation, 警告) Text1.Text = Text1.SetFocusExit SubElseText1.Text = sum Mod Text1.TextEnd IfEnd Selectflag2 = 0End SubPrivate Sub Command25_Click()If Text1.Text ThenText1
6、.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)If Text1.Text = ThenText1.Text = 0End IfEnd IfEnd SubPrivate Sub Command26_Click()Text1.Text = 0End SubPrivate Sub Command27_Click()Text1.Text = 0End SubPrivate Sub Command5_Click(Index As Integer)If flag2 = 1 Then Text1.Text = Index flag2 = 0Else If Te
7、xt1.Text 0 Then Text1.Text = Text1.Text & Index Else Text1.Text = & Index End IfEnd IfEnd SubPrivate Sub Command6_Click() If Text1.Text Then sum = Text1.Text flag1 = 4 flag2 = 1Else MsgBox 输入不能为空!, vbOKOnly, 警告 Text1.SetFocusEnd IfEnd SubPrivate Sub Command7_Click()If Text1.Text Then sum = Text1.Tex
8、t flag1 = 3 flag2 = 1Else MsgBox 输入不能为空!, vbOKOnly, 警告 Text1.SetFocusEnd IfEnd SubPrivate Sub Command8_Click()If Text1.Text Then sum = Text1.Text flag1 = 2 flag2 = 1Else MsgBox 输入不能为空!, vbOKOnly, 警告 Text1.SetFocusEnd IfEnd SubPrivate Sub Command9_Click()If Text1.Text Then sum = Text1.Text flag1 = 1 flag2 = 1Else MsgBox 输入不能为空!, vbOKOnly, 警告 Text1.SetFocusEnd IfEnd Sub