R
RB Smissaert
Have a plain multiline textbox on a userform and trying to
highlight a particular bit of text according to an Interbase
SQL statement error.
This is the code:
Sub HightlightSQLError(strError As String)
Dim arr
Dim strStringToFind As String
Dim lColumnUnknown As Long
Dim lTableUnknown As Long
Dim lTokenUnknown As Long
lColumnUnknown = InStr(1, strError, "Column unknown", vbTextCompare)
lTableUnknown = InStr(1, strError, "Table unknown", vbTextCompare)
lTokenUnknown = InStr(1, strError, "Token unknown", vbTextCompare)
If lColumnUnknown > 0 Then
arr = Split(Mid$(strError, lColumnUnknown), ",")
strStringToFind = Trim(arr(1))
With MainForm.SQLtxtStatement
.SetFocus
.SelLength = 0
.SelStart = _
InStr(1, .Text, strStringToFind, vbBinaryCompare) - 1
.SelLength = Len(strStringToFind) + 1
End With
Else
End If
End Sub
It works fine first time, but after that the right bit of text is not
highlighted anymore, although the values
for SelStart and SelLength are found fine.
Strangely when I right-click the textbox the right bit of text does show
highlighted.
I can't use the right-click though as it has a popup menu.
Maybe it is better if I change this textbox to a rich-text box.
Thanks for any advice in this.
RBS
highlight a particular bit of text according to an Interbase
SQL statement error.
This is the code:
Sub HightlightSQLError(strError As String)
Dim arr
Dim strStringToFind As String
Dim lColumnUnknown As Long
Dim lTableUnknown As Long
Dim lTokenUnknown As Long
lColumnUnknown = InStr(1, strError, "Column unknown", vbTextCompare)
lTableUnknown = InStr(1, strError, "Table unknown", vbTextCompare)
lTokenUnknown = InStr(1, strError, "Token unknown", vbTextCompare)
If lColumnUnknown > 0 Then
arr = Split(Mid$(strError, lColumnUnknown), ",")
strStringToFind = Trim(arr(1))
With MainForm.SQLtxtStatement
.SetFocus
.SelLength = 0
.SelStart = _
InStr(1, .Text, strStringToFind, vbBinaryCompare) - 1
.SelLength = Len(strStringToFind) + 1
End With
Else
End If
End Sub
It works fine first time, but after that the right bit of text is not
highlighted anymore, although the values
for SelStart and SelLength are found fine.
Strangely when I right-click the textbox the right bit of text does show
highlighted.
I can't use the right-click though as it has a popup menu.
Maybe it is better if I change this textbox to a rich-text box.
Thanks for any advice in this.
RBS