randika100100
Registered User.
- Local time
- Tomorrow, 03:40
- Joined
- Aug 31, 2011
- Messages
- 11
Hi All!
I have a live search in my form and searchtxt is the text box that users insert values to search.But in the process textbox looses focus and to get the focus and to set the cursor to the end of the already entered text I put
It worked properly. But now I want to be able to identify if user has pressed space then add a space to the end of the text box so I put the following code in the KeyDown event
But it doesn't work the way I want. Instead of adding a space to the end of the text, it adds a space to the beginning of the text . I tried few different things and non of them worked.
Can someone help me? Thanks in advance.
I have a live search in my form and searchtxt is the text box that users insert values to search.But in the process textbox looses focus and to get the focus and to set the cursor to the end of the already entered text I put
Me.searchtxt.SetFocus
Me.searchtxt.SelStart = Me.searchtxt.SelLength
It worked properly. But now I want to be able to identify if user has pressed space then add a space to the end of the text box so I put the following code in the KeyDown event
If keycode = 32 Then
Me.searchtxt.SetFocus
Me.searchtxt.Text = searchtxt.Text & " "
Me.searchtxt.SelStart = Me.searchtxt.SelLength
Else
Me.searchtxt.SetFocus
Me.searchtxt.SelStart = Me.searchtxt.SelLength
End If
But it doesn't work the way I want. Instead of adding a space to the end of the text, it adds a space to the beginning of the text . I tried few different things and non of them worked.

Can someone help me? Thanks in advance.