Hey guys, here is how the text file looks now,



bl ank:'++':

2Hello:.++.:2som ething:.++.:3b lank:'++':

vdvdfv:.++.:bdfadf bfad:.++.:

abfdabdabadfb:'++':Line4:.++.:So fh sj:.++.:sddsds:'++':

If you actually see the lines which are blank has some spaces in them. It varies for each line,

i want the lines in format,


Hello:.++.:some thing:.++.:bl ank:'++':
2Hello:.++.:2som ething:.++.:3b lank:'++':
vdvdfv:.++.:bdfadf bfad:.++.:abfdabdabadfb:'++':
Line4:.++.:So fh sj:.++.:sddsds:'++':

after vb conversion.
The FILEBEFORE is created by vb by downloading string from online html. So i can't control it, but I have managed to add :.++.: and :'++': in the correct places.

after every :'++': its a new line and after every :.++.: the text should continue.

Is there a way to do it ?

I want the spaces between the text/numbers but not between my special character and a text.


vdjnj njnvj

12nj3 nfjdns

both the spaces between j and n and 3 and n shoud be maintained, even if they have 10 spaces in between but

:'++': mytext

now that space inbetween : and m should be removed and made in the same line

2 Years
Discussion Span
Last Post by Oxiegen

You need two string variables.

You can perform a line read using the appropriate filereader object and append the line into a temp string variable through a simple loop.
And for each line you can in addition perform some string manipulation.
So for each line the only contains "" or " ", you can skip to the next line so that empty lines do not get read into the permanent string variable.

Additionally, during the manipulation phase you can do a simple string replacement.
:'++' becomes vbNewLine (or vbCrLf) and so on.
By using two variables you can append the last know good string to the "real" string.

The String object contains a whole bunch of useful tools to do exactly what you're asking for.


It sounds like the file you created isn't useful to you. Why don't you post the original file (or file format) and then explain what you are trying to accomplish.

   Dim strArray As String()
    Dim tempValue As String = ""
    Dim valueList As List(Of String) = New List(Of String)

    Using sr As New StreamReader("C:\test.txt")
        Dim line As String

            line = sr.ReadLine

            If (Not line Is Nothing) Then
                If (line.Contains(":'++':")) Then
                    tempValue += line.Substring(0, line.IndexOf(":'++':") + 6)

                    tempValue = ""

                    Dim newValue = line.Substring(line.IndexOf(":'++':") + 6)

                    If (newValue.Contains(":'++':")) Then

                        tempValue += newValue.Substring(0, newValue.IndexOf(":'++':") + 6)

                        tempValue = ""

                    ElseIf (newValue.Contains(":.++.:")) Then
                        tempValue += newValue.Trim
                    End If

                ElseIf (line.Contains(":.++.:")) Then
                    tempValue += line.Trim
                ElseIf Not (String.IsNullOrEmpty(line)) Then
                    tempValue += line.Trim
                End If
            End If
        Loop Until line Is Nothing

    End Using

    ' For if you need an array 
    strArray = valueList.ToArray()

You can remove the part with the newValue variable.
It does almost the exaxt same thing as the three lines above it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.