Results 1 to 7 of 7

Thread: very odd problem with file print

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    very odd problem with file print

    In a module I have

    VB Code:
    1. Global fileff As Integer

    In Form1 on form_load I have

    VB Code:
    1. fileff = FreeFile
    2.     Open "C:blah.txt" For Append As #fileff

    Then in module1, when i do something like

    Print #fileff, "hello"
    Print #fileff, "there"

    it appears in the file as:
    hello
    there

    shouldn't it be: hellothere (this is how i want it)

  2. #2
    Lively Member
    Join Date
    Feb 2005
    Location
    California
    Posts
    97

    Re: very odd problem with file print

    Ever time you use the Print#....
    It'll create a new line.

    You would need to say

    Code:
    Print #fileff, "hello" & "there"
    Or
    Print #fileff, "hellothere"
    Hope that helps

  3. #3
    Addicted Member sigid's Avatar
    Join Date
    May 2006
    Location
    Massachusetts, USA
    Posts
    182

    Re: very odd problem with file print

    Another way to do this is as follows:
    Print #fileff, "hello"; ' Note the semi-colon which supresses the CRLF at line end
    Print #fileff, "there"

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: very odd problem with file print

    but i want everything to appear on 1 line so if i do

    Print #fileff, "HelloThere"

    Print #fileff, "some more!!"

    etc etc..

    the file would be like this:

    HelloTheresome more!!
    is this not possible?

  5. #5
    Lively Member
    Join Date
    Oct 2004
    Posts
    91

    Re: very odd problem with file print

    No, I think it is the same as with printing to the form. Every time you write print it will make a new line, if you add ; it should print to the same line. Alternatively you could print "hello" & "there", but I have a feeling you are in a loop with variables to print so that might not be the best solution. So all in all, I believe (don't have vb6 here at the moment" that if you write
    VB Code:
    1. Print #ffile; "Hello";
    2. Print #ffile; "There"
    It should work.

    Edit: wow in the time it took to write that there was a lot of posts...

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: very odd problem with file print

    ahhhh, sigid, awesome!!

    thats exactly what I needed!!!

    Thanks mate

    Edit* and John hehe i cant believe the ';' makes such a big diff for me!

  7. #7
    Addicted Member sigid's Avatar
    Join Date
    May 2006
    Location
    Massachusetts, USA
    Posts
    182

    Re: very odd problem with file print

    Of course:
    Print #fileff, "HelloThere"; ' Again, the semi colon is important!
    Print #fileff, "some more!!"

    will result in the file containing "HelloTheresome more!!"

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