Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Switching Font Styles

TazzyLynnTazzyLynn Posts: 31Member
I am working on a project that I was originally wrote in VB6. I converted it to VB.Net for some of the features that it has. The problem that I am having is that on several rich text boxes that I have in the program, when information is shown in them for certain codes that I have set up it should change the font for each line from normal to bold and back again. So for example:

Line A = Bold
Line B = Normal
Line C = Normal
Line D = Bold

depending on the specific code that it found. I have set up property binds to make sure that each Rich text box uses the same thing but still not having any luck getting the lines to switch back and forth. What seems to be happening is that once it hits the code to switch to bold it will not switch back to normal for the next incoming code. Could anyone help with this problem or explain what I need to do? Here is a snippet of the code that I am having problems with.

[code]
If InStr(1, "02,01,05,06,04,07,cd", LineType) Then
RTB_Say.Font = My.Settings.MyBoldFont
RTB_Shout.Font = My.Settings.MyBoldFont
RTB_Linkshell.Font = My.Settings.MyBoldFont
RTB_Party.Font = My.Settings.MyBoldFont
RTB_Tell.Font = My.Settings.MyBoldFont
RTB_NoFilter.Font = My.Settings.MyBoldFont
'Else ----- I had to comment out this section to even get the bold to show up
' RTB_Say.Font = My.Settings.MyFont
' RTB_Shout.Font = My.Settings.MyFont
' RTB_Linkshell.Font = My.Settings.MyFont
' RTB_Party.Font = My.Settings.MyFont
' RTB_Tell.Font = My.Settings.MyFont
' RTB_NoFilter.Font = My.Settings.MyFont
End If

[/code]

Comments

  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-12-8 14:3:55[/red][/b][hr]

    : I am working on a project that I was originally wrote in VB6. I converted it to VB.Net for some of the features that it has. The problem that I am having is that on several rich text boxes that I have in the program, when information is shown in them for certain codes that I have set up it should change the font for each line from normal to bold and back again. So for example:
    :
    : Line A = Bold
    : Line B = Normal
    : Line C = Normal
    : Line D = Bold
    :
    : depending on the specific code that it found. I have set up property binds to make sure that each Rich text box uses the same thing but still not having any luck getting the lines to switch back and forth. What seems to be happening is that once it hits the code to switch to bold it will not switch back to normal for the next incoming code. Could anyone help with this problem or explain what I need to do? Here is a snippet of the code that I am having problems with.
    :
    : [code]
    : If InStr(1, "02,01,05,06,04,07,cd", LineType) Then
    : RTB_Say.Font = My.Settings.MyBoldFont
    : RTB_Shout.Font = My.Settings.MyBoldFont
    : RTB_Linkshell.Font = My.Settings.MyBoldFont
    : RTB_Party.Font = My.Settings.MyBoldFont
    : RTB_Tell.Font = My.Settings.MyBoldFont
    : RTB_NoFilter.Font = My.Settings.MyBoldFont
    : 'Else ----- I had to comment out this section to even get the bold to show up
    : ' RTB_Say.Font = My.Settings.MyFont
    : ' RTB_Shout.Font = My.Settings.MyFont
    : ' RTB_Linkshell.Font = My.Settings.MyFont
    : ' RTB_Party.Font = My.Settings.MyFont
    : ' RTB_Tell.Font = My.Settings.MyFont
    : ' RTB_NoFilter.Font = My.Settings.MyFont
    : End If
    :
    : [/code]

    _______________________________________________________________________

    Hi,

    You could try inserting a new line before switching fonts.
    It may work.

    Use &VbCrLf at the end of each line or put
    [code]
    Imports Microsoft.VisualBasic.ControlChars
    [/code]
    at the top of your code window and use the keyword NewLine instead in a string.

    E.G.

    myString="Hello." & vbCrLf 'or
    myString="Hello." & NewLine

    Just an idea though, i've not tried it yet.


    Regards,

    Dr M.

    P.S. If you think of the way WORD works,[b]then you could switch [/b]fonts or control like[b] bold[/b][blue] like i have switched[/blue] colours and control in this sentence.[red] I [red]hope [/red]that helps?



Sign In or Register to comment.