B4J Question How can i display MsgBox in a loop with Wait For

Brian Michael

Active Member
Licensed User
Hi, im trying to show a Messagebox if an item of a list exist, if the item exist i want to ask if you want Replace the data or just Decline.

I use this code:

B4X:
Public Sub importData(Database As List, newItems As List, option As Int) As ResumableSub
    Log("Importando datos... Productos a importar: " & newItems.Size)
    Dim DB As List = Database
    Dim a As Int = 0
    For Each item As Map In newItems
            a=a+1
            Log("Verificando dato: " & a)
        If option = 0 Then   
            If DB.IndexOf(item.Get("CODIGO")) = -1 Then
                For i = 0 To DB.Size - 1
                    'Log("Verificando ML " & (i+1) & " de " & MasterList.Size)
                    Dim tempRecord As Map = DB.Get(i)
                    If item.Get("CODIGO") == tempRecord.Get("CODIGO") Then
                        Wait For (ShowDialog(item)) Complete (Result As Int)
                        If Result = -1 Then
                            'MasterList.Set(i, record)
                            Log("Producto : " & item.Get("CODIGO") & " fue reemplazado correctamente")
                        End If
                    End If
                Next
            Else
                Log("Nuevo Producto : " & item.Get("CODIGO") & " fue agregado correctamente")
            End If
        End If
        
    Next
    Return DB
End Sub

Private Sub ShowDialog(old As Map) As ResumableSub
    Return Msg.show2("¿El producto " & old.Get("CODIGO") & " - " & old.Get("PRODUCTO") & " ya existe desea reemplazar sus datos?,","Aviso","Si","No","")
End Sub


And i get this error:


I just want to show a msgbox asking if you want to replace the existing item or not
 

Brian Michael

Active Member
Licensed User
I'm so sorry, the error I was receiving was different from the post, I managed to see the error after publishing this post, any member of staff please delete this post.
Thanks and apologies for the inconvenience.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…