AccessTr.neT
Vba Da Texbox Sadece Saat Değerleri - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Excel (https://accesstr.net/forum-microsoft-excel.html)
+--- Forum: Excel Cevaplanmış Soruları (https://accesstr.net/forum-excel-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Vba Da Texbox Sadece Saat Değerleri (/konu-vba-da-texbox-sadece-saat-degerleri.html)

Sayfalar: 1 2


Vba Da Texbox Sadece Saat Değerleri - merttr07 - 22/08/2020

Vba da sadece texbox saat değeri girilmesini istiyorum ve bunu sınırlamak istiyorum. Yanlış bir giriş olduğunda uyarı almasını istiyorum nasıl sağlaya bilirim.


RE: Vba Da Texbox Sadece Saat Değerleri - merttr07 - 22/08/2020

Dk içinde ayrı yapmak istiyorum sadece dk girilsin.


RE: Vba Da Texbox Sadece Saat Değerleri - berduş - 23/08/2020

saat kutusunun adı: TxtSaat
dakika kutusunun adı:TxtDk
Private Sub TxtDk_Change()
If Len(TxtDk.Text) = 0 Then Exit Sub
If Left(Me.TxtDk.Text, 1) > 5 Then
    TxtDk.SelStart = 0
    TxtDk.SelLength = 1
End If
If Me.TxtDk.Text > 59 Then
    TxtDk.SelStart = 0
    TxtDk.SelLength = 1
End If
End Sub

Private Sub TxtDk_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next

If Not IsNumeric(Chr(KeyAscii)) Or _
                (Len(Me.ActiveControl.Text) >= 2 And _
                ActiveControl.SelLength = 0) Then KeyAscii = 0

End Sub

Private Sub TxtSaat_Change()
If Len(TxtSaat.Text) = 0 Then Exit Sub
If Left(Me.TxtSaat.Text, 1) > 2 Then
    TxtSaat.SelStart = 0
    TxtSaat.SelLength = 1
End If
If Me.TxtSaat.Text > 23 And Me.TxtSaat.Text < 30 Then
    TxtSaat.SelStart = 1
    TxtSaat.SelLength = 1
ElseIf Me.TxtSaat.Text > 29 Then
    TxtSaat.SelStart = 0
    TxtSaat.SelLength = 2
End If

End Sub

Private Sub TxtSaat_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next

If Not IsNumeric(Chr(KeyAscii)) Or _
                (Len(Me.ActiveControl.Text) >= 2 And _
                ActiveControl.SelLength = 0) Then KeyAscii = 0

End Sub

çıkıldıgında olayı yapılmamıştır


RE: Vba Da Texbox Sadece Saat Değerleri - feraz - 23/08/2020

Örnek dosya ekler misiniz?
Normalde like ve format ile yapılabilir dosyayı görmek gerek.


RE: Vba Da Texbox Sadece Saat Değerleri - merttr07 - 23/08/2020

(23/08/2020, 00:48)berduş yazdı: saat kutusunun adı: TxtSaat
dakika kutusunun adı:TxtDk
Private Sub TxtDk_Change()
If Len(TxtDk.Text) = 0 Then Exit Sub
If Left(Me.TxtDk.Text, 1) > 5 Then
    TxtDk.SelStart = 0
    TxtDk.SelLength = 1
End If
If Me.TxtDk.Text > 59 Then
    TxtDk.SelStart = 0
    TxtDk.SelLength = 1
End If
End Sub

Private Sub TxtDk_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next

If Not IsNumeric(Chr(KeyAscii)) Or _
                (Len(Me.ActiveControl.Text) >= 2 And _
                ActiveControl.SelLength = 0) Then KeyAscii = 0

End Sub

Private Sub TxtSaat_Change()
If Len(TxtSaat.Text) = 0 Then Exit Sub
If Left(Me.TxtSaat.Text, 1) > 2 Then
    TxtSaat.SelStart = 0
    TxtSaat.SelLength = 1
End If
If Me.TxtSaat.Text > 23 And Me.TxtSaat.Text < 30 Then
    TxtSaat.SelStart = 1
    TxtSaat.SelLength = 1
ElseIf Me.TxtSaat.Text > 29 Then
    TxtSaat.SelStart = 0
    TxtSaat.SelLength = 2
End If

End Sub

Private Sub TxtSaat_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next

If Not IsNumeric(Chr(KeyAscii)) Or _
                (Len(Me.ActiveControl.Text) >= 2 And _
                ActiveControl.SelLength = 0) Then KeyAscii = 0

End Sub

çıkıldıgında olayı yapılmamıştır

Ne Yazıkki Hata Alıyorum Saat Bilgisi Girilecek Yer Tek bir Tex Boz değil.



RE: Vba Da Texbox Sadece Saat Değerleri - berduş - 23/08/2020

Ornek çalışmanız yok söylediğiniz tek şey de metin kutusuna sadece saat girileceği ve aynı şeyin dakika alanı için de geçerli olduğu bu bilgiler ışığında denemelerimde her hangi bir soruna raslamadım. Sizde nasıl bir sorun cıktı?

Uyari ekleme kısmi metin kutularından çıkıldığında olayına eklenebilir. Çıkıldığında olayına saat için eğer 23ten büyükse uyarı verip metin kutusuna dönme kodu eklenebilir.