How do I replace Enter

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2008
Posts: 1
Reputation: JeffN00B is an unknown quantity at this point 
Solved Threads: 0
JeffN00B JeffN00B is offline Offline
Newbie Poster

How do I replace Enter

 
0
  #1
Jun 4th, 2008
I have a headache over this one. what i am trying to do is take the text from a multi-line textbox and put it into one line so i can put that into a file for another program to read one line at a time. is there some way to do this so the file is small and streamreader can read one line at a time.

heres the code that writes to the file and compiles the textbox:
  1. Dim ENTER As String = Chr(13)' I Tried vbcrlf here but it still didnt work.
  2. Dim delimiters() As Char = {CChar(ENTER)}
  3. Dim TD, D1, D2, D3, D4, inp() As String
  4. Dim ipart As IEnumerator
  5. If TextBox4.Text = Nothing Then
  6. D2 = "_"
  7. Else
  8. D2 = TextBox4.Text
  9. End If
  10. D1 = TextBox1.Text
  11. inp = TextBox2.Text.Split(delimiters)
  12. ipart = inp.GetEnumerator
  13. While ipart.MoveNext
  14. D3 = D3 & Mid(ipart.Current.ToString, 1, ipart.Current.length - 1) & "Û"
  15. End While
  16. inp = TextBox3.Text.Split(delimiters)
  17. ipart = inp.GetEnumerator
  18. While ipart.MoveNext
  19. D4 = D4 & Mid(ipart.Current.ToString, 2, ipart.Current.length) & "Û"
  20. End While
  21. sd.WriteLine(D1 & "þ" & D2 & "þ" & D3 & "þ" & D4)

Thanks in advanced
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 22
Reputation: dadelsen is an unknown quantity at this point 
Solved Threads: 5
dadelsen dadelsen is offline Offline
Newbie Poster

Re: How do I replace Enter

 
0
  #2
Jun 9th, 2008
The following code replaces the CR+LF that separates the lines in a multiline textbox by a text that will hopefully never be entered by any user.
I tested this with german culture settings.

  1. Dim sLine As String
  2. sLine = Replace(TextBox1.Text, vbCr & vbLf, ":AxAxA:")
  3. Dim writer As New StreamWriter("temp.txt", False)
  4. writer.WriteLine(sLine)
  5. writer.Close()
  6.  
  7. Dim reader As New StreamReader("temp.txt")
  8. sLine = reader.ReadLine
  9. reader.Close()
  10. TextBox2.Text = Replace(sLine, ":AxAxA:", vbCr & vbLf)
Last edited by dadelsen; Jun 9th, 2008 at 4:36 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum


Views: 2456 | Replies: 1
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC