VB编写的电脑附件中计算器的代码
Option Explicit Private Sub Command1_Click() Text1 = "" Text2 = "" Label5。Caption = "" Text1。SetFocus Option1。 Value = True End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() If Option1。 Value = True Then Label5。Caption = Val(Text1) Val(Text2) End If If Option2。Value...全部
Option Explicit Private Sub Command1_Click() Text1 = "" Text2 = "" Label5。Caption = "" Text1。SetFocus Option1。
Value = True End Sub Private Sub Command2_Click() End End Sub Private Sub Command3_Click() If Option1。
Value = True Then Label5。Caption = Val(Text1) Val(Text2) End If If Option2。Value = True Then Label5。
Caption = Val(Text1) - Val(Text2) End If If Option3。Value = True Then Label5。Caption = Val(Text1) * Val(Text2) End If If Option4。
Value = True Then Label5。Caption = Val(Text1) / Val(Text2) End If Command1。SetFocus End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Option1。
SetFocus End If If IsNumeric(Text1。Text) Then If (KeyAscii = 45) Then Option2。Value = True Text2。
SetFocus ElseIf (KeyAscii = 43) Then Option1。Value = True Text2。SetFocus ElseIf (KeyAscii = 42) Then Option3。
Value = True Text2。SetFocus ElseIf (KeyAscii = 47) Then Option4。Value = True Text2。SetFocus End If ElseIf (Len(Text1。
Text) > 0) Then MsgBox "你输入了不正确格式或字符,请重新输入(你只能输入 0--9十个数字)", vbOKOnly vbInformation, "注意" Text1。
Text = "" End If End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) If IsNumeric(Text2。Text) Then ElseIf (Len(Text2。
Text) > 0) Then MsgBox "你输入了不正确格式或字符,请重新输入(你只能输入 0--9十个数字)", vbOKOnly vbInformation, "注意" Text2。
Text = "" End If If KeyAscii = 13 Then Command3。SetFocus End If End Sub。收起