• DİKKAT

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

textbox a sadece saat formatında bilgi girilebilsin

Katılım
9 Ağustos 2009
Mesajlar
1
Excel Vers. ve Dili
excel 2003
iyi günler userform üzerinde sayı veya tarih girilebilmesini kontrol edbiliyoruz acaba textbox a "hh:mm" formatında bilgi girişini kontrol edebilirmiyiz.
yani 12:03 formatının haricinde diğer girişlere hata versin.
 
Bildiğim kadarı ile böyle bir fonksiyon yok.
Ama ben sizin için bir fonksiyon yaptım.
Bu fonksiyonu kullanacağınız dosyalarda boş bir standart modüle kopyalayınız.
O dosyada Bütün formlarda ve makrolarda kulanabilirsiniz.:cool:
Dosya ektedir.
Fonksiyon:
Kod:
Function saat(deg As String) As Boolean
If Len(deg) <> 5 Then
    saat = False: Exit Function: End If
If Mid(deg, 3, 1) <> ":" Then
    saat = False: Exit Function: End If
If Not IsNumeric(Left(deg, 2)) Then
    saat = False: Exit Function: End If
If Not IsNumeric(Right(deg, 2)) Then
    saat = False: Exit Function: End If
If CInt(Left(deg, 2)) <= 0 Or CInt(Left(deg, 2)) > 24 Then
    saat = False: Exit Function: End If
If CInt(Right(deg, 2)) <= 0 Or CInt(Right(deg, 2)) > 59 Then
    saat = False: Exit Function: End If
saat = True
End Function
Kullanımı:
Kod:
Private Sub CommandButton1_Click()
[B][COLOR="Red"]If Not saat(TextBox1.Text) Then[/COLOR][/B]
    MsgBox "Saat formatında veri girilmedi.", vbCritical, "UYARI"
    TextBox1.SetFocus
    TextBox1.SelStart = 0
    TextBox1.SelLength = Len(TextBox1.Text)
    Exit Sub
End If
MsgBox "Saat doğru yazılmış."
End Sub
 

Ekli dosyalar

Bu şekilde bir koduda kullanabilirsiniz.

Private Sub TextBox1_AfterUpdate()
Me.TextBox1 = Format(Me.TextBox1, "00:00")
End Sub
 
sayın evren gizlen ve seyit tiken iki çalışmada istediğim gibi ve sorunumu hallettim çok teşekkür ederim.sağolun
 
Bildiğim kadarı ile böyle bir fonksiyon yok.
Ama ben sizin için bir fonksiyon yaptım.
Bu fonksiyonu kullanacağınız dosyalarda boş bir standart modüle kopyalayınız.
O dosyada Bütün formlarda ve makrolarda kulanabilirsiniz.:cool:
Dosya ektedir.
Fonksiyon:
Kod:
Function saat(deg As String) As Boolean
If Len(deg) <> 5 Then
    saat = False: Exit Function: End If
If Mid(deg, 3, 1) <> ":" Then
    saat = False: Exit Function: End If
If Not IsNumeric(Left(deg, 2)) Then
    saat = False: Exit Function: End If
If Not IsNumeric(Right(deg, 2)) Then
    saat = False: Exit Function: End If
If CInt(Left(deg, 2)) <= 0 Or CInt(Left(deg, 2)) > 24 Then
    saat = False: Exit Function: End If
If CInt(Right(deg, 2)) <= 0 Or CInt(Right(deg, 2)) > 59 Then
    saat = False: Exit Function: End If
saat = True
End Function
Kullanımı:
Kod:
Private Sub CommandButton1_Click()
[B][COLOR="Red"]If Not saat(TextBox1.Text) Then[/COLOR][/B]
    MsgBox "Saat formatında veri girilmedi.", vbCritical, "UYARI"
    TextBox1.SetFocus
    TextBox1.SelStart = 0
    TextBox1.SelLength = Len(TextBox1.Text)
    Exit Sub
End If
MsgBox "Saat doğru yazılmış."
End Sub
Merhabalar,
Burada Textbox' a ilk iki değer girilince otomatik olarak ":" yazılması sağlanamaz mı?

12 yazınca 12: olsun
01 yazınca 01: olsun
9 yazınca 09: olsun

Textbox' un içeriğinin her zaman "00:00" formatında olmasını sağlamaya çalışıyorum

teşekkürler, iyi Çalışmalar.
 
Geri
Üst