Hi guys,
This problem of mine is driving me nuts, and I'm hoping someone can help! I'm trying to display lists of information in a message box (to enable the user to visually check what is about to be entered), formatting the information so that the 'columns' line up with each other, but I can't work out how to do this effectively.
Consider the following sample code to illustrate the basics of what I'm trying to accomplish:
'----------------------------------------------
Sub Main
a = "apple"
b = "banana"
c = "carrot"
x = 110
For x = 95 to x
strMsgBox = strMsgBox & a & x & Chr(9) & b & x & _
Chr(9) & c & x & Chr(13) & Chr(10)
Next x
msgbox strmsgbox
End Sub
'----------------------------------------------
[/color blue]
If you run the code, you'll see that once the value of x goes into the 100's, the formatting changes, and the lists no longer line up.
I've tried experimenting with Print and the Tab function too. For example: Print a & x Tab(20) b & x Tab(40) c & x Tab(60)[/color blue]
This type of formatting is exactly what I want (that is, the words line up with the specific tab stops regardless of how long they are). But as in the earlier example, I need to be able to 'format' the string using a For Next loop because it is quite complex and involves variables that change in value.
Can anyone help by suggesting how I might be able to display the type of string obtained in the first example, with the lists of words lining up according to specific tab stops?
Your assistance would be very very appreciated, as I've had many unsuccessful attempts at doing this - some of which look successful at first, but end up failing miserably when I experiment with different substring lengths!
Tim
This problem of mine is driving me nuts, and I'm hoping someone can help! I'm trying to display lists of information in a message box (to enable the user to visually check what is about to be entered), formatting the information so that the 'columns' line up with each other, but I can't work out how to do this effectively.
Consider the following sample code to illustrate the basics of what I'm trying to accomplish:
'----------------------------------------------
Sub Main
a = "apple"
b = "banana"
c = "carrot"
x = 110
For x = 95 to x
strMsgBox = strMsgBox & a & x & Chr(9) & b & x & _
Chr(9) & c & x & Chr(13) & Chr(10)
Next x
msgbox strmsgbox
End Sub
'----------------------------------------------
[/color blue]
If you run the code, you'll see that once the value of x goes into the 100's, the formatting changes, and the lists no longer line up.
I've tried experimenting with Print and the Tab function too. For example: Print a & x Tab(20) b & x Tab(40) c & x Tab(60)[/color blue]
This type of formatting is exactly what I want (that is, the words line up with the specific tab stops regardless of how long they are). But as in the earlier example, I need to be able to 'format' the string using a For Next loop because it is quite complex and involves variables that change in value.
Can anyone help by suggesting how I might be able to display the type of string obtained in the first example, with the lists of words lining up according to specific tab stops?
Your assistance would be very very appreciated, as I've had many unsuccessful attempts at doing this - some of which look successful at first, but end up failing miserably when I experiment with different substring lengths!
Tim