Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Create a mask inside a textbox


Is there a way to create a mask inside a textbox? I have a form, tha
will require a Federal Tax ID to be entered in the textbox. And I nee
it to always have the format of XX-XXXXXXX where X can only be a numbe
0 through 9...any suggestions?

--
dok11
-----------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058
View this thread: http://www.excelforum.com/showthread.php?threadid=46834

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Create a mask inside a textbox

Not really.

But maybe you could just allow numbers and then format it when the user leaves
the textbox.

Option Explicit
Private Sub TextBox1_AfterUpdate()
With Me.TextBox1
.Value = Format(.Value, "00-0000000")
End With
End Sub
Private Sub TextBox1_KeyPress(ByVal keyascii As MSForms.ReturnInteger)
Dim OKChar As Boolean
OKChar = True
If Len(Me.TextBox1.Value) = 9 Then
OKChar = False
Else
Select Case keyascii
Case Asc("0") To Asc("9")
'ok
Case Else
OKChar = False
End Select
End If

If OKChar = False Then
keyascii = 0
Beep
End If
End Sub





dok112 wrote:

Is there a way to create a mask inside a textbox? I have a form, that
will require a Federal Tax ID to be entered in the textbox. And I need
it to always have the format of XX-XXXXXXX where X can only be a number
0 through 9...any suggestions??

--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=468341


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel input mask for textbox DaveF[_2_] Excel Discussion (Misc queries) 3 February 20th 08 04:25 PM
Need A date Mask format for a Textbox on UserForm [email protected] Excel Discussion (Misc queries) 2 November 4th 07 03:27 AM
create a text mask bryanp354 Excel Discussion (Misc queries) 3 July 26th 06 06:29 PM
Input for TextBox having a mask for date or $ amount jlroper[_4_] Excel Programming 2 September 25th 05 03:17 PM
Input mask for userform textbox Axehandler Excel Programming 1 November 6th 04 04:56 AM


All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"