Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default TextBox focus 4

I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default TextBox focus 4

How about this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
TextBox1.SetFocus
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default TextBox focus 4

Thanks. This appears to work. Will test it totally on Monday.
What does the 'KeyCode = 0' statement do?

"RB Smissaert" wrote in message
...
How about this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
TextBox1.SetFocus
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default TextBox focus 4

It just resets the Keycode to zero.
So the normal result of the enter key won't happen.
Actually you don't need to set the focus as you are already in the textbox.
So this will do the same:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
Thanks. This appears to work. Will test it totally on Monday.
What does the 'KeyCode = 0' statement do?

"RB Smissaert" wrote in message
...
How about this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
TextBox1.SetFocus
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default TextBox focus 4 - Thanks for all your help. I think I've got it now.

Thanks for all your help. I think I've got it now.

"RB Smissaert" wrote in message
...
It just resets the Keycode to zero.
So the normal result of the enter key won't happen.
Actually you don't need to set the focus as you are already in the

textbox.
So this will do the same:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
Thanks. This appears to work. Will test it totally on Monday.
What does the 'KeyCode = 0' statement do?

"RB Smissaert" wrote in message
...
How about this:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then
MsgBox "doing processing here"
TextBox1.SetFocus
KeyCode = 0
End If

End Sub


RBS


"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default TextBox focus 4

Tim,

Use the change event

Private Sub OptionButton1_Change()
TextBox1.SetFocus
End Sub

Private Sub OptionButton2_Change()
TextBox1.SetFocus
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default TextBox focus 4

_Change() isn't fired after <cr in a text box.
Tried it in _Enter(), but then, you can't change the option buttons.
I'll try RB Smissaert's solution Monday, but am aprehesive about
its ability to work..

"Bob Phillips" wrote in message
...
Tim,

Use the change event

Private Sub OptionButton1_Change()
TextBox1.SetFocus
End Sub

Private Sub OptionButton2_Change()
TextBox1.SetFocus
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...

Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub

Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.

Can someone tell me what is happening and how to solve it??

PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????






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
textbox focus Arne Excel Programming 1 June 15th 04 10:44 AM
TextBox Focus Tom Ogilvy Excel Programming 0 June 3rd 04 05:58 PM
TextBox Focus Tom Ogilvy Excel Programming 0 June 3rd 04 04:55 PM
TextBox focus Tom Ogilvy Excel Programming 0 June 3rd 04 03:17 PM
TextBox Focus John Wilson Excel Programming 6 January 16th 04 09:59 PM


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