Skip to main content

AccessTr.neT


Textbox Biçim Ayarları

tarkanaykın
tarkanaykın
6
479

Textbox Biçim Ayarları

#5
Sayın @tarkanaykın

Değerli Hocalarım @berduş ve @atoykan ın yönlendirmeleri ile Microsoft Access ve Excel eğitimlerime devam ediyorum. Onlar kadar bilgili olmasamda daha önce sorunuza benzer bir araştırma yapmıştım. Excel formlarında giriş maskesi kullanılabilir mi, nasıl uygulanır araştırırken aşağıdaki örnek kodu buldum ve kullandım. Sizin de işinize yaramasını dilerim. 

Kod:
Dim NewString, MyString, mask As String
Dim position, pos As Variant



Private Sub TextBox1_Change()
If IsNumeric(Right(TextBox1.Text, 2)) And Len(TextBox1.Text) >= 11 Then
    TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
Else
    position = TextBox1.SelStart
    MyString = TextBox1.Text
    pos = InStr(1, MyString, "_")
If pos > 0 Then
    NewString = Left(MyString, pos - 1)
Else
    NewString = MyString
End If
If Len(NewString) < 11 Then
    TextBox1.Text = NewString & Right(mask, Len(mask) - Len(NewString))
    TextBox1.SelStart = Len(NewString)
End If
End If
If Len(TextBox1.Text) >= 11 Then
    TextBox1.Text = Left(TextBox1.Text, 10)
End If


End Sub

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim strDate As String
strDate = Me.TextBox1
If IsDate(strDate) Then
    strDate = Format(CDate(strDate), "DD/MM/YYYY")
    MsgBox strDate
  Else
    MsgBox "Wrong date format"
  End If
End Sub

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
position = TextBox1.SelStart
If KeyCode = 8 Then
    TextBox1.Text = mask
End If
End Sub
Private Sub UserForm_Initialize()
TextBox1.SelStart = 0
mask = "__/__/____"
TextBox1.Text = mask
End Sub

İyi çalışmalar diler, saygılar sunarım.

Murtaza AF
Son Düzenleme: 16/06/2022, 13:00, Düzenleyen: MURTAZAAF. (Sebep: imla hatalarını düzeltmek)
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
Textbox Biçim Ayarları - Yazar: tarkanaykın - 15/06/2022, 16:10
RE: Textbox Biçim Ayarları - Yazar: berduş - 15/06/2022, 16:14
RE: Textbox Biçim Ayarları - Yazar: tarkanaykın - 15/06/2022, 20:52
RE: Textbox Biçim Ayarları - Yazar: berduş - 15/06/2022, 21:34
RE: Textbox Biçim Ayarları - Yazar: MURTAZAAF - 16/06/2022, 12:59
RE: Textbox Biçim Ayarları - Yazar: berduş - 16/06/2022, 14:08
RE: Textbox Biçim Ayarları - Yazar: tarkanaykın - 20/06/2022, 22:34
Task