Hi again, 2° test program; a Terminal which interfaces an external box through the serial port. I send a single character command and get a variable lenght answer.
I wish to show the IN/OUT strings in the TextArea with different colors. I did it in the past with VB6 and a Rich Text window. My O.S. is Win7.
The problem I have is with ‘selected text’. This is the code for the Serial input (Area is the TextArea) :
[code] dim ch as String, currPos, newPos as integer,
//these are for debugging only
dim leng as Integer
dim sText as String
dim sLen as Integer
ch = Me.ReadAll(Encodings.ASCII)
if AscB(ch)=clearScreen then
Area.Text=""
else
currPos=Area.SelStart //start of selection
Area.AppendText ( ch)
newPos=Area.SelStart //end position of new text
leng = newPos-currPos
Area.SelLength = leng
sLen = Area.SelLength //for testing
sText = Area.SelText //for testing
Area.SelTextColor= &c0000ff00
end if[/code]
The current text is not rendered in color; all the subsequent text will be in blue
Debugging the code I see:
leng = 165 //ok
sLen=1
sText = empty
It appears that the ‘Area.SelLength = leng’ row does nothing
Possibly another stupid error my side…which?