



 
 


Oxygen писал(а):А ведь совсем недавно обсуждалось...
Поиском пользоваться нужно иногда...
http://bbs.vbstreets.ru/viewtopic.php?p ... 5#66101835




 for_xqz_me.rar
 for_xqz_me.rar

ВуД писал(а):Как сделать слово "ВуД" при написание в RichTextBox1 выделялось красным цветом






Sub ColorIt(ByVal lBegPos As Long, ByVal lLength As Long)
    RichTextBox1.SelStart = lBegPos - 1
    RichTextBox1.SelLength = lLength
    RichTextBox1.SelColor = vbRed
End Sub
Private Sub RichTextBox1_Change()
Dim sst As Long, slln As Long
Dim lCurPos As Long
RichTextBox1.Enabled = False
sst = RichTextBox1.SelStart
slln = RichTextBox1.SelLength
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text) + 1
RichTextBox1.SelColor = vbBlack
lCurPos = 0
    Do
        lCurPos = InStr(lCurPos + 1, RichTextBox1.Text, "ВуД", vbTextCompare)
        If lCurPos = 0 Then Exit Do
        ColorIt lCurPos, 3
    Loop
RichTextBox1.SelStart = sst
RichTextBox1.SelLength = slln
RichTextBox1.SelColor = vbBlack
RichTextBox1.Enabled = True
RichTextBox1.SetFocus
End Sub






Специально для ВуД-а я вот это на писал(а):lCurPos = 0
Do
lCurPos = InStr(lCurPos + 1, RichTextBox1.Text, Chr(34)+"ВуД"+Chr(34), vbTextCompare)
If lCurPos = 0 Then Exit Do
ColorIt lCurPos, 3
Loop








 Это ж Вуду вроде лень самому разобраться как работает код. Хотя, мне не особо трудно подогнать под "новую задачу" замечательный пример Хакера
  Это ж Вуду вроде лень самому разобраться как работает код. Хотя, мне не особо трудно подогнать под "новую задачу" замечательный пример Хакера   
 
Sub ColorIt(ByVal lBegPos As Long, ByVal lLength As Long)
    RichTextBox1.SelStart = lBegPos - 1
    RichTextBox1.SelLength = 1
    RichTextBox1.SelColor = vbBlue
    RichTextBox1.SelStart = lBegPos
    RichTextBox1.SelLength = 3
    RichTextBox1.SelColor = vbRed
    RichTextBox1.SelStart = lBegPos + 3
    RichTextBox1.SelLength = 1
    RichTextBox1.SelColor = vbBlue
End Sub
Private Sub RichTextBox1_Change()
Dim sst As Long, slln As Long
Dim lCurPos As Long
RichTextBox1.Enabled = False
sst = RichTextBox1.SelStart
slln = RichTextBox1.SelLength
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(RichTextBox1.Text) + 1
RichTextBox1.SelColor = vbBlack
lCurPos = 0
    Do
        lCurPos = InStr(lCurPos + 1, RichTextBox1.Text, Chr(34) + "ВуД" + Chr(34), vbTextCompare)
        If lCurPos = 0 Then Exit Do
        ColorIt lCurPos, 3
    Loop
RichTextBox1.SelStart = sst
RichTextBox1.SelLength = slln
RichTextBox1.SelColor = vbBlack
RichTextBox1.Enabled = True
RichTextBox1.SetFocus
End Sub








Kovu писал(а):/me достает бензопилу и ме-дле-нно приближается к Вуду.
p.s. Too Many attempts...





Private Sub RichTextBox1_Change()
Dim sst As Long, slln As Long
Dim matchCol As MatchCollection
Dim nashel As Match
Dim s As String
sst = RichTextBox1.SelStart
slln = RichTextBox1.SelLength
    On Error Resume Next
    Dim reg As New RegExp
    reg.Pattern = "ВуД"
    reg.IgnoreCase = True
    reg.Global = True
    
    Dim reg2 As New RegExp
    reg2.Pattern = Chr(34)
    reg2.IgnoreCase = True
    reg2.Global = True
    s = RichTextBox1.Text
    
    Set matches = reg.Execute(s)
    For Each nashel In matches
        RichTextBox1.SelStart = nashel.FirstIndex
        RichTextBox1.SelLength = nashel.Length
        RichTextBox1.SelColor = vbRed
    Next nashel
    
    Set matches = reg2.Execute(s)
    For Each nashel In matches
        RichTextBox1.SelStart = nashel.FirstIndex
        RichTextBox1.SelLength = nashel.Length
        RichTextBox1.SelColor = vbBlue
    Next nashel
    RichTextBox1.SelStart = sst
    RichTextBox1.SelLength = slln
    RichTextBox1.SelColor = vbBlack
    RichTextBox1.SetFocus
End Sub

ВуД писал(а):Помогите, пожалуйста
Все это последний вопрос по этой теме
Вот я прописываю так и почему то не выходит:
Do
lCurPos = InStr(lCurPos + 1, RichTextBox1.Text, Chr(34) + RichTextBox1.Text +"Вуд" + RichTextBox1.Text + Chr(34), vbTextCompare)
If lCurPos = 0 Then Exit Do
ColorIt lCurPos, 3
Loop
А мне нужно что: "тест Вуд-это ...."


Хакер писал(а):ВуД писал(а):Помогите, пожалуйста
Все это последний вопрос по этой теме
Вот я прописываю так и почему то не выходит:
Do
lCurPos = InStr(lCurPos + 1, RichTextBox1.Text, Chr(34) + RichTextBox1.Text +"Вуд" + RichTextBox1.Text + Chr(34), vbTextCompare)
If lCurPos = 0 Then Exit Do
ColorIt lCurPos, 3
Loop
А мне нужно что: "тест Вуд-это ...."


Chr(34) + RichTextBox1.Text +"Вуд" + RichTextBox1.Text + Chr(34),





 for_vood.rar
 for_vood.rar



Сейчас этот форум просматривают: AhrefsBot, Google-бот и гости: 7