Moving to the next line in my file

sergeysagan

Member
Joined
Sep 10, 2003
Messages
7
How do I insert the next line character into my txt-based file in Visual BAsic .NET
Here is how my code goes:

Code:
 Now, finaly lets add the actual link
FileOpen(1, LinkFileDir LinkFileName, OpenMode.Input)
 Put the contents of the file into our variable
LinkFileValue = InputString(1, LOF(1))
 Check to see where in the string we need to be.
LinkFilePos1 = InStr(1, LinkFileValue, "<tr style=mso-yfti-irow:40;mso-yfti-lastrow:yes>")
 Manupulate the sting adding our new link
LinkFileValue = LinkFileValue.Insert(LinkFilePos1, " ")
Now this " " needs to be changed to a carriage return(Next Line, Enter Key, etc.) what would I put, I searched all of VB help and could find out how to do it.
(By the way in C its "/n")

Thanks,
Serj
http://www.enhancementresearch.com
 
You really really should get away from the old VB6 ways of file access. I also see you using InStr() which you should not do. Look at the System.IO namespace for file manipulation functionality that is supported by the .NET Framework, and use
Code:
LinkFileValue.IndexOf("<tr... etc")
instead of that InStr line. Read up on the String class for info on .NET string manipulation.

To answer your question, use Environment.NewLine to insert a newline.
Code:
Dim s As String = "Line1" & Environment.NewLine & "Line2"
 
Back
Top