Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Form Text Box

How do i get a text box on a form to only allow a certain way to fill the box
in. Such as a text box for a phone number and I want the input to be limited
to look like the following:

(555)555-5555
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Form Text Box

This works in a worksheet range:

Sub Numbfmt()
Range("C3").NumberFormat = "(###)###-###0"
End Sub

"krc547" wrote:

How do i get a text box on a form to only allow a certain way to fill the box
in. Such as a text box for a phone number and I want the input to be limited
to look like the following:

(555)555-5555

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Form Text Box

untested but something like this may work:

Private Sub TextBox1_Change()
If IsNumeric(TextBox1.Text) Then
If Len(TextBox1.Text) = 10 Then
mynum = Format(TextBox1.Text, "(###)###-###0")
TextBox1.Text = mynum
End If
End If
End Sub
--
JB


"krc547" wrote:

How do i get a text box on a form to only allow a certain way to fill the box
in. Such as a text box for a phone number and I want the input to be limited
to look like the following:

(555)555-5555

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
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
2 criteria lookup of text. Return text form column 3. SUMPRODUCT t zzxxcc Excel Worksheet Functions 2 August 26th 08 11:04 PM
DATE IN TEXT FORM - NEED TO CHANGE IT DATE FORM SSJ New Users to Excel 3 October 27th 06 08:34 PM
Formatting text in a user form text box DB Excel Programming 0 July 23rd 05 08:09 PM
VBA - Form Text box value Linda Excel Programming 1 December 4th 03 06:56 PM


All times are GMT +1. The time now is 05:09 AM.

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"