Android Question (Solved) How use just one password five times?

f0raster0

Well-Known Member
Licensed User
Longtime User
Hi all,

My first app has 7 different passwords with 7 different textbox. My db has already added those passwords (column 1, see pic attached).
When I write a password in my app let me say in textbox1 and if it is correct then write the inf from column 1 to column 2 in my db.

After completed the 7 passwords by writing in each textbox, the app send me a message "enjoy your free coffe", then I reset the db by writing "1111111" see pic attached, column 2 .

well, it work prefect, but looks awfull :D
then, How can I use just one password and just one textbox?

Thanks for any help..

My current code below, I have repeated it with 7 passwords, 7 buttons and 7 textboxss.. :rolleyes:
B4X:
Sub Button5_Click

    Cursor1 = SQL1.ExecQuery("SELECT * FROM persons")
    Cursor1.Position = 1
    c = Cursor1.GetString("Password")
   
    If c=EditText3.Text  Then

        Panel3.Visible=False
        Panel2.Visible=True
        ImageView2.Visible=True    
        SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup2' WHERE ID = '2' ")
    End If
    'Cursor1.Close
    WebView1.Visible=True
 

Attachments

  • db.jpg
    db.jpg
    73.2 KB · Views: 240
Last edited:

f0raster0

Well-Known Member
Licensed User
Longtime User
I have tried to using: Select True.. case..
How can I exit of case 1 (if it is true), I used "Return" but if case 1 isn't true it does not go to check case2, case3...

B4X:
Sub Button12_Click

If EditText1.Text= "12346789" Then
        EditText1.Text=""
        Cursor1=SQL1.ExecQuery("SELECT * FROM persons")
        For i=0 To Cursor1.RowCount-1

            Cursor1.Position=i
            d=Cursor1.GetString("Password")
            c=Cursor1.GetString("copypassword")

        Select True

        Case    (c="1111111") 'case1
                ImageView2.Visible=True               
                SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup2' WHERE ID = '2' ")
                Msgbox ("cup2", "ok")
                Return
               
        Case    (c="1111111") 'case2
                ImageView3.Visible=True
                SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup3' WHERE ID = '3' ")
                Msgbox ("cup3", "ok")
                Return
               
        Case    (c="1111111") 'case3
                ImageView4.Visible=True
                SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup4' WHERE ID = '4' ")
                Msgbox ("cup4", "ok")
                Return
               
        Case    (c="1111111") 'case4
                ImageView5.Visible=True
                SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup5' WHERE ID = '5' ")
                Msgbox ("cup5", "ok")
                Return
       
        End Select
       
        Next
   
    End If
End Sub
 
Upvote 0

JTmartins

Active Member
Licensed User
Longtime User
1- Create an array of imageviews, lets call it igv. Then you refert o them as igv(1), igv(2),igv(3), etc.
2 -Create a function Sub Update (cup as String, ID as int) where you pass the parameters

now you can use only one line to call the function, passing the parameters, let's say Update ("cup1",1), and by using those parameters you can change the imageview and the SQL

I' haven´t much time at the moment to put this on code, but would make your program more manageable, and also I did not understand if this is what you are looking for.
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
Thanks James Chamblin and JTmartins, at the moment I have solved it, I think..
I used:
B4X:
Sub Button13_Click
If EditText1.Text= "123" Then
        EditText1.Text=""
        Cursor1=SQL1.ExecQuery("SELECT * FROM persons")
        For i=0 To Cursor1.RowCount-1

            Cursor1.Position=i
            d=Cursor1.GetString("Password")
            c=Cursor1.GetString("copypassword")

        If c="1111111" AND d ="1234561" Then
            ImageView2.Visible=True            
            SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup2' WHERE ID = '2' ")
            Msgbox ("cup2", "ok")
            Exit
            'Return
        End If
    
        If c="1111111" AND d ="1234562" Then
                ImageView3.Visible=True
                SQL1.ExecNonQuery("UPDATE persons set copypassword ='cup3' WHERE ID = '3' ")
                Msgbox ("cup3", "ok")
                Exit
            '    Return
        End If

            
        Next

    End If
End Sub
 
Upvote 0
Top