Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Highlight Text In A Textbox

Hi I was wondering if someone can help I am trying to highlight text in a
textbox if the user miss scan an item into a textbox, I am using the code
below but I can't get it to work any help would much apprecated.
Regards
Charles

Private Sub txtVin_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'
If KeyCode = 13 Then
If Len(txtVin.Value) = 17 Then
Call Vinchk
Else
MsgBox "Sorry there are not enough character,Please re-scan the
Vin."
With txtVin
.SetFocus
.SelStart = 0
.SelLength = Len(.Text) 'I have also tried .TextLength
End With
End If
End If
Call bntEnabled
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Highlight Text In A Textbox

What does the "Call bntEnabled" statement do? I'm guessing that it is
probably setting focus to another control. You can overcome this problem by
changing the TextBox's HideSelection property to False; then it will still
show the selected text even if some other control has focus.

--
Rick (MVP - Excel)


"vqthomf" wrote in message
...
Hi I was wondering if someone can help I am trying to highlight text in a
textbox if the user miss scan an item into a textbox, I am using the code
below but I can't get it to work any help would much apprecated.
Regards
Charles

Private Sub txtVin_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'
If KeyCode = 13 Then
If Len(txtVin.Value) = 17 Then
Call Vinchk
Else
MsgBox "Sorry there are not enough character,Please re-scan the
Vin."
With txtVin
.SetFocus
.SelStart = 0
.SelLength = Len(.Text) 'I have also tried .TextLength
End With
End If
End If
Call bntEnabled
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Highlight Text In A Textbox

Thank that worked, I do one other problem when the item is scanned I
sometimes get $/ is there away to check each character to do the same as
below?

"Rick Rothstein" wrote:

What does the "Call bntEnabled" statement do? I'm guessing that it is
probably setting focus to another control. You can overcome this problem by
changing the TextBox's HideSelection property to False; then it will still
show the selected text even if some other control has focus.

--
Rick (MVP - Excel)


"vqthomf" wrote in message
...
Hi I was wondering if someone can help I am trying to highlight text in a
textbox if the user miss scan an item into a textbox, I am using the code
below but I can't get it to work any help would much apprecated.
Regards
Charles

Private Sub txtVin_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'
If KeyCode = 13 Then
If Len(txtVin.Value) = 17 Then
Call Vinchk
Else
MsgBox "Sorry there are not enough character,Please re-scan the
Vin."
With txtVin
.SetFocus
.SelStart = 0
.SelLength = Len(.Text) 'I have also tried .TextLength
End With
End If
End If
Call bntEnabled
End Sub


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Highlight Text In A Textbox

Try with the Exit event..

Private Sub txtVin_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(txtVin.Value) = 17 Then
'Call Vinchk
Else
With txtVin
.SelStart = 0
.SelLength = Len(.Text)
End With
MsgBox "Sorry there are not enough character,Please re-scan the Vin."
Cancel = True
End If
'Call bntEnabled
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"vqthomf" wrote:

Hi I was wondering if someone can help I am trying to highlight text in a
textbox if the user miss scan an item into a textbox, I am using the code
below but I can't get it to work any help would much apprecated.
Regards
Charles

Private Sub txtVin_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'
If KeyCode = 13 Then
If Len(txtVin.Value) = 17 Then
Call Vinchk
Else
MsgBox "Sorry there are not enough character,Please re-scan the
Vin."
With txtVin
.SetFocus
.SelStart = 0
.SelLength = Len(.Text) 'I have also tried .TextLength
End With
End If
End If
Call bntEnabled
End Sub

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
Highlight text in textbox Erik Excel Programming 2 October 17th 08 02:26 PM
Highlight text in Textbox jnf40 Excel Programming 3 January 2nd 08 10:53 PM
Highlight the contain of textbox and radio button Peter Cheang Excel Programming 0 August 11th 06 04:50 PM
highlight text in userform textbox RB Smissaert Excel Programming 1 November 2nd 05 11:44 PM
Highlight all Text in a Textbox when the textbox is selected RPIJG[_73_] Excel Programming 3 October 28th 05 08:28 PM


All times are GMT +1. The time now is 09:16 PM.

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"