• DİKKAT

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

Tarih ve telefon maskesi

Güzel çalışma, module1 aşağıdaki şekilde de düzenlenebilir.

C#:
Public Function Format_Telefon(Kutu As MSForms.TextBox)
    Dim Nmr As String
    Dim list() As String
    
    Nmr = Kutu
        
    On Error Resume Next
    Nmr = Replace(Replace(Replace(Replace(Replace(Nmr, "(", ""), ")", ""), "_", ""), ".", ""), " ", "")
    list = Split(StrConv(Nmr, vbUnicode), Chr$(0))
    ReDim Preserve list(UBound(list) - 1)
    
    Nmr = "(___) ___ __ __"
    Nmr = "(" & list(0) & "__)" & " ___ __ __"
    Nmr = "(" & list(0) & list(1) & "_)" & " ___ __ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ")" & " ___ __ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & "__ __ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & "_ __ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & list(5) & " __ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & list(5) & " " & list(6) & "_ __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & list(5) & " " & list(6) & list(7) & " __"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & list(5) & " " & list(6) & list(7) & " " & list(8) & "_"
    Nmr = "(" & list(0) & list(1) & list(2) & ") " & list(3) & list(4) & list(5) & " " & list(6) & list(7) & " " & list(8) & list(9)
    
    Kutu = Nmr
    For i = 1 To Len(Kutu)
      If IsNumeric(Mid(Kutu, i, 1)) = True Then
      Kutu.SelStart = i
      End If
    Next
    On Error GoTo 0
    
End Function

Public Function Format_Tarih(Kutu As MSForms.TextBox)
    Dim list() As String
    Dim Nmr As String
    
    Nmr = Kutu
        
    On Error Resume Next
    Nmr = Replace(Replace(Nmr, "-", ""), ".", "")
    list = Split(StrConv(Nmr, vbUnicode), Chr$(0))
    ReDim Preserve list(UBound(list) - 1)
    
    Nmr = "--.--.----"
    Nmr = list(0) & "-.--.----"
    Nmr = list(0) & list(1) & ".--.----"
    Nmr = list(0) & list(1) & "." & list(2) & "--.----"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & "-.----"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & list(4) & ".----"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & list(4) & "." & list(5) & "---"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & list(4) & "." & list(5) & list(6) & "--"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & list(4) & "." & list(5) & list(6) & list(7) & "-"
    Nmr = list(0) & list(1) & "." & list(2) & list(3) & list(4) & "." & list(5) & list(6) & list(7) & list(8)
        
    Kutu = Nmr
    For i = 1 To Len(Kutu)
      If IsNumeric(Mid(Kutu, i, 1)) = True Then
      Kutu.SelStart = i
      End If
    Next
    On Error GoTo 0
End Function
 
Paylaşımınız için teşekkürler.

Yıllar önce @Haluk beyin benzer bir paylaşımı vardı. Hatırlatmak amacıyla linki paylaşıyorum.

 
Geri
Üst