text'te dört format

Katılım
1 Mart 2005
Mesajlar
71
selamlar
combobox içinde dört format harici başka bişey olamsın diyorum
format şekilleri : 2005/1 , 2005/11 , 2005/111 , 2005/1111 gibi 4 seçenek var diğer fomatta girilirse olay bitsin
Private Sub ComboBox13_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If ComboBox13 = Format(ComboBox13, "####,/,###") Then
ElseIf ComboBox13 = Format(ComboBox13, "####,/,##") Then
TextBox12 = ComboBox13
Else
msgbox "hata"
ComboBox13.Value = ""
Exit Sub
End If
End Sub
gibi değişik yöntemler denedimama ama olmuyor
 

Levent Menteşoğlu

Administrator
Yönetici
Admin
Katılım
13 Ekim 2004
Mesajlar
16,057
Excel Vers. ve Dili
Excel 2010-32 bit-Türkçe
Excel 365 -32 bit-Türkçe
Veri yazdığınızın combobox değilde textbox olduğunu kabul ettim. Aşağıdaki kodu deneyin. Bu kodda textboxtan çıkarken değerlendirme yapılır ve sizin formatlara uymuyorsa mesaj verilerek textboxtaki veri silinir.
[vb:1:3a057cd908]Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Mid(TextBox1.Value, 5, 1) <> "/" Or Len(TextBox1.Value) < 6 Or Len(TextBox1.Value) > 9 Then
MsgBox ("HATALI VERİ GİRİÞİ")
TextBox1 = ""
Exit Sub
End If
End Sub[/vb:1:3a057cd908]
 

Haluk

Özel Üye
Katılım
7 Temmuz 2004
Mesajlar
12,406
Excel Vers. ve Dili
64 Bit 2010 - İngilizce
+
Google Sheets
+
JScript
Altın Üyelik Bitiş Tarihi
Alternatif:

[vb:1:144aecd463]Private Sub ComboBox13_AfterUpdate()
If Not ComboBox13 Like "####/#" And _
Not ComboBox13 Like "####/##" And _
Not ComboBox13 Like "####/###" And _
Not ComboBox13 Like "####/####" Then
MsgBox "Hata...!"
ComboBox13 = Empty
TextBox12 = Empty
Else
TextBox12 = ComboBox13
End If
End Sub
[/vb:1:144aecd463]
 
Üst