Well, if you are going to be inserting the text in the box with code, and not having the user enter it, then you could use 2 label controls like this:
Place a Label control on your form, and then paste a copy of it to create a control array. Put the copy directly behind the first one. Set the properties of the controls like this:
Label1(0):
Backstyle = Transparent
Borderstyle = Fixed Single
Label1(1):
Caption = ( No caption )
Visible = False
Borderstyle = None
Backcolor = 'Select the highlight color that you want. Note that very dark colors will not work too well. Because this does not change the foreground color of the selected text.
In code, do this:
Declarations:
Dim CutStart As Integer
Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1(1).Visible = False
CutStart = X
End Sub
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim I As Integer
Dim R As Integer
Dim CutSize As Integer
If Button = vbLeftButton Then
Label1(1).Visible = False
' Adjust CutStart to the beginning of a character. Allow for the border.
For I = 0 To Len(Label1(0).Caption)
If TextWidth(Left$(Label1(0).Caption, I)) > CutStart Then
CutStart = TextWidth(Left$(Label1(0).Caption, I - 1)) + 20
GoTo Jump
End If
Next I
Jump:
R = I
CutSize = X - CutStart
' Adjust Cutsize to the end of a character
For I = 0 To Len(Label1(0).Caption)
If (TextWidth(Left$(Label1(0).Caption, I)) > CutStart + CutSize) And (I > R) Then
CutSize = TextWidth(Mid$(Label1(0).Caption, R, I - R)) + 30
GoTo Jump2
End If
Next I
Jump2:
' If CutSize exceeds the lenth of the text, chop it off
If (CutStart + CutSize) > TextWidth(Label1(0).Caption) Then
CutSize = TextWidth(Label1(0).Caption) - CutStart + 45
End If
' draw the background label
If CutSize < 0 Then Exit Sub
Label1(1).Left = Label1(0).Left + CutStart
Label1(1).Width = CutSize
Label1(1).Visible = True
End If
End Sub
So, when you place the text in the Label1(0).Caption, the user can select text and it will be highlighted, and it will stay that way even if the control loses focus.
HTH
Robert