1 Attachment(s)
[VB6] How Do I Work With The RichTextBox?
Q: How Do I Add A Rich TextBox To My Application?
A: Click Project, Components, and Select Microsoft Rich TextBox from the list
Q: How Do Align Text In A RichTextBox?
A: The Following Will Align The Text In The Center. Left And Right Are Similar :
Code:
Private Sub cmdCenter_Click()
'Center Align
rtfText.SelAlignment = rtfCenter
End Sub
Q: How Do I Format The Text, Bold, Italic Or Underline?
A: The Next Segment Will Bold, Italicise, Underline Text :
Code:
Private Sub cmdBold_Click()
'Bold
rtfText.SelBold = Not rtfText.SelBold
End Sub
Private Sub cmdItalic_Click()
'Italic
rtfText.SelItalic = Not rtfText.SelItalic
End Sub
Private Sub cmdUnderline_Click()
'Underline
rtfText.SelUnderline = Not rtfText.SelUnderline
End Sub
Q: How Do I Change The Text Colour?
A: The Next Segment Shows How To Change A Color, With The Use Of The CommonDialog Component, Which Must Be Added By Clicking Project, Components, And Selecting It From The Available List.
Code:
Private Sub cmdColor_Click()
'CommonDialog To Show Colours
CD.Flags = cdlCFBoth 'Show All Colours
CD.ShowColor
rtfText.SelColor = CD.Color 'Set Colour
End Sub
A Full Example Of The RTB In Working Is Attached