943,952 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 5866
  • VB.NET RSS
Jun 4th, 2008
0

How do I replace Enter

Expand Post »
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:
VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
JeffN00B is offline Offline
1 posts
since Jun 2008
Jun 9th, 2008
0

Re: How do I replace Enter

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.

VB.NET Syntax (Toggle Plain Text)
  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.
Reputation Points: 25
Solved Threads: 5
Newbie Poster
dadelsen is offline Offline
22 posts
since Jun 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Vb 4/5 to Vb.net
Next Thread in VB.NET Forum Timeline: Datagrid





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC