| On Error Goto..., Err.Number, Err.Description |
| |
| |
| Private Operand1 As Single | |
| Private Operand2 As Single |
| Private Ergebnis As Single |
|
| Private Sub cmdDivision_Click() |
| On Error GoTo errDivision |
| Ergebnis = Operand1 / Operand2 |
| lblErgebnis.Caption = Ergebnis |
| Exit Sub | |
| errDivision: | Ausgabe Error-Meldung: |
| Select Case Err.Number | |
| Case 11 | Division durch Null. |
| lblErgebnis.Caption = "Error" | |
| Exit Sub | |
| Case 6 | Überlauf. |
| lblErgebnis.Caption = "Error" | |
| Exit Sub | |
| Case Else | |
| MsgBox "Laufzeitfehler (" & Err.Number & ")", 16, Err.Description |
| Stop | |
| End Select | |
| End Sub | |
| |
| Private Sub cmdMinus_Click() | |
| On Error GoTo errMinus | |
| Ergebnis = Operand1 - Operand2 | |
| lblErgebnis.Caption = Ergebnis | |
| Exit Sub | |
| errMinus: | |
| Select Case Err.Number | |
| Case 6 | Überlauf. |
| lblErgebnis.Caption = "Error" | |
| Exit Sub | |
| Case Else | |
| MsgBox "Laufzeitfehler (" & Err.Number & ")", 16, Err.Description |
| Stop | |
| End Select | |
| End Sub | |
| |
| Private Sub cmdMultiplikation_Click() | |
| On Error GoTo errMultiplikation | |
| Ergebnis = Operand1 * Operand2 | |
| lblErgebnis.Caption = Ergebnis | |
| Exit Sub | |
| errMultiplikation: | |
| Select Case Err.Number | |
| Case 6 | Überlauf. |
| lblErgebnis.Caption = "Error" | |
| Exit Sub | |
| Case Else | |
| MsgBox "Laufzeitfehler (" & Err.Number & ")", 16, Err.Description |
| Stop | |
| End Select | |
| End Sub | |
| |
| Private Sub cmdPlus_Click() | |
| On Error GoTo errPlus | |
| Ergebnis = Operand1 + Operand2 | |
| lblErgebnis.Caption = Ergebnis | |
| Exit Sub | |
| errPlus: | |
| Select Case Err.Number | |
| Case 6 | Überlauf. |
| lblErgebnis.Caption = "Error" | |
| Exit Sub | |
| Case Else | |
| MsgBox "Laufzeitfehler (" & Err.Number & ")", 16, Err.Description |
| Stop | |
| End Select | |
| End Sub | |
| |
| Private Sub txtOperand1_Change() | |
| If IsNumeric(txtOperand1.Text) = True Then | |
| Operand1 = CSng(txtOperand1.Text) | |
| End If | |
| End Sub | |
| |
| Private Sub txtOperand1_KeyPress(KeyAscii As Integer) | |
| Select Case Chr(KeyAscii) | |
| Case "0" To "9" | |
| Case "." | |
| If InStr(txtOperand1.Text, ".") <> 0 Then | |
| KeyAscii = 0 | |
| End If | |
| Case Chr(vbKeyBack) | |
| Case Else | |
| KeyAscii = 0 | |
| End Select | |
| End Sub | |
| |
| Private Sub txtOperand2_Change() | |
| If IsNumeric(txtOperand2.Text) = True Then | |
| Operand2 = CSng(txtOperand2.Text) | |
| End If | |
| End Sub | |
| |
| Private Sub txtOperand2_KeyPress(KeyAscii As Integer) | |
| Select Case Chr(KeyAscii) | |
| Case "0" To "9" | |
| Case "." | |
| If InStr(txtOperand2.Text, ".") <> 0 Then | |
| KeyAscii = 0 | |
| End If | |
| Case Chr(vbKeyBack) | |
| Case Else | |
| KeyAscii = 0 | |
| End Select | |
| End Sub | |
| |