![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
strange symbol
The following code works well apart from one slight floor. I can’t seem to figure it out.
The job it is doing it essentially removing a given section of the string by splitting it up and then joining it back together again (I’m sure the process it obvious by the code). However when it is displayed in a text box on a form it has some wired rectangle character on the last line by itself. At first I though it was the process of splinting it and putting it back together but if I comment out the line that clears the array it seems that the character disappears. That then made me think it was the fact that an element of an array is cleared out and not removed but in changing the value of the array element to “” it still has that symbol. What is the symbol called (a little rectangle that is tall and thin)? Any I ideas on what’s causing it? 'declares an array
Dim ping_stdout_array() As String
'splits the string 's' into lines and then passes each string into array ping_stdout_array
ping_stdout_array = s.Split(vbLf)
'iterates 0 - the size of the array
For i As Integer = 0 To UBound(ping_stdout_array)
'declares a variable type boolean
Dim t_or_f As Boolean
'searches each line of the array for the word "exit" and returns - true or false into
'the 'boolean' variable
t_or_f = InStr(ping_stdout_array(i), "exit")
'conditional - if true then clear array element 'i'. 1 is the number of elements to clear
If t_or_f = "True" Then
'Array.Clear(ping_stdout_array, i, 1)
End If
Next
'joins the array back together and passes it back into the s variable
s = String.Join(vbLf, ping_stdout_array)
'displays stdout of ping to "textbox" on form1
TextBox.Text = s |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 850
Rep Power: 4
![]() |
I think the multiline edit control needs a CR-LF sequence for the end of lines.
Try using vbCrLf in your join statement. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
It got rid of the symbol at the end of the string. But put one at the end of each line.
I guess that’s the sysmbol for Cr (carriage return) then. Thanks for the swift reply |
|
|
|
|
|
#4 | |
|
Expert Programmer
Join Date: Jun 2005
Posts: 850
Rep Power: 4
![]() |
Quote:
Otherwise you would be leaving the original CRs in the strings after splitting, which would give your two CRs and one LF when you joined them back again. |
|
|
|
|
|
|
#5 |
|
Programmer
Join Date: Feb 2006
Location: 127.0.0.1
Posts: 35
Rep Power: 0
![]() |
That puts three of them next to each other on a new line.
But I then tried every combination as I see what you are getting at and I found one that works properly: ping_stdout_array = s.Split(vbCrLf) … s = String.Join(vbCr, ping_stdout_array) thanks for the help The Dark ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wierd compile Error. Need help please. | Keiyentai | Java | 7 | Aug 19th, 2006 1:35 AM |
| C++ OWL What am I doing wrong | Vagabond | C++ | 7 | Mar 24th, 2006 5:31 PM |
| Problem Compiling this program | OUfanAP12 | Java | 4 | Nov 7th, 2005 7:27 PM |
| inserting symbol into a string | Bernard | C | 26 | Aug 2nd, 2005 3:30 AM |
| Errors in microjava midlet | freddielj | Java | 1 | Apr 8th, 2005 11:02 AM |