Android Question NumberDialog how exactly do you get the returned value?

AntonBrz

Member
Licensed User
Longtime User
Hello. I want to use the number dialog for my second game. I have an icon of an old fashioned safe. I have it set up so when you touch the safe door the number dialog pops up showing what looks like a combination lock. I'm having a problem getting the number because I don't know how to know if they selected ENTER or CANCEL. Could you show me a short example code how to get a number? I don't need a decimal place as I intend to use simple combinations like 54621 or 81953.

Thanks
Anton
 

Mahares

Expert
Licensed User
Longtime User
Is this example in line with what you are looking for?
B4X:
Sub b1_click 'b1 is a button
  Dim nd As NumberDialog
  Dim Comb As Int=1234
  Dim MyNumber As Int
  ret=nd.Show("PLEASE ENTER COMBINATION", "Ok", "No", "Cancel", Null)
 If ret=-1 Then
  MyNumber=nd.Number
  If MyNumber=Comb Then
    Msgbox("You got it","")
  Else
    Msgbox("Wrong combination","")
  End If
 End If
End Sub
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
That should do it, thanks! I knew the format was something like MsgBox2 but couldn't quite get it.
There are wonderful routines in the additional Libraries.

Anton
 
Upvote 0
Top