I figured that if I was having as much trouble with the RichTextBox Control, maybe someone else on the internet is.. So here is my explanation of it all since I finally get it thanks to [url="http://forums.killagraphix.com/index.php?showuser=41"]FlyingDoggyJake[/url].
RichTextBox Control
What is the RichTextBox Control?
The RichTextBox control is a control which can read .rtf files and display them properly, unlike the basic TextBox control. You can also add color and images to this type of textbox also, unlike the basic TextBox control.
Now that we have that covered, let's jump right in. ~ First, let's actually get the RichTextBox Control on our toolbox list of components.
1.) Right-click on the toolbox and select "Components"
2.) Scroll down near the bottom/middle and find "Microsoft Rich TextBox Control 6.0 (SP4)"
3.) Check it and then click "Apply" and then "OK"
4.) If everything went 'ok' you should now have a RichTextBox Control ([img]http://img95.exs.cx/img95/6712/RTB.png[/img]) on your toolbox /smile.gif' class='bbc_emoticon' alt=':)' />
Now go ahead and add the RichTextBox Control to your form with a pretty good size to it and add a textbox underneath that with a command button somewhere and set the command button's default property to "True". You should end up with something like this:
[img]http://img44.exs.cx/img44/3566/RTB1.png[/img]
Now lets add some code to this project. In the Private Sub Command1_Click() event, add this code:
Visual Basic CodePublic Sub Command1_Click()
If (Len(Text1.Text) > 1) Then
'Adding The Nickname
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelBold = True
RichTextBox1.SelColor = QBColor(1)
RichTextBox1.SelFontName = "Arial"
RichTextBox1.SelFontSize = "10"
RichTextBox1.SelText = "Josh: "
'Adding Text1.Text After The Nickname
RichTextBox1.SelStart = Len(RichTextBox1.Text)
RichTextBox1.SelBold = False
RichTextBox1.SelColor = QBColor(2)
RichTextBox1.SelFontName = "Arial"
RichTextBox1.SelFontSize = "10"
RichTextBox1.SelText = Text1.Text & vbCrLf
'Clear the TextBox
Text1.Text = ""
End If
End Sub
Okay.. Now that we have all of this added, let me explain everything step-by-step.
If (Len(Text1.Text) > 1) Then
This means, "If the length of the text in Text1 is greater than ONE, then do the following code
RichTextBox1.SelStart = Len(RichTextBox1.Text)
This is saying that we want to start our colored text at the end of everything that is in the RichTextBox Control's contents.. This is why we bring in Len(RichTextBox1.Text) because it will return where to start, which is at the end of it all.
RichTextBox1.SelBold = True
This tells VB to make the text bold we are about to enter in the RichTextBox
RichTextBox1.SelColor = QBColor(1)
This tells VB to make the color navy blue, or QBColor(1).. (QBColor(1) = Navy Blue)
RichTextBox1.SelFontName = "Arial"
RichTextBox1.SelFontSize = "10"
This tells VB to make our font Arial size 10
RichTextBox1.SelText = "Josh: "
And finally, this is the text we are adding to our RichTextBox, which is in fact "Josh:"
I think you can figure out the rest of the things that I've included at the end..
[img]http://img78.exs.cx/img78/4075/RTB2.png[/img]
That is basically the workings of RichTextBox Control.. Pretty simple eh? Sometimes I wonder why I was having such a hard time with it /blum.gif' class='bbc_emoticon' alt=':P' />
If you have any questions, please feel free to PM me, or leave a post here /smile.gif' class='bbc_emoticon' alt=':)' /> /good.gif' class='bbc_emoticon' alt='(Y)' />
~Josh /sp_ike.gif' class='bbc_emoticon' alt='(spike)' />
RichTextBox Control
Moderators: Moderator, Global Moderator
RichTextBox Control
Last edited by Josh on Sun Oct 17, 2004 10:52 am, edited 1 time in total.
[align=center]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]
RichTextBox Control
nice tutorial Josh`. Now I can stop using the webbrowser for everything /blum.gif' class='bbc_emoticon' alt=':P' />
Love is all a matter of timing.
It's no good meeting the right person too soon or too late.
If I'd live in another time or place...
...my story might have had a very different ending.
It's no good meeting the right person too soon or too late.
If I'd live in another time or place...
...my story might have had a very different ending.
RichTextBox Control
lol, well as I told Rift the other night, I wish I could combine the two into one control because I really wish I had the webbrowser control and not the RTB and sometimes I wish I had the RTB and not the webbrowser..
[align=center]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]

“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
[/align]

