samedi 18 juillet 2020

Library Book Finder - Replace with highlighted String of Itself

I have a large string(over 255 char) called strLibrary.

This string has random text throughout and book locations within the library. The book locations are always in the format 'Floor###Column###Shelf###' IE Floor149Column423Shelf876. I want to be able to find all strings like Floor###Column###Shelf### and then highlight them in my rich text box named txtLibrary so they are easy to see.

Note, the random text throughout may include the words "Floor" and or "Column" and or "Shelf" and not be the string format Floor###Column###Shelf### so it is important to only highlight the strings in the format Floor###Column###Shelf###.

In the past if I ever wanted to highlight a word(for example the word Book) in a rich text box I used the following:

strLibrary_RICH = Replace(strLibrary, "Book", "<font style =""BACKGROUND-COLOR:#FFFF00"">"Book"</font>")

Me.txtLibrary = strLibrary_RICH

The 'strLibrary like Floor###Column###Shelf### function' only returns a TRUE/FALSE result. So using the following doesn't work:

Dim strLibrary_RICH     AS String
Dim strHighlight        AS String

If (strLibrary Like *Floor###Column###Shelf###*) Then

strHighlight = (strLibrary Like *Floor###Column###Shelf###*)

strLibrary_RICH = Replace(" & strHighlight & ","<font style =""BACKGROUND-COLOR:#FFFF00"">" & strHighlight & "</font>")

End If

Me.txtLibrary = strLibrary_RICH

Is there a way to search for all strings like Floor###Column###Shelf### from within strLibrary and highlight them in rich text box txtLibrary?

Aucun commentaire:

Enregistrer un commentaire