MsgBox does not interrupt code

adamioan

Member
Licensed User
Longtime User
Greetings to all,
I have an issue with a MsgBox.
I do a check in a sub called DownloadCompleted which is the callback sub of HttpUtils. The MsgBox appears but the code continues to be executed and the app exits, closing the msgbox too.
Here is a code sample
B4X:
Msgbox("In order to get the program initialized, please connect to the internet." , "No internet connection")
' Exit program
StopService (HttpUtils2Service)
SaveSettings
Activity.Finish
Return

What can I do to stop the code at the appearance of the msgbox?
Thanks in advance.

Running: Android 4.0.3 on HTC HD2 with Nexus ICS CM9
 

mc73

Well-Known Member
Licensed User
Longtime User
You can give the following a try:

B4X:
Dim result As Int
result = Msgbox2("In order to get the program initialized, please connect to the internet." , "No internet connection", "OK", "", "", null)

if result = DialogResponse.Positive Then

    ' Exit program
    StopService (HttpUtils2Service)
    SaveSettings
    Activity.Finish
    Return

end if
 
Upvote 0

adamioan

Member
Licensed User
Longtime User
Thank you both for your response.
Sadly neither worked. When I used the code by mc73, it did continue to run but I noticed that the response of MsgBox (without click on it) was -3.
The only way to make the code stop, was to capture the response within a while loop
B4X:
do while Msgbox2("In order to get the program initialized, please connect to the internet." , "No internet connection", "OK", "", "", null)<>-3
loop
 
Last edited:
Upvote 0
Top