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
Valore2 = Valore2.Replace(Chr(10)," ")
Valore2 = Valore2.Replace(Chr(13)," ")
ListaCose.AddTwoLines2(Valore2,Valore3,Valore)
Next
Cursor1.Close
End Sub
This sounds strange.I have yet to understand why, but I found that by using the replace before writing the record in the database, the problem is resolved.
As if I write the record without using the Replace command, and after reading the record does not resolve the problem.
ub SetCosaTextHeight
CosaTxt.Height = Max(60dip, 30dip + su.MeasureMultilineTextHeight(CosaTxt, CosaTxt.Text))
Labdove.top=CosaTXT.top + CosaTxt.Height
DoveTxt.top=Cosatxt.Top + CosaTxt.Height + Labdove.height
Labquando.Top=DoveTXT.top + DoveTxt.Height
QuandoTxt.Top=DoveTXT.top + DoveTxt.Height
BtnDate.Top=DoveTXT.top + DoveTxt.Height+5dip
LabCat.Top=Quandotxt.Top + Quandotxt.Height
TestoCat.Top=Labcat.Top + Labcat.height
Spnrname.Top=Labcat.Top+Labcat.height
Newcat.top=Labcat.Top+Labcat.height+5dip
LabNote.Top=Testocat.Top + testocat.Height
Notetxt.Top=LabNote.Top + Labnote.height
End Sub
Sub Salva_Click
Salvato = False
NewCatTxt=Testocat.text
If NewcatTxt="" AND Dovetxt.Text="" AND CosaTxt.Text="" Then
StartActivity("Lista")
Else
If NewcatTxt="" OR Dovetxt.Text="" OR CosaTxt.Text="" Then
ControllaImmissioni
Else
Try
Vcosa=CosaTxt.Text.Replace("'","''")
VcosaInizio=Vcosa.ToUpperCase.SubString2(0,1)
VcosaFine=Vcosa.SubString(1)
Vcosa=Vcosainizio&Vcosafine
Vcosa=Vcosa.Replace(Chr(13), " ")
Vcosa=Vcosa.Replace(Chr(10), " ")
Vquando=QuandoTxt.Text.Replace("'","''")
Vdove=DoveTxt.text.Replace("'","''")
SpinIndex=spnrname.SelectedIndex
NewCatTxt = TestoCat.Text 'spnrName.GetItem(SpinIndex)
Vcategorie= NewCatTXT
Vnote=NoteTxt.text.Replace("'","''")
If Salva.text= "Aggiorna" Then
Sql1.ExecNonQuery("UPDATE Articoli SET Cosa= '" & Vcosa & "', Dove= '" & Vdove & "',Quando='" & Vquando & "',Categoria='" & Vcategorie & "',Note= '" & Vnote & "'where Codice= '" & main.CodiceGlo & "' ")
Else
Sql1.ExecNonQuery("INSERT INTO Articoli VALUES(NUll,'" & Vcosa & "','" & Vdove & "','" & Vquando & "','" & Vcategorie & "','" & Vnote & "')")
ToastMessageShow(Main.Dlg7,False)'"Salvataggio completato"
Salvato=True
End If
Catch
Errore= LastException.message
If Errore.Contains ("is not unique") Then
Ret=Msgbox2(Main.Dlg11,Main.dlg4,"",main.dlg12,main.dlg13,Null)'"Una voce con questo nome esiste già nell'archivio",Attenzione,Correggo,Elimino
Select ret
Case -3
cosatxt.RequestFocus
cosatxt.SelectAll
Return True
Case -2
CosaTxt.Text=""
DoveTxt.Text=""
NoteTxt.Text=""
TestoCat.Text=""
CosaTxt.RequestFocus
End Select
End If
End Try
'Imposta data corrente
Dim t As Long
t = DateTime.Now
DateTime.DateFormat = "dd/MM/yyyy"'Formatta la data
Dim s As String
s = DateTime.Date(t)
'************************************
CosaTxt.Text=""
DoveTxt.Text=""
Quandotxt.text=s
NoteTxt.Text=""
TestoCat.Text=""
CosaTxt.RequestFocus
End If
End If
End Sub
Sub LoadLista
ListaCose.Clear
listacose.BringToFront
If main.ListaOpzioni=2 Then
Cursor1=Sql1.ExecQuery2("SELECT Codice,Cosa,Dove,Quando,Categoria,Note FROM articoli where cosa like ? ORDER BY cosa", Array As String(main.Cercacosa))
Else
If main.ListaOpzioni=3 Then
Cursor1=Sql1.ExecQuery2("SELECT Codice,Cosa,Dove,Quando,Categoria,Note FROM articoli where Dove like ? ORDER BY cosa", Array As String(main.CercaDove))
Else
If main.ListaOpzioni=4 Then
Cursor1=Sql1.ExecQuery2("SELECT Codice,Cosa,Dove,Quando,Categoria,Note FROM articoli where categoria like ? ORDER BY cosa", Array As String(main.Cercacategorie))
Else
Cursor1 = SQL1.ExecQuery("SELECT Codice,Cosa,Dove,Quando,Categoria,Note FROM Articoli ORDER BY Cosa")
End If
End If
End If
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
Msgbox(Valore2,"Normale")
Valore2=Valore2.Replace(Chr(13), " ")
Msgbox(Valore2,"Con Chr 13")
Valore2=Valore2.Replace(Chr(10), " ")
Msgbox(Valore2,"Con Chr 10")'**************** CORRECT LINE ****************
ListaCose.AddTwoLines2(Valore2,Valore3,Valore)
Next
Cursor1.Close
End Sub