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 / January 2007

Tip: Looking for answers? Try searching our database.

Move the cursor to end of data in textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sir Tom - 25 Jan 2007 22:21 GMT
I'm using Excel 2000 and creating some user forms.
The form has a phone number textbox that I have added code to vailidate the
phone and put it in a certian format (xxx)xxx-xxxx)
I have set textbox on Enter event to write  "(" before the user start typnig
the phone number.
If you click into the textbox the cursor moves to end okay.
If you tab into the textbox in highligthts the ( and when the user starts
typing it erases the ( .

Private Sub tbGBPhone_Enter()
   Dim Somedata
  ' If Phone not correct length
   If Len(tbGBPhone.Value) > 13 Or Len(tbGBPhone.Value) < 13 Then

       tbGBPhone.Value = "("
   End If
End Sub

I have tried SelLength or SelStart properties, but that didn't work.

How do I make the cursor advance to the end ??
Jim Cone - 26 Jan 2007 01:30 GMT
You have to change the EnterFieldBehavior to 1 to get things
to cooperate.  This seems to work...

Private Sub TextBox1_Enter()
If Len(TextBox1.Text) <> 13 Then
  TextBox1.Text = "("
  TextBox1.SelStart = 1
  TextBox1.SelLength = 0
Else
  TextBox1.SelStart = 0
  TextBox1.SelLength = Len(TextBox1.Text)
End If
End Sub
Signature

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

"Sir Tom" <SirTom@discussions.microsoft.com>
wrote in message
I'm using Excel 2000 and creating some user forms.
The form has a phone number textbox that I have added code to vailidate the
phone and put it in a certian format (xxx)xxx-xxxx)
I have set textbox on Enter event to write  "(" before the user start typnig
the phone number.
If you click into the textbox the cursor moves to end okay.
If you tab into the textbox in highligthts the ( and when the user starts
typing it erases the ( .

Private Sub tbGBPhone_Enter()
   Dim Somedata
  ' If Phone not correct length
   If Len(tbGBPhone.Value) > 13 Or Len(tbGBPhone.Value) < 13 Then

       tbGBPhone.Value = "("
   End If
End Sub

I have tried SelLength or SelStart properties, but that didn't work.
How do I make the cursor advance to the end ??

Sir Tom - 26 Jan 2007 03:51 GMT
Thanks Jim, that fixed it.
It's the little things that get you.

> You have to change the EnterFieldBehavior to 1 to get things
> to cooperate.  This seems to work...
[quoted text clipped - 9 lines]
> End If
> End Sub
 
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.