|
-
Jan 31st, 2006, 09:09 AM
#1
Thread Starter
Hyperactive Member
[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 ?
-
Jan 31st, 2006, 09:27 AM
#2
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.
-
Jan 31st, 2006, 09:35 AM
#3
Thread Starter
Hyperactive Member
Re: formatting text output
Thanks i'll give that a go
-
Jan 31st, 2006, 03:25 PM
#4
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
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
|