I have a textbox used for writing out a sql string to query a MS SQL Server 7.0 database.

Above this textbox I have a serious of buttons with images of the logical operators to be used for compariosons.

When the user clicks one of these buttons that operator is copied into the textbox.

The focus stays on the button. I know i can change the focus to the textbox with the setfocus method however this places the caret at the beginning of the textbox.

How do I get the caret to appear at the end of the textbox?

Also when I place the operators into the textbox I'm doing something like this:

Private Sub cmdLess_click()
txtquery.Text = txtQuery.Text & "<"
End Sub

This code appends the operator to the end of the textbox string. What if a user moves the caret to the middle of the textbox - How do I insert the operator at the caret position?

Thanks.