/ Forums / Advansys Formativ / Creating Solutions with Formativ / Exiting the applet when the user presses “Cancel” / Reply To: Exiting the applet when the user presses “Cancel”

#6993
Support 1a
Participant

    Try this code. The Cmd variable needed to be set again down near dialog 2.

    Regards,

    Advansys Support

    '*******************
    'Global Constants
    '*******************
     
    Const cExit =999
    Const cDlg1 =101
    Const cDlg2 =102
     
    '*******************
    'Main Routine
    '*******************
     
    Sub Main(ClientState, GWEvent)
     
      Dim Dlg
      Dim Cmd
     
      '*******************
      'Dialogue 1
      '*******************
      Do
     
        set Dlg = Utilities.NewControlBoxDialog
        with Dlg
         .Caption = "Advansys Formativ"
         .Title = "Dialogue 1"
         .Description = "This is Dialogue 1."
        end with
     
        Cmd = cDlg1
     
        If Cmd = cDlg1 Then
         Select Case Dlg.Execute
           Case Btn1 Cmd = cDlg2
           Case Else Cmd = cExit
         End Select
        End If
     
        '*******************
        'Dialogue 2
        '*******************
        If Cmd = cDlg2 Then
         set Dlg = Utilities.NewControlBoxDialog
         with Dlg
           .Caption = "Advansys Formativ"
           .Title = "Dialogue 2"
           .Description = "Dialogue 2"
         end with
     
         ' ** Set the variable Cmd value to the button pressed **
         Select Case Dlg.Execute
           Case Btn1 Cmd = cExit
                     MsgBox("OK pressed")
           Case Else Cmd = cExit
                     MsgBox("Something else pressed")
         End Select
        End If
     
      Loop Until Cmd=cExit
     
    end sub