[RESOLVED] formatting text output
I'm currently writing a application that ultimately outputs a configuration file as a text document. The question I have is how do I format the text so it looks like this: (I've used periods to show where I need spaces because I can't format it correctly in the message!)
host_name.....................CF1
alias.............................reception
address........................127.0.0.1
check_command.............check-host-alive
I've created a structure for all the parameters and hold these in a seperate collection. Basically what I'm thinking of doing is creating the whole file as one large string and then letting the user preview the config file in a mulitline textbox before writing it out to disk.
Question is how can I format the string so the text aligns correctly, adding spaces doesn't seem to work ?
Re: formatting text output
The easy answer is to change your textbox's font to something like "Lucida Console." That way, all of the characters are the exact same width. Then to space everything out, use the tab character (chr(9)). You're still going to need some logic to find out how many tab characters to insert on based on length (a tab character is 8 positions), but shouldn't be too difficult.
Re: formatting text output
Thanks i'll give that a go :thumb:
Re: [RESOLVED] formatting text output
Also look at padding your string, using string.padleft, string.padright... check out an example of a question similar to this in this thread:
http://www.vbforums.com/showthread.php?t=376593