Searching for bold text in a textarea

I have a textarea with more than 50,000 characters. There are several words in bold in the text.
How can I select only the bold words ?
Now I am using the code :

'TA is a textarea
'ListB is a Listbox
Dim Place As Integer, Start As Integer, BoldText As string
Start = 0
BoldText = “”
For Place = 1 to TA.Text.Len
TA.SelStart = Place
TA.SelLength = 1
if TA.SelBold = True then
If Start = 0 Then
Start = Place
End If
BoldText = BoldText + TA.SelText
If Start > 0 Then
ListB.AddRow(Format(Start,“0000000”), Trim(BoldText))
Start = 0
BoldText = “”
End If
end if

This code is working, but VERY, VERY SLOW

Does someone has a faster method ?

Look at STYLERUNS … this automatically breaks the text into chunks based on where color, bold, italic etc changes

Tx Dave.

I tried using STYLERUNS, but to no avail. Where can I find a code example for my specific problem ?
Is the starting point you will want to look at.

There is an example on the StyleRunRange entry that shows you how to get all the style runs. You just have to filter out the bold ones.

Tx Tim.
I’ll try it out.

Dear Tim,

I tried the following code :

Dim count As Integer
count = TextArea1.StyledText.StyleRunCount //get the number of StyleRuns
For i As Integer = 0 To count-1 //loop through them
ListBox1.Cell(i,1) = Str(TextArea1.StyledText.StyleRunRange(i).Length)
ListBox1.Cell(i,2) = TextArea1.StyledText.StyleRun(i).Text

This works just fine.
But how can I know which parts of the text are in bold ?
In the listbox, I see no differences

You would have to check the StyleRun.Bold property for each StyleRun returned.

Tx for your help ! It works !