Problem formatting

Hi team, I have a formatting problem. I try to explain myself.
I have a table that I’m reading values ​​from… most of the values ​​don’t expect a carriage return, but the ones that do need to be separated. For each value I have to write a dedicated line.

For values ​​without carriage return the code works, for the others, they wrap and the formatting comes out all wrong. I try to write the code.
My Code:

Dim LunghezzaDescrizione as string  'String for single description no chr(13)
Dim words() As string 'Array
Dim PezzoStringa as string 'Temp string

For row As Integer =  0 To maxRow
  
  LunghezzaDescrizione=""
  LunghezzaDescrizione=ListBoxInventario.CellTextAt(row,7)
  LunghezzaDescrizione=LunghezzaDescrizione.Left(70)   ''''i need first 70 chars
  LunghezzaDescrizione=LunghezzaDescrizione.ReplaceLineEndings(EndOfLine.Windows)
  
  
  if LunghezzaDescrizione.Contains(chr(13)) =True  then ' if i see goback char, create an array for any goback
    
    words.RemoveAll
    words = LunghezzaDescrizione.Split(chr(13))    'create an array for any ch(13)
    For i As Integer = words.FirstIndex To words.LastIndex 'print line for any array created
      PezzoStringa=words(i)
      tisx.WriteLine("\\\\\\\\\\\\\\\\\\\")
      tisx.WriteLine(row.ToString + " ** " + PezzoStringa + " ** ")
    Next
    
    
  else
    tisx.WriteLine("")
    tisx.WriteLine(row.ToString + " ** " + LunghezzaDescrizione + " ** ") 
  end if
  
Next

For example, if there are 3 articles written in the same box on several lines, I have to write each article on a separate line, keeping the number of the position, like the number 273 in the example.

The problem is similar to line character remains memorized

Without paying much attention to your problem, those lines called my attention, and can be contributing to unexpected results.

The first one change chr(10) or chr(13) to chr(13)+chr(10)
The second one removes the chr(13) but keeps the chr(10)

Is that by design?

Hi Rick A, what does it mean Is that by design?

Means “Is it intentional? Did you want it this way?”

Sorry I’m not very good with English. I have to sort some values not written by me, I noticed that in this database there are carriage returns, I thought it was the chr(13), but I just replaced the chr(13) with chr(10)+chr(13) seems to work … now I have to do some more verification.

Don’t forget the process of ReplaceLineEndings before doing anything with parsing line endings.

1 Like

It’s the first thing I did before analyzing the content… LunghezzaDescrizione=LunghezzaDescrizione.ReplaceLineEndings(EndOfLine.Windows)

What Rick is suggesting is that you change this line to

words = LunghezzaDescrizione.Split(EndOfLine.Windows)

since you already changed the line endings.

ok