• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Excel userform tarih formatı bozuluyor.

Katılım
9 Ağustos 2011
Mesajlar
94
Excel Vers. ve Dili
2010 / Türkçe
Arkadaşlar Office 2013 kullanıyorum daha önce kullandığım kodlar yanlış çalışmaya başladı. Aşağıda sıkıntı yaşadığım kodları yazıyorum.
Kod:
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox3.Value = Format(TextBox3.Value, "dd.mm.yyyy")
End Sub
Private Sub TextBox3_Change()
If UserForm2.TextBox3 <> "" Then
If Len(TextBox3) = 2 Then
TextBox3 = Format(TextBox3, "0#"".")
End If
If Len(TextBox3) = 5 Then
TextBox3 = Format(TextBox3, "0#"".""##"".")
End If
If Len(TextBox3) = 10 Then
TextBox3 = Format(TextBox3, "0#"".""##"".""####")
End If
End If
End Sub

Daha önceden bu kodlar çok iyi çalışıyordu ancak örneğin şimdi 20.08.2013 yazmak istediğimde otomatik olarak 00.20.2013 olarak dönüşüyor. Sıkıntı ne olabilir
 
Kullandığınız kodları aşağıdaki gibi değiştirip deneyiniz.

Kod:
Option Explicit
Dim Kontrol As Boolean

Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    On Error GoTo Son
    TextBox3.Value = Format(TextBox3.Value, "dd.mm.yyyy")
    Exit Sub
Son: MsgBox "Hatalı tarih girişi!", vbCritical
     TextBox3 = ""
     Cancel = True
End Sub

Private Sub TextBox3_Change()
    If Kontrol = True Then Exit Sub
    If TextBox3 <> "" Then
        Select Case Len(TextBox3)
            Case 2, 5
                TextBox3 = TextBox3 & "."
            Case 10
                On Error GoTo Son
                TextBox3 = Format(TextBox3, "dd.mm.yyyy")
                Exit Sub
Son:            MsgBox "Hatalı tarih girişi!", vbCritical
                TextBox3 = ""
        End Select
    End If
End Sub

Private Sub TextBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 8 Then
        Kontrol = True
    Else
        Kontrol = False
    End If
End Sub
 
Geri
Üst