Textbox format "dd/mm/yyyy"
Hejklikker MonthView1(01-01-2018)
Textbox1= 01-01-2018
Range("A2").Value =01-01-2018
klikker ind i Textbox1 tilføjer 9(måned 19) 01-019-2018
Excel ændre til 19-01-2018?????
Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
On Error Resume Next
TextBox1 = Format(DateClicked, "dd/mm/yyyy")
End Sub
Private Sub TextBox1_Change()
On Error GoTo ErrorHandler
Application.EnableEvents = False 'disable Worksheet_SelectionChange, Worksheet_Change
If Me.TextBox1.Text = "" Then
'do nothing
ElseIf Me.TextBox1.Text <> "" Then
Me.TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy")
If IsDate(Me.TextBox1.Value) = True Then
Me.TextBox1.ForeColor = RGB(0, 0, 0)
Range("A2").Value = CDate(Me.TextBox1.Value)
Else
Me.TextBox1.ForeColor = RGB(250, 0, 0)
Range("A2").ClearContents
End If
End If
ErrorHandler:
Application.EnableEvents = True 'disable Worksheet_SelectionChange, Worksheet_Change
End Sub