Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2006

Tip: Looking for answers? Try searching our database.

On entering a textbox problem ??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Case - 26 Sep 2006 07:07 GMT
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
Bob Phillips - 26 Sep 2006 08:10 GMT
Add this code

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

Signature

HTH

Bob Phillips

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

> Hi;
>
[quoted text clipped - 21 lines]
>
> Regards Bill
Bill Case - 26 Sep 2006 17:37 GMT
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

> Add this code
>
[quoted text clipped - 33 lines]
> >
> > Regards Bill
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.