Q:

Apply multiple FontStyles to Richtextbox

i need some help to figure out how to set bold,italic,underline to the same text into a richtextbox..
So far i have been doing this...
Public Class Form1
    Dim texto As String

    Public Sub seleccionCB()

        If CBNegrita.Checked = True Then
            txtTexto.Font = New Font(txtTexto.Font, FontStyle.Bold)

        Else
            txtTexto.Font = New Font(txtTexto.Font, FontStyle.Regular)
            If CBCursiva.Checked = True Then
                txtTexto.Font = New Font(txtTexto.Font, FontStyle.Italic)
            Else
                txtTexto.Font = New Font(txtTexto.Font, FontStyle.Regular)
                If CBSub.Checked = True Then
                    txtTexto.Font = New Font(txtTexto.Font, FontStyle.Underline)
                Else
                    txtTexto.Font = New Font(txtTexto.Font, FontStyle.Regular)
                End If

            End If

        End If

    End Sub

A:

You can combine multiple values using the bitwise Or operator, for instance:
txtTexto.Font = New Font(txtTexto.Font, FontStyle.Bold Or FontStyle.Italic)

However, in your case, where you need to check each one with a condition, you can do it like this: 
Dim style As FontStyle = FontStyle.Regular
If CBNegrita.Checked Then style = style Or FontStyle.Bold
If CBCursiva.Checked Then style = style Or FontStyle.Italic
If CBSub.Checked Then style = style Or FontStyle.Underline
txtTexto.Font = New Font(txtTexto.Font, style)

