By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,101 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,101 IT Pros & Developers. It's quick & easy.

aligning text in textBox

100+
P: 175
Is there a way to set the position of text in a textBox?

for example, I'm reading from an excel file, several columns with several rows, then putting it in a textBox...so the alignment is gonna be a little weird. I tried using "Chr" inserting tabs, but it just doesn't work, it's off a little. Then I tried to do some funny stuff with textWidth, but the columns still didn't come out aligned.

So, is there a way to tell it what position (horizontally) to put text in a text box? I'll need to do this 4 to 5 times a line.
Apr 4 '07 #1
Share this Question
Share on Google+
3 Replies


iburyak
Expert 100+
P: 1,017
Text box in VB has Alignment property.

[PHP]Text1.Alignment = 0 'Left Justify
Text1.Alignment = 1 'Right Justify
Text1.Alignment = 2 'Center[/PHP]
Apr 4 '07 #2

100+
P: 175
I actually looked into alignment...not into great detail though because I'm gonna have several columns, not just 3, so I didn't think that would work if I have 4-6 columns.
Apr 4 '07 #3

iburyak
Expert 100+
P: 1,017
Try to use fixed length strings instead:

Try this:

[PHP]Dim col1 As String * 20
Dim col2 As String * 20
Dim col3 As String * 20


col1 = "aa"
col2 = "bbbbb"
col3 = "ccccc"


Text1 = col1 & col2 & col3

col1 = "aaaa"
col2 = "bbb"
col3 = "c"

Text1 = Text1 & vbCrLf & col1 & col2 & col3[/PHP]
Apr 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.