Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How Do I Justify Align A Paragraph In RichTextBox Control, In VB?

I'm using a RichTextBox control in my VB application & I'm restricted touse that control only.RichTextBox control provides three alignments, Left Right & Centre.I need to align a paragraph in RichTextBox to Justify(strech each line to fit in text area), as it is in Microsoft Word application.This is an urgent requirement. I would be greatful for immediate response.Manish.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Justify Alignment In RichTextBox Control

How to align selected text in RichText control to Justify (not Left, Center of Right)?

I searched the Internet and only found explanations that this is not supported by VB or even there is some bug in standard RichTextBox control ?!

Does anyone now how to solve this ...

Justify With RichTextBox
I have a problem trying to do full justification on text in a richtextbox. Probably it is not possible, but if anyone has any ideas I would be most grateful.
Thanks, Mick

Fill Justify Of RichtextBox
I am trying to justify a richtextbox so that it fills the box from both sides (like the text in a novel). It is not one of the options for SelAlignment, but it should be possible. How do you suggest i go about justifying the text in the richtextbox control?


Richtextbox - Paragraph Character
how can i make my richtextbox control put the text on a new line, instead of showing the paragraph character?

How To Display Multiline Paragraph And Input Multiline Paragraph In What Vb Control?
good day to all! how can i display multiline paragraph? and how can i input such paragraph in a multiline way. What vb control will i use, can you give me some code to extract idea from it?

Can't Align Right In Richtextbox!
I got a wierd problem. if i set the multiline = false in a richtextbox and then set the selalignment = rtfright it will not work!!! WHY!!!!

If i turn multiline = true then it will work... strange...

RichTextBox Align Justified
In a RichTexBox object I want to use Align Justified but this properties not exist.

What can I do?


To Align The Text In Richtextbox
hai guys,

I am using the form named as billing repot. In this form,we have print button to pritn the content of the bill details in the richtext box. my code is working fine,but all the details of the bill is to be printed in overwrited format.My ques tion is how to align the space for print the bill details in the rich textbox.

Public Sub PrintView(title As String, query As String, n As Integer, column As Variant)
Dim rs1 As New ADODB.Recordset
Dim colwidth(7) As Integer
rs1.Open "select b.billno,b.bdate,c.caddr,b.quantity,b.rate,,b.netamt from billing b,CREGISTER c where b.clientname=c.clientname", con, adOpenDynamic, adLockReadOnly
Dim col, ss, sp, Line As String
Line = String$(99, "_") + vbCrLf + vbCrLf
colwidth(0) = 15
colwidth(1) = 10
colwidth(2) = 35
colwidth(3) = 20
colwidth(4) = 25
colwidth(5) = 30
colwidth(6) = 40
colwidth(7) = 45
col = Space(36)
sp = Space(15)
ss = Space(37)
Dim rs As New ADODB.Recordset
rs.Open query, con, adOpenDynamic, adLockReadOnly
View = ""
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(5)

frmprintbill.RichTextBox1.Text = rs1("billno")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(10)
frmprintbill.RichTextBox1.Text = rs1("bdate")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(15)
frmprintbill.RichTextBox1.Text = rs1("caddr")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(20)
frmprintbill.RichTextBox1.Text = rs1("quantity")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(25)
View = View + vbCrLf + vbCrLf + vbCrLf
frmprintbill.RichTextBox1.Text = rs1("rate")
View = View + Space(30)
frmprintbill.RichTextBox1.Text = rs1("discount")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(35)
frmprintbill.RichTextBox1.Text = rs1("netamt")
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Space(40)
View = View + Space$(5) + title + vbCrLf + vbCrLf
View = View + vbCrLf + vbCrLf + vbCrLf
View = View + Line
Dim j
For j = 0 To n - 1
    If j = 0 Or j = 1 Then
        LSet col = rs(j)
        View = View + sp + col
        LSet ss = rs(j)
        View = View + sp + ss
    End If
Next j
View = View + vbCrLf
View = View + Line
While Not rs.EOF
'Dim i
    For i = 0 To n - 1
        If i = 0 Or i = 1 Then
            LSet col = rs(i)
            View = View + sp + col
            ss = Space(colwidth(i))
            LSet ss = rs(i)
            'View = View + sp + ss
            View = View + ss
        End If
    Next i
    View = View + vbCrLf
End Sub

Plzzzz trace the code and swend the solution for me.


How To Align Text In RichTextBox
Can anybody help me?

I want to print the text from the richtextbox in the format aligned by the user. How shall i go for it?


Right Align Cell Contents In Richtextbox

Been scratching my head over this for some time.

I'm new to the forum so if I do or say anything incorrectly please set me straight.

I need to place a table (or just aligned text would do) in a richtextbox (either by modifying the rtf or copy/paste) and have no problems doing this.

What I want to happen is have some of the cell contents right align (they contain currency). Same behaviour as if copying an excel sheet into word where cell formats are preserved.

I have tried RSet and spacing which doesn't work unless you use a font like courier etc. but users can set fonts and sizes in this app.
I have also tried setting and using tabs but they simply left align. If i pad the currency text only with spaces I get real close but when I generate an HTML page from the RTB it looks a lot worse.

I'm sure there must be a simple way to do this??????
Any ideas would be very welcome!
Thanks in advance.

How To Align The Space For Printing In Richtextbox
hai guys,

            I have a billing form.In this form ,i click the print button to print the bill details in the richtextbox.My question is
"How to align the space for printing the bill details in the richtextbox.Plz help me.It's very urgent for me.


How To Right Justify Or Left Justify A Column In Excel From VB
How to right justify or left justify the data in a column in excel from VB

Right Justify In An ActiveX Control
I'm working on an ActiveX control that has a Textbox. I've selected Right Justify under alignment, yet the Textbox still stays Left Justified. Is there some other property that needs to be set to enable Right Justify on Textboxes in control?

Text Control Justify
I need a Text Control where I can justify the Text at both margins. ¿Do you know where or how can I get it?

Justify Text In Rich Textbox Control
Is there any method to "justify" text in Rich Text Box Control?

When I display Memo field from ACCESS database into the Rich Textbox Control on the form, the right margin looks wavy (i.e. not properly aligned). Is there any solution for this.


URGENT Masked Edit Control, How Can I Justify Numbers To The Right????
Hi!, I'm from México and I've some troubles formating numbers with this control (masked edit control), I would like to justify numbers to the right as they should be, but I can't (they all go to the left). And I don't know how can I do it , or which controls can I use.

please help me!!


Align Control In Picture Box
Hello everybody,

is it possible to align a control inside a picture box ? Something like : 15 top of pic box and 20 left ?

I hope someone could help me



How To Right Align Masked Box Control
Can i make my masked box control to right align??
thx alot....

Vertical Align Text In Text Box / Label Control
I searched on "vertical align" in all forums and did not find this mentioned. (Not that it hasn't been, I just didn't get a hit.)

Anyway, is there a way to vertically align text within a VB 6.0 textbox or label control? (i.e., some programmatic equivalent to the Alignment property) It looks really goofy when the text is crammed against the top of the control ...

Getting some other toolset is not an option. (I am doing this at home for kicks and grins.)



Tab In A Richtextbox Control
I know ctrl + tab will, create a tab, but is there any way to control the size (spacing) of the tab?

Richtextbox Control
hi all
working with rtb today, trying to make a colorful console windows for a game-online fake hacking game , but thats beside the point. anyways since i want a console that can display colors, i decided to use the rtb control, only im having problems with it. i need to be able to add text to the console window, and while typing the selcolor method works fine, but when trying something like rtb.text=rtb.text & "moo" the whole prog goes to hell (not literally of course)
basically the color is all reset to black when i try this. it seems as tho all the rtf formating was lost. so any ideas on how i can accomplish this? for right now, all i need to be able to do is add new text with dif colors while retaining the old text, tho later i might want to allow the old text to be modified by code and so id rather have a complete solution if its not difficult.

thx for any help

RichTextBox Control
How do you change the text colour in a rich text box? Can't Seem to make it work...

Help With RichTextBox Control
Two questions about the RichTextBox control:

1) In my current project I have set the ScrollBars property to be = rtfBoth (3), but under NO circumstances do I ever seem to get a Horiz Scroll bar...???

2) I have reviewed previous posts here about using EM_SETSCROLLPOS and SENDMESSAGE to force the RTB to scroll up or down, but these calls do not seem to work....basically I am trying to force the rtb back to the top after entering a large amount of text that causes it to scroll to the end of the text.

Can anyone offer additional insight into this?

RichTextBox Control
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:
Private Sub LabelBold_Cick()If RTBCode.SelBold = True then RTBCode.SelBold = Not TrueIf RTBCode.SelBold = False then RTBCode.SelBold = TrueEnd 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:
Private Sub LabelBold_Click()If RTBCode.SelBold = True Then RTBCode.SelBold = Not True Else RTBCode.SelBold = TrueEnd Sub

Richtextbox Control ... Is It Possible ?
hello everyone !

i've a richtextbox control called rtbresult.

i'm using :
str="the name u entered is " & txtname.txt
str=str & "the address is = " & txtadd.text

rtbresult.text="The info is :" & str

currently all the strings are concatenated and is diaplayed continously in the richtextbox.

now how can i display all the three lines on 3 diff lines on rtbresult.text, (like with an entre key pressed betwwen them)


shruti !

RichTextBox Control
I just used a Rich Text Box for the first time and noticed that Cut, Copy, Paste, and Select All work automatically without any additional programming (CTRL + X, etc.). What other common commands work in a Rich Text Box, and where would I find a list of them? And, is there any shortcut to coding these commands (for my Edit menu and my toolbars, for example) or do I just use the usual Clipboard and .SelText commands I would with a regular Text Box?


RichTextBox Control
In rich text box i want to use multi colour is it possible to do so(for ex 1st line should be in red colour and second line should be yellow colour .like this)if it ios not possible in this one in which control can i use

RichTextBox Control......why??
Does anyone know how to format the text in a richtextbox so it can be transfered to the clipboard as actual text, not that crap it puts out??

RichTextBox Control

I would like to use the RichTextBox control, to display lines with differents colors.

So i've found that i need to use selcolor, but when i do the following code it doen't works well...

Option Explicit

Private Sub Form_Load()
Const Text1 = "Hello"
Const Text2 = "In progress"
Const Text3 = "Done"

RichTextBox1.Text = Text1
RichTextBox1.Text = Text2 & vbCrLf & RichTextBox1.Text
RichTextBox1.SelStart = 0
RichTextBox1.SelLength = Len(Text2)
RichTextBox1.SelColor = &HFF&
RichTextBox1.SelText = Text2
RichTextBox1.SelStart = 0
RichTextBox1.SelColor = &H80000012
RichTextBox1.Text = Text3 & vbCrLf & RichTextBox1.Text

End Sub

I would like the Text2 to be displayed in red and the rest of the text in black....

Thank you.


RichTextBox Control
I think i must be an idiot. I have a richtextbox control, and my program first receives a color, and then the text. is there a way that I can add this to the front of the text that already exists in the box, have the text be the new color, and have the old text retain its old color and properties?

Bill Rogers

RichTextBox Control
How do I change part of a RTB control's text color? For instance
<Andy> hello
<Andy> how are you?
I just want to change <Andy> to a different color on each new line?

Using Of RichTextBox Control
I am working on my first project. It is a terminal that looks like a dos windows (80 cols and 25 rows). I use fix-pitch font (Courier New) for RTF. But i could not control the space between lines on the terminal (i know how to control the character's spacing). is there anyway to do that? Help me!
My email address is

RichtextBox Control -where Does It Come From?

can neone tell me the source of richtext box control. Does it come with the os itself? or does it come with the microsoft office suite or some thing else. any information will be highly appreciated.


RichTextBox Control !
I have a form in VB, it has some textboxes and a RichTextBox control. The rich text box control is bulletted one and the user enters a list of things say for eg.


When the user hits print, I am creating a new Word document....filling the necessary values in it(this doc is based on some template which has tables) I am retreiving the values from the text boxes and putting them in appropriate cells in the word doc tables.....Hmmmm.....

Following is something on which I need some advice....the list in the Richtext box control....must go in a different row in one of the tables in the Word doc......

How d I do this.....will I have to split......Yeshhhhhhhhhhhhhhhh......@#$$%^&*@$

I got it.....I will use the SPLIT function to split the text from the rich text box control and put it in a different row......

Would like to say thanks to everyone for reading the query till the solution myself.... ...still I am posting this query so that nobody else makes this mistake....


RichtextBox Control
I 've a problem with my messenger! I want to add smileys to the RichtextBox control and its not possible is there any other control that would help me add these smileys??

Thanks in advance

RichTextBox Control
I am trying to save the contents of a RichTextBox control to SQL Server. I can cut, copy and paste to MS Word, but I have been unsuccessful so far in preserving the formatting when saving to SQL Server. If I bind the control, I get something like {
tf1ansiansicpg1252deff0deflang1033uc1 }. When the form loads the saved data, the RichTextBox control displays nothing.

Help Regarding RichTextBox Control
Whenever I add an image into a richtextbox it is possible to drag it and make the image larger.Can I disable this.

RichTextBox Control
I use RichTextBox control in VB6.
When I insert super keyword into rtfText.SelRTF, it worked well in Windows2000.
But in Window98, super keyword changes to up10 keyword.
Could you help me ?
Thank a lot.

Richtextbox Control With Winsock
I'm using a richtextbox control to simulate scrolling of my Telnet client. Unfortunately, as the richtextbox is updated, the focus always stays on the top, so I can only view my data after the Winsock client is done receiving. How can I maintain focus at the end of the richtextbox so I can view the data as it scrolls by? Thanx.

Microsoft Richtextbox Control
March 5, 2006

Two questions:

Anyone's reply will be appreciated.

1. If I use a Richtextbox, I have to include Microsoft Richtextbox Control in my application. Can I distribute it with my application?

2. Other than all the goodies the Richtextbox can do, what is the max capacity can it hold text? Is it the same as the regular textbox, which is around 32,000 KB?
Thank you.


Problem With RichTextBox Control
I've just inherited some code from a colleague and i'm having problems with the richtextbox control when i use the code in windows 2000. It was developed (and works fine) in windows nt.

It basically runs SQL statements, outputting to the richtextbox in question. Under NT it works fine but under 2000 it can throw up the wrong year from a datetime query (2004 = 7049) or the formatting will be crazy and certain parts of strings will be deleted before being added to the textbox (always before or after backslash or hyphens, etc).

I just need to know if there is a difference in the way that NT and 2000 handle richtextbox controls and if so, how can I workaround this? Any other ideas will be greatly appreciated, thanks.

RichTextBox Margin Control

In the past I have used EM_SETMARGINS on Textboxes and ComboBoxes to set the margins. But I have been trying to set the left margin on an RTB using the same method and found out that it doesn't work.

I was just hoping that someone would be able to point me in the right direction...


Textbox/richtextbox Control
Hello, having problems with the following two points, any help would be appreciated:

(1) When a [single-line] textbox has control and the user presses enter, a beep is emitted. Is there any way to override this beep?

(2) If text is selected on a textbox and another form has focus, you cannot see the selected text. Is there any way to still see selected text when another form has the focus?


RichTextBox Control Crashes VB6
I'm trying to load a readme file into a richtextbox using the following line of code in my form load:
rtbHelp.LoadFile App.Path & "README.txt"
I get the error "Method 'LoadFile' of object 'IRichText' failed" and then it crashes my VB6.

Is this common?

Richtextbox Control Question
Im using a rich textbox control to load some text.
I got two questions, first: Where can I find the codes to format the text? (bold, italic, color, etc)
And second, how do I do to scroll down to show the last line of text loaded into the richtextbox? (like MSN, yo enter the message and it shows yo the last line entered, like a scroll down)

Control Like Richtextbox Without Right Margin
I'm using a nice richtext found at
The matter is that it hasn't any rightmargin propriety.
By this way, the loaded file.rtf has a different line length and numbers.

Is it possible to solve this problem with SendMessageLong API?
If it's possible, how can I?
Truely I'm not an API expert

Thanks in advance

A Control Similar To RichTextBox??
I need a control that not only can you change the foreground color, but also the background color. I really dont want to go to console mode to do this hehe

RichTextBox + Other Functionality Control?
Does anyone have a control they've created to extend the RichTextBox functionality?

I guess I'm looking for something with a wrapper to a RTB control where I can set the font, bold, etc. and just 'send' text to it. If there's nothing out there then I'll just go ahead and build my own control but I was hoping someone had already gone through the trouble


Cursor Control In Richtextbox
Hi, i'm trying to make a text editor using the richtextbox
control. one of the problems i'm having when i click on a
combo box to change the font, the combo box still has focus
and i have to click the mouse in the correct place in the
richtextbox to continue.

my question is should i code every control to give the focus
back to the richtextbox or is there an easier/better way to
do this?

thanks in advance


Copyright © 2005-08, All rights reserved