• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Credit card format in userform textbox

Hi try
Code:
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Textbox1.Value = format(textbox1.value,"0000-0000-0000")
End Sub
or
Code:
Private Sub TextBox1_Change()
If Len(TextBox1.Value) = 4 Then TextBox1.Value = TextBox1.Value & Chr(45)
If Len(TextBox1.Value) = 8 Then TextBox1.Value = TextBox1.Value & Chr(45)
TextBox1.MaxLength = 14
End Sub
 
Are you needing pattern for only specific credit card? Each card type/issuing network will have different spacing pattern and IIN range (Issuer Identification Number). Though most popular pattern is 16 char length 4-4-4-4

Ex:
Visa, length 13-19, IIN Range always starts with 4, pattern 4-4-4-4 (pattern not known for 13-15 & 17-19 digit card)

Amex, length 15, IIN Range 34, 37, pattern 4-6-5

etc.
 
Back
Top