17-02-21, 04:48 AM
و عليكم السلام و رحمة الله و بركاته
استبدل أداة TextBox بالأداة RichTextBox عندها يمكن تغيير لون او خط جميع الكلمات المطابقة للبحث معا
استبدل أداة TextBox بالأداة RichTextBox عندها يمكن تغيير لون او خط جميع الكلمات المطابقة للبحث معا
كود :
Option Explicit
Private Sub Form_Load()
Me.RichTextBox1.Text = "1 2 3 4 4 4 1 4 5 7 8 8 9 7 1 2 9 3 1 3 9 7 5 4 2 1 5 6"
BoldWord "4"
End Sub
Private Sub BoldWord(ByVal word As String)
Dim start, found As Integer
With Me.RichTextBox1
found = .Find(word, start)
Do While found > -1
.SelStart = found
.SelLength = Len(word)
.SelBold = True
.SelColor = vbRed
start = found + Len(word)
If start >= Len(.Text) Then Exit Do
found = .Find(word, start)
Loop
End With
End Sub