Results 1 to 4 of 4

Thread: [RESOLVED] formatting text output

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Resolved [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 ?

  2. #2
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: formatting text output

    Thanks i'll give that a go

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    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
  •  



Click Here to Expand Forum to Full Width