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

FILEBEFORE

Hello:.++.:something:.++.:

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,

FILEAFTER

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.

like

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

What code have you tried so far?

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

        Do
            line = sr.ReadLine

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

                    valueList.Add(tempValue)
                    tempValue = ""

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

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

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

                        valueList.Add(tempValue)
                        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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.