Results 1 to 3 of 3

Thread: RichTextBox Control [resolved]

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Resolved RichTextBox Control [resolved]

    Hi all, i am struggling with the RichTextBox control on my form, i can bold letters but canot unbold them here is my code :

    VB Code:
    1. Private Sub LabelBold_Cick()
    2. If RTBCode.SelBold = True then RTBCode.SelBold = Not True
    3. If RTBCode.SelBold = False then RTBCode.SelBold = True
    4. End Sub

    Help please

    EDIT: Nevermind, i know whats wring, even if the text gets set to unbold the next line sets it back to bold, wow, why didn't i notice that last night :S
    I'm silly

    The code should look like this :
    VB Code:
    1. Private Sub LabelBold_Click()
    2. If RTBCode.SelBold = True Then RTBCode.SelBold = Not True Else RTBCode.SelBold = True
    3. End Sub
    Zeegnahtuer?

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: RichTextBox Control [resolved]

    Try this:

    VB Code:
    1. Private Sub LabelBold_Cick()
    2. If RTBCode.SelBold = True Then
    3.     RTBCode.SelBold = False
    4. End if
    5. If RTBCode.SelBold = False Then
    6.     RTBCode.SelBold = True
    7. End If
    8. End Sub

    Or, you could just do this:

    VB Code:
    1. Private Sub LabelBold_Cick()
    2.     RTBCode.SelBold = Not RTBCode.SelBold
    3. End Sub

    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: RichTextBox Control

    your code is a little confusing to read. Try this

    VB Code:
    1. Public Sub Temp()
    2. RTBCode.SelBold = Not RTBCode.SelBold 'This implements a toggle!
    3. End Sub

    ---

    Clearly I am a slow typer

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