|
-
Nov 7th, 2000, 03:21 AM
#1
Thread Starter
New Member
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
-
Nov 7th, 2000, 04:43 AM
#2
Addicted Member
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.
-
Nov 7th, 2000, 05:49 AM
#3
Fanatic Member
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...
-
Nov 7th, 2000, 05:59 AM
#4
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|