For... Next loop does not work

I have this code in a loop, but does not work …

Dim i As Integer Dim GIMA As RecordSet Dim ImagenCarp As FolderItem Dim Foto As Picture GIMA = Android.SQLSelect("SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia='" + Trim(PopPlanta.Text) + "'AND HoraEvi='" + Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 0)) + "'") ImagenCarp = SpecialFolder.Windows.Child("/Temp/") Foto=GIMA.Field("FotoEvidencia").PictureValue For i = 0 To ListaDetalles.ListCount -1 Foto.Save(ImagenCarp.Child("/TempXojo/" + ListaDetalles.Cell(ListaDetalles.LastIndex, 1) + ".jpg") , Picture.SaveAsJPEG) MsgBox "Admin" Next
You should keep the number of images based on the number of records in the ListBox.
I just saved the first image

In that I’m wrong?

ok… you read a photo from a data base
then you save that photo TO THE SAME FILE supposedly as many times as you have rows in ListaDetalles
[lastindex only changes on ADDROW, which I do not see anywhere]

So my question is. DOES ListaDetalles have anything in it? is so, How did it get there?

Full COde

[code] ListaDetalles.DeleteAllRows
CONSULTA = Android.SQLSelect(“SELECT * FROM infoext WHERE OCRs=’” + Trim(PopPlanta.Text) + “‘AND FechaRevs=’” + Trim(PopFecha.Text) + “’”)
If CONSULTA <> Nil Then
While Not CONSULTA.EOF
ListaDetalles.AddRow(CONSULTA.Field(“HoraRevs”).StringValue)
ListaDetalles.Cell(ListaDetalles.LastIndex, 1)=CONSULTA.Field(“Ubicacions”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 2)=CONSULTA.Field(“CondicionesCilindros”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 3)=CONSULTA.Field(“Observaciones”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 4)=CONSULTA.Field(“Hologramas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 5)=CONSULTA.Field(“CollarinPQSs”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 6)=CONSULTA.Field(“CapacidadAreas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 7)=CONSULTA.Field(“AgenteAreas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 8)=CONSULTA.Field(“Alturas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 9)=CONSULTA.Field(“Obstruccions”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 10)=CONSULTA.Field(“Delimitacions”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 11)=CONSULTA.Field(“Senalamientos”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 12)=CONSULTA.Field(“EtiquetaInspeccions”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 13)=CONSULTA.Field(“Manometros”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 14)=CONSULTA.Field(“Cornetas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 15)=CONSULTA.Field(“Mangueras”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 16)=CONSULTA.Field(“Manerals”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 17)=CONSULTA.Field(“SeguroMetalicos”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 18)=CONSULTA.Field(“ColaRatas”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 19)=CONSULTA.Field(“Ganchos”).StringValue
ListaDetalles.Cell(ListaDetalles.LastIndex, 20) = PopPlanta.Text
CONSULTA.MoveNext
Wend
CONSULTA.Close
End If

Dim i As Integer
Dim GIMA As RecordSet
Dim ImagenCarp As FolderItem
Dim Foto As Picture
GIMA = Android.SQLSelect(“SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia=’” + Trim(PopPlanta.Text) + “‘AND HoraEvi=’” + Trim(ListaDetalles.Cell(ListaDetalles.LastIndex, 0)) + “’”)
ImagenCarp = SpecialFolder.Windows.Child("/Temp/")
Foto=GIMA.Field(“FotoEvidencia”).PictureValue
For i = 0 To ListaDetalles.ListCount -1
Foto.Save(ImagenCarp.Child("/TempXojo/" + ListaDetalles.Cell(ListaDetalles.LastIndex, 1) + “.jpg”) , Picture.SaveAsJPEG)
Next
[/code]

Ok… you are STILL saving the photo over and over again to the same file!

replace LASTINDEX with “I”

LASTINDEX ONLY CHANGES WHEN YOU ADD A ROW… so it is NOT changing inside you for/next loop.
The loop is working fine… you are just doing the same thing over and over

You suggest me in this way?

Foto.Save(ImagenCarp.Child("/TempXojo/" + ListaDetalles.Cell(ListaDetalles.LastIndex, i) + ".jpg") , Picture.SaveAsJPEG)

Error: UnsoportedFormatException…

no
Foto.Save(ImagenCarp.Child("/TempXojo/" + ListaDetalles.Cell(i, 1) + “.jpg”) , Picture.SaveAsJPEG)

DO NOT USE LASTINDEX… IT IS NOT CHANGING

This indicates that this line should I do the same? Because if not, I will bring the same image for all records …
In the Recordset

This indicates that this line should I do the same? Because if not, I will bring the same image for all records ..
GIMA = Android.SQLSelect("SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia='" + Trim(PopPlanta.Text) + "'AND HoraEvi='" + Trim(ListaDetalles.Cell(i,1)) + "'")

I have provided all the information I can… either if fixes your situation or it doesn’t… but I’m afraid the language barrier is making it difficult for me to understand either your problem, or how better to explain my responses.

Sorry, I use google translator.

change this line of code too?

GIMA = Android.SQLSelect("SELECT FotoEvidencia FROM evidenciaext WHERE NombreEvidencia='" + Trim(PopPlanta.Text) + "'AND HoraEvi='" + [b]Trim(ListaDetalles.Cell(i,1))[/b] + "'")

I have not, but I do keep the same image for all records

Maybe a bit off-topic, but Mr Hernandez, aren’t you going a bit over your limits? It’s obvious that your knowledge is not that big about programming, and your already trying to run with databases.

As you say, it’s not as geande my knowledge, if it were not so there would be these forums … With the help of Dave I cleared my doubts …

No hablo Ingls.

Mathias, he has the rights of asking for help. We can try to help or not. Never deny his rights about asking. His limits are listed here: https://forum.xojo.com/4307-forum-etiquette-and-notices and he did not cross any.

Sorry people! I was not trying to offend Mr Hernandez. I don’t meant he crossed any lines.
I really meant his limits. (Meant as advice, to study the basics, before trying to do big stuff)

I did not meant that he cannot ask questions here. Because I also do, also about very stupid things.

Sorry if I offended anyone, or if I expressed myself wrong.
I really didn’t meant to do that.

¿Más vale preguntar en el canal Español?

Yo digo, aquela persona que tenga gusto de ayudar, bienvenido… Y aquella persona que simplemente no aportar nada, que omita su comentario…

Utiliza el canal español del foro de Xojo si tienes cualquier tipo de problema con el inglés. En el resto de canales el inglés es el idioma oficial.

Por cierto Mathias estaba pidiéndote disculpas por si su mensaje ha molestado y/o haberse malentendido, cosa loable y no creo que merezca una crítica o respuesta así. Aquí estamos todos para ayudarnos los unos a los otros y ni todo el mundo habla inglés ni por supuesto en español.

Escribe un nuevo mensaje en el foro Español y verás que hay gente que puede ayudarte.