VERSION 5.00 Begin VB.Form Form1 Caption = "Berechnung des Wochentags" ClientHeight = 4125 ClientLeft = 60 ClientTop = 345 ClientWidth = 6105 LinkTopic = "Form1" ScaleHeight = 4125 ScaleWidth = 6105 StartUpPosition = 3 'Windows Default Begin VB.TextBox tfWochentag Height = 375 Left = 1800 TabIndex = 9 Text = " " Top = 2640 Width = 2415 End Begin VB.CommandButton bsAktuell Caption = "aktuelles Datum" Height = 375 Left = 3960 TabIndex = 8 Top = 1560 Width = 1455 End Begin VB.CommandButton bsNeu Caption = "Neu eingeben" Height = 375 Left = 2280 TabIndex = 7 Top = 1560 Width = 1455 End Begin VB.CommandButton bsBerechnen Caption = "Berechnen" Height = 375 Left = 600 TabIndex = 6 Top = 1560 Width = 1455 End Begin VB.TextBox tfJahr Height = 375 Left = 3720 TabIndex = 4 Top = 840 Width = 855 End Begin VB.TextBox tfMonat Enabled = 0 'False Height = 375 Left = 2640 TabIndex = 2 Text = "1" Top = 840 Width = 855 End Begin VB.TextBox tfTag Enabled = 0 'False Height = 375 Left = 1560 TabIndex = 0 Text = "1" Top = 840 Width = 855 End Begin VB.Label Label4 Alignment = 2 'Center Caption = "Wochentag" Height = 255 Left = 1800 TabIndex = 10 Top = 2400 Width = 2415 End Begin VB.Label Label3 Caption = "Jahr" Height = 255 Left = 3720 TabIndex = 5 Top = 600 Width = 855 End Begin VB.Label Label2 Caption = "Monat" Height = 255 Left = 2640 TabIndex = 3 Top = 600 Width = 855 End Begin VB.Label Label1 Caption = "Tag" Height = 255 Left = 1560 TabIndex = 1 Top = 600 Width = 855 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mJahr As Integer Dim mStandardVersatz As Integer Dim mSchaltjahrVersatz As Integer Dim mGesamtVersatz As Integer Dim mWochen As Integer Dim mTag As Integer Dim mAktuellesJahr As Integer Private Sub Form_Load() 'Form 1 anzeigen Form1.Show 'Fokus auf tfJahr setzen tfJahr.SetFocus End Sub Private Sub tfJahr_KeyPress(KeyAscii As Integer) 'Wurde ENTER gedrueckt? Dann Fokus auf bsBerechnen If KeyAscii = 13 Then bsBerechnen.SetFocus End If End Sub Private Sub bsBerechnen_Click() 'Unterprozeduren aufrufen przDatenuebernahme 'Wertebereich pruefen If mJahr < 1900 Or mJahr > 2100 Then tfJahr.Text = "" tfJahr.SetFocus MsgBox ("Geben Sie ein Jahr zwischen 1900 und 2100 ein!") Else przWochentagBerechnen przDatenuebergabe 'Fokus auf tfJahr setzen tfJahr.SetFocus End If End Sub Private Sub bsNeu_Click() 'tfJahr leeren tfJahr.Text = "" 'Fokus auf tfJahr setzen tfJahr.SetFocus End Sub Private Sub bsAktuell_Click() 'Aktuelles Jahr aus Computeruhr übernehmen und in tfJahr schreiben mAktuellesJahr = Year(Now()) tfJahr.Text = mAktuellesJahr 'Fokus auf bsBerechnen bsBerechnen.SetFocus End Sub Private Sub tfWochentag_GotFocus() 'Fokus auf tfJahr setzen tfJahr.SetFocus End Sub Private Sub przDatenuebernahme() 'Jahr aus Textfeld nehmen und in Speichervariable uebertragen mJahr = CInt(tfJahr.Text) End Sub Private Sub przWochentagBerechnen() '1 Versatztag pro Jahr seit 1900 mStandardVersatz = mJahr - 1900 '1 Versatztag zusaetzlich pro Schaltjahr mSchaltjahrVersatz = Int((mStandardVersatz - 1) / 4) 'Gesamtversatztage berechnen mGesamtVersatz = mStandardVersatz + mSchaltjahrVersatz 'Volle Wochen berechnen mWochen = Int(mGesamtVersatz / 7) 'Resttage bestimmen mTag = mGesamtVersatz - 7 * mWochen End Sub Private Sub przDatenuebergabe() If mTag = 0 Then tfWochentag.Text = "Montag" End If If mTag = 1 Then tfWochentag.Text = "Dienstag" End If If mTag = 2 Then tfWochentag.Text = "Mittwoch" End If If mTag = 3 Then tfWochentag.Text = "Donnerstag" End If If mTag = 4 Then tfWochentag.Text = "Freitag" End If If mTag = 5 Then tfWochentag.Text = "Samstag" End If If mTag = 6 Then tfWochentag.Text = "Sonntag" End If End Sub