Results 1 to 12 of 12

Thread: Writing to a file

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44

    Writing to a file

    Hi,

    I know this is pretty easy but I'm afraid I'm stuck at it:

    I want to open a text file (which is fine) and format the contents of it to be in different positions. ie. There are 5 rows of data and i just need each row to be in a different position in the file(I've got the numbers of the positions) Is it best to write out the contents to it to a new file.
    Not sure how to do this?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Can you give us an example of what you want done ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44
    Originally posted by plenderj
    Can you give us an example of what you want done ?
    Yes,

    I'm afraid this is all i've done so far

    strUnformattedFile = App.Path & "\" & App.EXEName & "\" & "strFile.txt"

    intFile = FreeFile

    Open strUnformattedFile For Input As intFile
    strLine = Input(1, #1)
    intCounter = intCounter + 1

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    No no, what do you want to do ?
    Swap the order of the lines, reverse each line, move each line in by a few spaces ...?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44
    Originally posted by plenderj
    No no, what do you want to do ?
    Swap the order of the lines, reverse each line, move each line in by a few spaces ...?
    just move each line by a space or two

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    So you want to indent lines a bit ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  7. #7

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44
    Originally posted by plenderj
    So you want to indent lines a bit ?
    yes, they have to be in the correct position,this is one line of the file. I need 10 spaces and not 11 between the first row and 2nd row and i'll need a few spaces between the 2nd last row and last row. I think the best way is to write out to another file but i'm not sure what the syntax is for outputing to a file
    eg.1GNPA10 552721II5 A 3000000EUR

  8. #8
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Uhn you're talking about spacing out rows, but that sample there shows spaced out columns.
    Which is it to be ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  9. #9

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44
    Originally posted by plenderj
    Uhn you're talking about spacing out rows, but that sample there shows spaced out columns.
    Which is it to be ?
    Yes but it has to be the correct amount of spacing
    ie. the first row has to have 10 spaces between it and the second row.
    What i'm wondering is do i write the changes to a new file or is it possible to make the changes within the existing file?
    Sorry for the confusion

  10. #10
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Uhn. You're being confusing again.
    Two examples. Which one is correct :

    Spacing Columns :
    Code:
    a b c d e f
    g h i j k l
    m n o p q r
    
    '' turns into
    
    a   b   c   d   e   f
    g   h   i   j   k   l
    m   n   o   p   q   r

    Spacing Rows :
    Code:
    a b c d e f
    g h i j k l
    m n o p q r
    
    '' turns into
    
    a b c d e f
    
    
    g h i j k l
    
    
    m n o p q r
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  11. #11

    Thread Starter
    Member
    Join Date
    Jun 2002
    Posts
    44
    spacing between the columns:

    ie.
    I need to format this line to look like the following line
    Code ID stat amount loc
    1GNPA10 023551AJ3 C 5000000DTC

    1GNPA10 023551AJ3 C 5000000 DTC 500000000


    So that between the 1st and 2nd column, there is 10 spaces and 3 spaces between the 2nd and 3rd.

    ie. code is = (1,6) position
    id = (18,12) ""
    stat = (30,1) ""

  12. #12
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Can you show me some sample lines from your data file ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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