Solved

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

Posted on 2004-04-29
9
134 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:Jozin
  • 4
9 Comments
 
LVL 9

Expert Comment

by:p_sie
ID: 10947328
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
0
 

Author Comment

by:Jozin
ID: 10947673
Thanks,

What I want to know is Left and Right alignment at the same time.
0
 
LVL 9

Accepted Solution

by:
p_sie earned 50 total points
ID: 10947723
Don't think that is possible in a textbox
Maybe you could use the rich textbox (add it in the component list) there you have the setalignment property, which you can set per paragraph.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:p_sie
ID: 10948679
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
0
 
LVL 9

Expert Comment

by:p_sie
ID: 11257212
I think I gave all the info what the asker needed!
0
 
LVL 22

Expert Comment

by:DarkoLord
ID: 11977340
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
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now