Results 1 to 4 of 4

Thread: Tabs in MsgBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    1
    Hi

    Anyone able to help with the following problem:

    I'm concatenating a string to be displayed in a MsgBox. What I want to display is something like this:

    Apples 4
    Pears 7
    Bananas 2

    However, using tab characters in the string, the numbers do not align properly. Actually it looks something like this:

    Apples 4
    Pears 7
    Bananas 2

    The string is dynamic, so I do not know beforehand how long the the respective "label" (the "fruit") is.

    Help!

    Bjorn

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Use the Space() function, like this (Tab position is 40):

    MsgBox strFruitName1 & Space(40-Len(strFruitName1)) & CStr(intFruitNumber1) & Chr$(10) & Chr$(13) & strFruitName2 & Space(40-Len(strFruitName2)) & CStr(intFruitNumber2) & Chr$(10) & Chr$(13) ....

    Hope it helps.

  3. #3
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Space

    Space is fine but you need a fixed pitch font... How you change the font in a MsgBox - I don't know...

    Cheers,

    Paul
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Tabs

    Further to before, Tabs (Chr$(9)) works OK for me but it depends on the Tab Width in Tools... Options as to where the tabs place characters. If the string goes beyond the tab then the tabs will not line up...

    You could try and build a string with multiple tabs based on the length of the first item

    i.e.
    Code:
    Select Case Len(strFruitName)
      Case 0 to 10
        strFruitName = strFruitName & Chr$(9) & Chr$(9) & Chr$(9)
      Case 11 to 15
        strFruitName = strFruitName & Chr$(9) & Chr$(9)
      Case >=16
            strFruitName = strFruitName & Chr$(9)
    End Select
    This will still not get round the fact that text is left-justified, so two digit numbers will not line up properly with one digit numbers etc.

    Why not report the data in your own control where you have better control?

    MsgBox is not designed as a reporting interface...

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width