Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How do I insert the next line character into my txt-based file in Visual BAsic .NET

Here is how my code goes:

 

' 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 it's "/n")

 

Thanks,

Serj

http://www.enhancementresearch.com

  • *Experts*
Posted

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

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.

Dim s As String = "Line1" & Environment.NewLine & "Line2"

  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...