Hi, I need a little help here, I am learning Vb, and have a texbox that needs to be highlighted but at allcost, that means that no matter what key I press (left arrow, right arrow, etc.) and it continues to be highlighted
I already have tried this
ctl.SelStart = 0
ctl.SelLength = Len(ctl.Text)
and it works fine, but when I press the right arrow or left arrow it de-selects the textbox.
I am sorry if this is a lame question, but it's a validation that I need to acomplish before the review of the project.
Anyidea is more than welcome. THNX!
Comments
: I already have tried this
: ctl.SelStart = 0
: ctl.SelLength = Len(ctl.Text)
: and it works fine, but when I press the right arrow or left arrow it de-selects the textbox.
: I am sorry if this is a lame question, but it's a validation that I need to acomplish before the review of the project.
:
: Anyidea is more than welcome. THNX!
:
although I don't understand why you want to do that, I think I have a solution that will work
your code is good, but it's probably in the wrong event. i'm betting you've tried keypress, change, and keydown. but when you press the left or right arrow it unselects the text after the keypress event. so instead try putting your code in the KeyUp event instead. I tried it in vb6 and it seemed to work fine.
: I already have tried this
: ctl.SelStart = 0
: ctl.SelLength = Len(ctl.Text)
: and it works fine, but when I press the right arrow or left arrow it de-selects the textbox.
: I am sorry if this is a lame question, but it's a validation that I need to acomplish before the review of the project.
:
: Anyidea is more than welcome. THNX!
:
Play with code like following and you will see how it works
[code]
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then 'Left button pressed Button = 2 - Right button pressed
Me.Text1.SelStart = 0
Me.Text1.SelLength = 0
End If
End Sub
Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Text1.SelStart = 0
Me.Text1.SelLength = Len(Me.Text1.Text)
End Sub
[/code]