Results 1 to 5 of 5

Thread: RichTextBox .SelBold is driving me nuts * RESOLVED

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    RichTextBox .SelBold is driving me nuts * RESOLVED

    I'm using this code which I got here at VBForums:

    VB Code:
    1. Private Sub txtSession_Change()
    2.  
    3.     Dim nPos As Long
    4.    
    5.     nPos = -1
    6.     Do
    7.     nPos = txtSession.Find((Trim(txtSendTo.Text) & ":"), nPos + 1, Len(txtSession.Text))
    8.         If nPos <> -1 Then
    9.             txtSession.SelColor = vbBlack
    10.             txtSession.SelBold = True
    11.         End If
    12.     Loop While nPos <> -1
    13.    
    14.     'txtSession.SelStart = 0
    15.     'txtSession.SelLength = 0
    16.     txtSession.SelBold = False
    17. End Sub

    First time it runs, its ok. But on succeeding calls it sets all text to bold instead of just the result from .Find. Actually, even before the procedure starts statements on the 2nd and succeeding calls(I put a break on Private Sub txtSession_Change()), all the text is already changed to bold.

    I inserted txtSession.SelBold = False in hopes of preventing this but it had no effect. I even tried the statements above that are commented out. This is the only procedure in the project wherein .SelBold is used so the prob can't be anywhere else. I checked .SelLength, .SelStart, and .SelText right after executing .Find and their values are ok, but the text still turns to bold. I checked the value of .SelBold in several other procedures (before and after the call to this procedure) and its value is false as expected. I CAN'T FIGURE OUT WHAT'S WRONG.

    Can someone please help me?
    Last edited by leinad31; Mar 25th, 2003 at 07:20 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width