Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default On entering a textbox problem ??

Hi;

I have a textbox on a Userform for phone numbers. I want to have the most
likely area code placed in the textbox. I don't want to use a listbox. I
have:

Private Sub HomePhNTxt28_Enter()

HomePhNTxt28 = "(613)"

End Sub

When the user tabs into the Textbox the area code is selected (blue
background)and the cursor is at the end of the '(613)' text -- which is what
I want. However when any key is pressed the '(613)' text is deleted --
including pressing the spacebar. I would like to set it up so that deletion
is the result of pressing anything *except* the spacebar.

Pressing the spacebar should only insert a space and then wait for the user
to input the rest of the phone number.

I am afraid that key manipulation is new to me; I can't even thing of how to
properly pose the question on google etc.

Regards Bill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default On entering a textbox problem ??

Add this code

Private Sub HomePhNTxt28_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 32 Then
HomePhNTxt28.Text = HomePhNTxt28.Text & " "
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bill Case" wrote in message
...
Hi;

I have a textbox on a Userform for phone numbers. I want to have the most
likely area code placed in the textbox. I don't want to use a listbox. I
have:

Private Sub HomePhNTxt28_Enter()

HomePhNTxt28 = "(613)"

End Sub

When the user tabs into the Textbox the area code is selected (blue
background)and the cursor is at the end of the '(613)' text -- which is

what
I want. However when any key is pressed the '(613)' text is deleted --
including pressing the spacebar. I would like to set it up so that

deletion
is the result of pressing anything *except* the spacebar.

Pressing the spacebar should only insert a space and then wait for the

user
to input the rest of the phone number.

I am afraid that key manipulation is new to me; I can't even thing of how

to
properly pose the question on google etc.

Regards Bill



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default On entering a textbox problem ??


Thanks Bob:

I give myself a big headsap this morning when I read your answer. "I knew
that." The perils of working late at night!!

Regards Bill

"Bob Phillips" wrote:

Add this code

Private Sub HomePhNTxt28_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 32 Then
HomePhNTxt28.Text = HomePhNTxt28.Text & " "
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bill Case" wrote in message
...
Hi;

I have a textbox on a Userform for phone numbers. I want to have the most
likely area code placed in the textbox. I don't want to use a listbox. I
have:

Private Sub HomePhNTxt28_Enter()

HomePhNTxt28 = "(613)"

End Sub

When the user tabs into the Textbox the area code is selected (blue
background)and the cursor is at the end of the '(613)' text -- which is

what
I want. However when any key is pressed the '(613)' text is deleted --
including pressing the spacebar. I would like to set it up so that

deletion
is the result of pressing anything *except* the spacebar.

Pressing the spacebar should only insert a space and then wait for the

user
to input the rest of the phone number.

I am afraid that key manipulation is new to me; I can't even thing of how

to
properly pose the question on google etc.

Regards Bill




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
Problem entering numbers Martyn Tindall Excel Worksheet Functions 3 January 9th 09 09:48 PM
Problem entering amounts Sky Excel Discussion (Misc queries) 1 October 14th 06 09:09 AM
userform to search by entering data into a textbox Moh Excel Programming 3 September 13th 06 02:01 PM
Entering a date in a textbox johncassell[_7_] Excel Programming 3 July 25th 05 02:56 PM
Selecting or Entering a Textbox Todd Huttenstine[_2_] Excel Programming 2 January 19th 04 06:09 PM


All times are GMT +1. The time now is 08:45 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"