Link to home
Start Free TrialLog in
Avatar of Jozin
Jozin

asked on

How to make a string aligned (Left and Right) in a text box

How can I make the string that are encoded in a text box be Left justified and Right justified. Just like when using MS Word where in you make the paragraph aligned both at the Left and Right margin
Avatar of p_sie
p_sie
Flag of Netherlands image

If you want all the text in a textbox aligned to one side, then use the alignment property of the textbox.

Textbox1.Alignment = 0 (left-align)
Textbox1.Alignment = 1 (right-align)
Textbox1.Alignment = 2 (center-align)

If you want left and right align in one textbox, I don't know
Avatar of Jozin
Jozin

ASKER

Thanks,

What I want to know is Left and Right alignment at the same time.
ASKER CERTIFIED SOLUTION
Avatar of p_sie
p_sie
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tested something:

do the following
add a rich text control to a form and name it RT
add a button to the form

paste the following code in the form's code window

Private Sub Command1_Click()

    RT.SelAlignment = 1
End Sub

Private Sub Form_Load()

    RT.Text = "Bike" & vbCrLf & "test" & vbCrLf & vbCrLf & "car"
   
End Sub

now select a line and press the button, the line will be rightaligned!
to make it center aligned use  RT.SelAlignment = 2 and left aligned : RT.SelAlignment = 0

Good luck
I think I gave all the info what the asker needed!
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Accept p_sie's comment as an answer

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

DarkoLord
EE Cleanup Volunteer