String Manipulation

cnicolapc

Active Member
Licensed User
Longtime User
Hi,
does anyone know how to convert a string that contains CRLF in a string of text without CRLF?
Thank You.
Nicola
 

cnicolapc

Active Member
Licensed User
Longtime User
hi,
Thank you very much.
I tried to solve this problem, in my listview looks like.
Have an idea?
Thank You
Nicola
 

Attachments

  • Testo_CRLF.jpg
    Testo_CRLF.jpg
    7.8 KB · Views: 301
  • shot_000009.jpg
    shot_000009.jpg
    4.8 KB · Views: 324
Last edited:
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi Rolf,
Thank you
I tried but the result remains the same.
Text is hidden in Listview as in the previous post.
This is a part of code that I inserted.
B4X:
Valore2=Cursor1.getstring("Cosa")
      Valore2=Valore2.Replace(Chr(13),"")
            ListaCose.AddTwoLines2(Valore2,Valore3,Valore)
            Next
I also tried with
Valore2=Valore2.Replace(Chr(10),"")
but with no result

Thank You
Nicola
 
Last edited:
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Have you tried...
B4X:
Valore2=Valore2.Replace(Chr(13) & Chr(10),"")

Rolf
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi Rolf,
Thanks for your help, but the problem is not solved.
When I put the text I press Enter on the keyboard (so the return should Chr (13) & Chr (10) )
or perhaps it could be a different code?
Nicola
 
Upvote 0

cnicolapc

Active Member
Licensed User
Longtime User
Hi Klaus
here is the code
B4X:
For i = 0 To Cursor1.RowCount - 1
        Cursor1.Position = i
      valore=Cursor1.GetString("Codice")
      valore2=Cursor1.getstring("Cosa")
      Valore3=Cursor1.getstring("Dove")
      If valore2.Length >=30 Then
      Valore2=valore2.SubString2(0,30)&"..."
      End If
      If valore3.Length >=39 Then
      Valore3=valore3.SubString2(0,39)&"..."
      End If
      
            ListaCose.AddTwoLines2(Valore2.Replace(Chr(13)& Chr(10),""),Valore3,Valore)
            Next
   Cursor1.Close
Thank You
Nicola
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly is the content of Valore2 ?

In the meantime try this code:
B4X:
For i = 0 To Cursor1.RowCount - 1
  Cursor1.Position = i 
  Valore=Cursor1.GetString("Codice")
  Valore2=Cursor1.getstring("Cosa")
  Valore2 = Valore2.Replace(Chr(13),"")
  Valore2 = Valore2.Replace(Chr(10),"")
  Valore3=Cursor1.getstring("Dove")
  If Valore2.Length >=30 Then
    Valore2=Valore2.SubString2(0,30)&"..."
  End If         
  If Valore3.Length >=39 Then
    Valore3=valore3.SubString2(0,39)&"..." 
  End If                          
   ListaCose.AddTwoLines2(Valore2,Valore3,Valore)
Next     
Cursor1.Close
Best regards.
 
Last edited:
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
You can see what is going on a little with this too


B4X:
Sub Activity_Create(FirstTime As Boolean)

Dim theline As String

theline = Chr(13) & "We love to go to " & CRLF & " the store." & Chr(9) & Chr(13)

cleanword(theline)

End Sub


Sub cleanword(bigword As String)

Dim c As Int
Dim BuildWord As String
'
' go through the bigword - character by character
'
Log("##################### START ##################################")
Log("Big Word Length is: " &  bigword.Length )

For c = 0 To bigword.Length

   ' Examine each character that is not
   ' a valid character and report it to the log
   'BuildWord = BuildWord & bigword.CharAt(c)
   'Log(BuildWord)
   
   MyASci = Asc(bigword.CharAt(c)) 

 
   
      If MyASci < 32 Then Log("**Chr(" & MyASci & ") was found! at Position: " & c )
      If MyASci > 126 Then Log("**Chr(" & MyASci & ") was found! at Position: " & c )
       
      
 
Next

End Sub
 
Last edited:
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
This line
B4X:
For c = 0 To bigword.Length
needs to be changed to
B4X:
For c = 0 To bigword.Length - 1

Otherwise you will get an error

That code just shows that CRLF adds a Chr(10). Did you examine Valore2 in your original program with your cleanword routine?

Rolf
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
it seems the problems is in the Replace function - it does not replace chr(10).

Attached is a little test project that shows the problem.
 

Attachments

  • listboxtest.zip
    6.6 KB · Views: 270
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
:BangHead:
Manchmal sieht man den Wald vor lauter Bäumen nicht!

Sometimes you don't see the forest because of all the trees!
(Germam proverb)

Thanks Klaus and Andrew

Rolf
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Yes, works now.
I uploaded the corrected project.

(See Klaus' post.)

Rolf
 

Attachments

  • listboxtest.zip
    6.6 KB · Views: 265
Upvote 0
Top