Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Move the cursor to end of data in textbox

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 ??

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Move the cursor to end of data in textbox


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
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Sir Tom"
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 ??

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Move the cursor to end of data in textbox

Thanks Jim, that fixed it.
It's the little things that get you.

"Jim Cone" wrote:


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
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Sir Tom"
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 ??


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
Move cursor one cell to the right after entering data PLGGP Excel Discussion (Misc queries) 2 June 3rd 08 10:14 PM
move cursor after inputting data without using enter key [email protected] New Users to Excel 2 June 13th 07 02:25 PM
Move cursor to textbox in a userform jgmiddel[_4_] Excel Programming 5 March 29th 06 02:55 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
How to move cursor from one textbox control to another textbox con KMoore007 Excel Programming 0 September 16th 04 02:47 PM


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