Re: Datum -> KW -> Label
16.06.2002 11:43:56
andreas
Hallo Hajo,ich habe deinen Code eingebaut, das Ergebnis:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not IsDate(TextBox2) Then
If Not IsNumeric(TextBox2) Then
MsgBox "Kein Datum"
Else
If InStr(TextBox2, ".") = 0 Then
If Len(TextBox2.Value) = 6 Then TextBox2.Value = Left(TextBox2.Value, 4) & "20" & Right(TextBox2.Value, 2)
TextBox2.Value = Left(TextBox2.Value, 2) & "." & Mid(TextBox2.Value, 3, 2) & "." & Right(TextBox2.Value, 4)
If Not IsDate(TextBox2) Then MsgBox "Kein Datum"
End If
End If
End If
End Sub
Private Sub TextBox2_Change()
Dim i%
If Not IsDate(TextBox2) Then
Label1.Caption = ""
Exit Sub
Else
If Weekday(TextBox2) = 1 Then i = 1 Else i = 0
Label1.Caption = TextBox1.Text & "-" & Format(TextBox2, "ww", , vbFirstFourDays) - i & "/" & Right(TextBox2.Value, 2)
End If
End Sub
Funktioniert auf den ersten Blick gut. Warum zeigt der Code für den 29.12.2002 die KW 0 an? Kann man den Code ändern, dass eine einstellige KW zweistellig (z. B. 01) angezeigt wird?
Trotzdem Danke für die Hilfe.
Und tschüß
Andreas