I'm having a problem recently, a logical issue so hard to determine various examples.
I need the text that is inserted in textbox, which has been altered or modified or twisted to have a proper format through line accordance and constant white spaces etc. And some cases I stuck at defining the If statement within the loop. Here's an example of a text I'm trying to reformat
3/7/ 12 3:50PM 108 02 6060001108 00:00'48" .. .. 3 / 7
/12 3:51PM 102 01 00 49 17
34973369 00:00'33" ....
3/7/12 3:51P M 1
02 02 00491734973369 00:00'43" ....
3/ 7/12 3:54PM 102 02 00491734973369
00:00'2 1" ....
3/7/12 3: 55PM 102 02 044659912
00:00'24" ....
and the way it should look like is :
3/7/12 3:50PM 108 02 6060001108 00:00'48" ....
3/7/12 3:51PM 102 01 00491734973369 00:00'33" ....
3/7/12 3:51PM 102 02 00491734973369 00:00'43" ....
3/7/12 3:54PM 102 02 00491734973369 00:00'21" ....
3/7/12 3:55PM 102 02 044659912 00:00'24" ....
And here's the code that I filter the message in the textbox.
Code:
 Dim fjalet As String = txtReceive.Text
            Dim status As Boolean
            Dim strfilter As String = ""
            Dim oldfilter As String = ""
            For Each b As Char In fjalet
                If status = True Then
                    If b <> oldfilter Then
                        status = False
                        strfilter = strfilter + b
                    End If
                Else
                    strfilter = strfilter + b
                End If
                If b = " " Then
                    status = True
                End If
                oldfilter = b
            Next
            'Since the bytes that are converted after they're received in the Data Received event have white spaces
            'and when trying to split them into smaller parts of that string, resulsts some logical errors by
            'inserting each of the characters into designated columns of the database table thus to prevent that
            'a replacement of every white space next to randomly selected character with the sole character is a must.

            strfilter = strfilter.Replace(": ", ":")
            strfilter = strfilter.Replace("/ ", "/")
            strfilter = strfilter.Replace(" /", "/")
            strfilter = strfilter.Replace("< ", "<")
            strfilter = strfilter.Replace("A ", "A")
            strfilter = strfilter.Replace(" i", "i")
            strfilter = strfilter.Replace(" >", ">")
            strfilter = strfilter.Replace(". 0", ".0")
            strfilter = strfilter.Replace(". .", "..")
            strfilter = strfilter.Replace("....", ".... ")
            strfilter = strfilter.Replace(vbCrLf + "/", "/")
            strfilter = strfilter.Replace("* ", "*")
            strfilter = strfilter.Replace("-", "")
            strfilter = strfilter.Replace("P ", "P")
            strfilter = strfilter.Replace(" M", "M")
            strfilter = strfilter.Replace("Date", "")
            strfilter = strfilter.Replace("D ate", "")
            strfilter = strfilter.Replace("Time", "")
            strfilter = strfilter.Replace("Ext.", "")
            strfilter = strfilter.Replace("CO", "")
            strfilter = strfilter.Replace("Dial", "")
            strfilter = strfilter.Replace("number", "")
            strfilter = strfilter.Replace("Duration", "")
            strfilter = strfilter.Replace("Code", "")

            Dim split2 As String() = strfilter.Split(New [Char]() {" "c, CChar(vbTab), CChar(vbCrLf), CChar(vbCr), CChar(vbLf)})
            Dim listfilter As New List(Of String)(split2)
            Dim i As Integer = 0
            Dim itemnew As String = ""
            For Each item As String In split2
                If item.Trim = "" Then
                    listfilter.RemoveAt(i)                   
                    i -= 1
                End If
                i += 1
            Next
I'm using Microsoft Visual Studio 2010 Ultimate version with Microsoft SQL Server Management Studio. This code is being fired on mouse click event of a button control. This is a snippet of my code there are more filtering after but here is what should be changed.