Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2004
    Posts
    178

    Unanswered: need help with formating text file

    i have setup a code to output a query to a text file to the way i want it but i need to get this code to have 2 spaces no mater how mush is in it if it only has 1 letter i need it to put in a space

    rs!cert & " " & _

    the cert could have 1 letter 2 letters or 4 letters

    can any1 help

  2. #2
    Join Date
    Mar 2006
    Posts
    163
    Can you post your current code?

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    if len(cert) = 0 then
    ...
    elseif len(cert = 1 then
    ...
    etc?
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    I am a little confused by your question. Typically when you are outputting to a file you want the field to always take up n spaces. If the data is 1 character long you pad it with n spaces to reach the full length of n characters. There is an easy way to accomplish this. If you have varaible length data that needs to fit into 10 characters then do the following:

    Left(rst!Cert & " ",10)

    If rst!Cert is 4 characters long then 10 spaces will be appended to Cert and you will take Cert plus 6 spaces using the Left function.

    You could have also used the String function to get the 10 spaces like:

    String(10," ") instead of " ".

  5. #5
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    DCKunkle that wont work he wants a minimum size of two not a size of 2, though i have to admit i can't think why

    Quote Originally Posted by georgev
    if len(cert) = 0 then
    ...
    elseif len(cert = 1 then
    ...
    etc?
    that seems more complex than required

    Code:
    While Len(cert ) < 2
    cert = " " & cert 
    Wend
    Last edited by m.timoney; 02-07-07 at 05:37.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by m.timoney
    that seems more complex than required
    I guess you're right, but it'd work (I think)
    George
    Home | Blog

  7. #7
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    yes it would work, but where's you sense of elegance?
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Over there... -->
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •