| Option Base 1, Array, Mod-Operator |
| |
| |
| Option Base 1 | Diese Deklarationen gehören in ein eigenes Modul |
| |
| Public maxtag%(12) | Array deklarieren |
| Public jjjj As Integer | |
| Public mm As Integer | |
| Public tt As Integer | |
| Public dfehl% | |
| |
| Private Sub Form_Load() | |
| maxtag(1) = 31 | Array laden |
| maxtag(2) = 28 | |
| maxtag(3) = 31 | |
| maxtag(4) = 30 | |
| maxtag(5) = 31 | |
| maxtag(6) = 30 | |
| maxtag(7) = 31 | |
| maxtag(8) = 31 | |
| maxtag(9) = 30 | |
| maxtag(10) = 31 | |
| maxtag(11) = 30 | |
| maxtag(12) = 31 | |
| |
| txtTag.MaxLength = 2 | |
| txtMonat.MaxLength = 2 | |
| txtJahr.MaxLength = 4 | |
| End Sub | |
| |
| Private Sub cmdDatPruef_Click() | |
| tt = Val(txtTag.Text) | |
| mm = Val(txtMonat.Text) | Array |
| jjjj = Val(txtJahr.Text) | |
| dfehl = 0 | Variable für falsches Datum (0 = richtig). |
| |
| If jjjj < -9999 Or jjjj > 9999 Then | Fehlerprüfungen: |
| dfehl = 1 | Jahr zu klein oder zu groß. |
| Else | |
| If mm < 1 Or mm > 12 Then | Monat zu klein oder zu groß. |
| dfehl = 1 | |
| Else | |
| If jjjj Mod 4 = 0 And jjjj Mod 100 <> 0 Or _ | Bei Schaltjahr: 29 Tage im Februar. |
| jjjj Mod 400 = 0 Then | Schaltjahr nur alle 400 Jahre (also nicht 1700, 1800, 1900!). |
| maxtag(2) = 29 | |
| Else | |
| maxtag(2) = 28 | Kein Schaltjahr. |
| End If | |
| Call februar | |
| End If | |
| End If | |
| If dfehl = 1 Then lblAusgabe.Caption = "falsches Datum" | |
| End Sub | |
| |
| Private Sub februar() | |
| If tt < 1 Or tt > maxtag(mm) Then |
| dfehl = 1 |
| Else |
| lblAusgabe.Caption = "Datum plausibel" |
| End If |
| End Sub |
|
| Private Sub loeschen() |
| lblAusgabe.Caption = "" |
| txtTag.Text = "" | |
| txtMonat.Text = "" | |
| txtJahr.Text = "" |
| txtTag.SetFocus |
| End Sub |
|
| Private Sub cmdWeiter_Click() |
| Call loeschen |
| End Sub |
|
| Private Sub txtTag_Click() |
| Call loeschen |
| End Sub | |
| |