Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default question for Ron de Bruin

I'm using the code you previously provided on formatting a
textbox in a form. In my macro, a form displays a
textbox, radio buttons, and push buttons. The textbox is
populated with a phone number. Sometimes the user will
keep the existing number (which is already formatted) and
sometimes they will change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like it
does now. Any suggestions on how we can do this? Thanks
for all of the help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default question for Ron de Bruin

Hi JT

Try this then

It will only allow digits 0 thru 9

Private Sub TextBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim i As Integer
If KeyAscii < 48 Or KeyAscii 57 Then
' only allow digits 0 thru 9
KeyAscii = 0
End If
End Sub

Private Sub TextBox3_Exit(ByVal cancel As MSForms.ReturnBoolean)
If Len(TextBox3) = 0 Then Exit Sub
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JT" wrote in message ...
I'm using the code you previously provided on formatting a
textbox in a form. In my macro, a form displays a
textbox, radio buttons, and push buttons. The textbox is
populated with a phone number. Sometimes the user will
keep the existing number (which is already formatted) and
sometimes they will change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like it
does now. Any suggestions on how we can do this? Thanks
for all of the help.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default question for Ron de Bruin

Ron........Thanks a bunch. That is exactly what I was
looking for.....JT
-----Original Message-----
Hi JT

Try this then

It will only allow digits 0 thru 9

Private Sub TextBox3_KeyPress(ByVal KeyAscii As

MSForms.ReturnInteger)
Dim i As Integer
If KeyAscii < 48 Or KeyAscii 57 Then
' only allow digits 0 thru 9
KeyAscii = 0
End If
End Sub

Private Sub TextBox3_Exit(ByVal cancel As

MSForms.ReturnBoolean)
If Len(TextBox3) = 0 Then Exit Sub
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"JT" wrote in

message ...
I'm using the code you previously provided on

formatting a
textbox in a form. In my macro, a form displays a
textbox, radio buttons, and push buttons. The textbox

is
populated with a phone number. Sometimes the user will
keep the existing number (which is already formatted)

and
sometimes they will change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key

in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like

it
does now. Any suggestions on how we can do this?

Thanks
for all of the help.




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default question for Ron de Bruin

See another option at your other post.



JT wrote:

I'm using the code you previously provided on formatting a
textbox in a form. In my macro, a form displays a
textbox, radio buttons, and push buttons. The textbox is
populated with a phone number. Sometimes the user will
keep the existing number (which is already formatted) and
sometimes they will change it.

I use the following code to format the textbox:

Private Sub TextBox3_Exit(ByVal cancel As
MSForms.ReturnBoolean)

If Not IsNumeric(TextBox3) Or Len(TextBox3) 10 Then
cancel = True
Me.TextBox3.Text = Format(TextBox3, "000-000-0000")

End Sub

I would like the users to be able to tab through the
form. The problem is they can tab through it until they
get to the text box. The tab is locked until they key in
a phone number.

What I would like to do is let the user tab through the
phone number if they keep the existing number and not
change it. If they change it and keep in 10 new number,
then it should be formatted automatically for them like it
does now. Any suggestions on how we can do this? Thanks
for all of the help.


--

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
question for Ron de Bruin on importing JohnE Excel Discussion (Misc queries) 2 August 23rd 07 01:52 AM
For Ron Bruin Please Steved Excel Worksheet Functions 6 April 6th 05 02:19 AM
Email Question (Ron De Bruin related) Lobo[_2_] Excel Programming 5 March 1st 04 02:01 PM
for Ron de Bruin Valeria[_2_] Excel Programming 1 January 22nd 04 04:42 PM
A Question for Ron de Bruin Jamal[_2_] Excel Programming 3 January 9th 04 04:12 PM


All times are GMT +1. The time now is 04:32 AM.

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

About Us

"It's about Microsoft Excel"