Results 1 to 2 of 2

Thread: Unix Text Files

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    3
    I'm sure that, at least once, you downloaded a text file that was written in Unix environment and had those nasty black boxes instead of line brakes. This isn't so bad when you need to read the file as you can manually press enter every time you encounter one or simply open it in wordpad instead of notepad, but the problem appears if you actually need to process such a file from inside visual basic. If anyone knows how to transform such files pretty, pretty, pretty please HELP! Thanks in advance,

    Kosta Krauth


  2. #2
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217
    The problem is that UNIX text files use only LineFeeds (or is it Carriage Returns? I can't remember, but it is only one of them) to indicate a new line, while Windows uses both CR and LF. To solve the problem in VB, if you're opening the file and placing it into a TextBox or RichTextBox then simply use the following:

    Text1.Text = Replace(Text1.Text, vbCr, vbCrLf)

    (NOTE: if it is a Line Feed instead of the Carriage Return simply use vbLf instead of vbCr)

    Otherwise, you can read the entire contents of the file into a string and perform the same operation, and then save the file again (which will now be in the Windows standard).


    Hope this is what you needed. Bye.

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