excel input mask for textbox

  • Thread starter Thread starter DaveF
  • Start date Start date
D

DaveF

can anyone help me on this textbox issue:

Private Sub IBAN1_AfterUpdate()

IBAN1.Text = Format(IBAN1.Value, "#### #### #### #### #### ####
#### #### ##")

End Sub


when the user enters numbers, the textbox is change the input.

example 1255 2222 3333 3666 5555 6666 99999 88888 88

1255 2222 3333 3666 0000 0000 0000 0000 00

any ideas
 
I'd use:

Option Explicit
Private Sub IBAN1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
With Me.IBAN1
If IsNumeric(.Value) Then
.Value = Format(CDec(.Value), _
"#### #### #### #### #### #### #### #### ##")
Else
Beep
Cancel = True 'don't let them leave the textbox.
End If
End With
End Sub

I switched to _BeforeUpdate, too.

If you have a Cancel button on your userform, make sure its .takefocusonclick is
false.
 
Thanks Dave,

One more question.

If I want to allow letters in place of number what would I do?

Example

GB23 4445 6666 7777 LD94 4994 44

Thanks in advance
 
I'd just parse it out using a bunch of left's, mid's, right's.
& mid(.value,5,4) & " " _
& mid(.value,9,4) & " " _
'etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Input Mask Help 1
Entering Credit Card Numbers 3
EXCELL 2002 Glitch???? 1
Input mask for date! 0
Format text box with check box 1
Input Mask For Phone Number 4
input mask for phone number 2
Input Mask Question 14

Back
Top