aligning text in textBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manontheedge
    New Member
    • Oct 2006
    • 175

    aligning text in textBox

    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.
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Text box in VB has Alignment property.

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

    Comment

    • manontheedge
      New Member
      • Oct 2006
      • 175

      #3
      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.

      Comment

      • iburyak
        Recognized Expert Top Contributor
        • Nov 2006
        • 1016

        #4
        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]

        Comment

        Working...