Examples: Prompt method

  1. This PROMPT_OK example displays an informational message; the user clicks OK to close the dialog box. Use this style when you want to inform the user about something without receiving anything back except an acknowledgment.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim askme As Integer
      askme = workspace.Prompt(PROMPT_OK, _
      "Reminder", "Don't forget to run backup tonight.")
    End Sub
  2. This PROMPT_YESNO example displays a message and gives the user a chance to proceed or cancel the operation. If the user selects Yes the value 1 is returned. If the user selects No the value 0 is returned.
    Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim askme As Integer
      askme = ws.Prompt (PROMPT_YESNO, _
      "Order status", "Is all information complete?")
      If askme = 1 Then
        Messagebox "Thank you for your business.", , _
        "Order submitted"
      End If
    End Sub
  3. This PROMPT_YESNOCANCEL example also displays a message and gives the user a chance to select Yes, No, or Cancel. If the user selects Cancel, the value -1 is returned.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim askme As Integer
      askme = workspace.Prompt (PROMPT_YESNOCANCEL, _
      "Send memo?", _
      "This memo will be sent to everyone listed in the To, CC, _
       and BCC fields.")
      If askme = 1 Then
        Messagebox "Memo sent", , "Status"
      End If
    End Sub
  4. This PROMPT_OKCANCELEDIT example prompts the user to enter a message which is returned as a text string. No default message is displayed.
    Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim askme As Variant
      askme = ws.Prompt (PROMPT_OKCANCELEDIT, _
      "We want to hear from you!", _
      "Enter your message here.")
      If Not Isempty (askme) Then
        Messagebox "Sending your message...", , _
        "Message status"
      End If
    End Sub
  5. This PROMPT_OKCANCELEDIT example, using a default value, displays the user's name and prompts for any corrections. If changes are made, the name is updated. If the user quits, the name does not change.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim response As Variant
      Dim dialogBox As String
      Dim userName As String
      userName = "Mr. Cheng"
      dialogBox = "Mailing List Update"
      response = workspace.Prompt (PROMPT_OKCANCELEDIT, _
      "Your name", _
      "Make changes here, if necessary, then click OK to continue _
       or Cancel to quit.", userName)
      If Isempty (response) Then
        Messagebox  "Name not added.", , dialogBox
      Else
        userName = response
        Messagebox "Thank you, " + userName + _
        ". Your name has been added.", , _
        dialogBox
      End If
    End Sub
  6. This PROMPT_OKCANCELLIST example displays a list box with database names, prompts the user to select a database, and returns that database's name as a text string for use in a subsequent operation. If the user selects Cancel, the response string is Empty. The user must select one of the listed options; by default, Schedule is highlighted (the value listed as the default must also be included in the display list).
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim response As Variant
      Dim values(2) As Variant
      values(0) = "Schedule"
      values(1) = "Phone Book"
      values(2) = "My Mail"
      response = workspace.Prompt (PROMPT_OKCANCELLIST, _
      "Select a Database", _
      "Select a database to open.", _
      values(0), values)
      If Isempty (response) Then
        Messagebox "User canceled", , "Database not opened"
      Else
        Messagebox response, , "Open Database"
      End If
    End Sub
  7. This PROMPT_OKCANCELCOMBO example displays a dialog box similar to the PROMPT_OKCANCELLIST example, except that a drop-down list is used, so that initially only the default value is displayed. The user clicks the down arrow on the box to display the rest of the list. As in the PROMPT_OKCANCELLIST example, the user must select one of the listed values; by default, Schedule is selected. This script returns the user's selection. If the user selects Cancel, the response string is Empty.
    Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim response As Variant
      Dim values(2) As Variant
      values(0) = "Schedule"
      values(1) = "Phone Book"
      values(2) = "My Mail"
      response = ws.Prompt (PROMPT_OKCANCELCOMBO, _
      "Select a Database", _
      "Select a database to open.", _
      values(0), values)
      If Isempty (response) Then
        Messagebox "User canceled", , "Database not opened"
      Else
        Messagebox response, , "Open Database"
      End If
    End Sub
  8. This PROMPT_OKCANCELEDITCOMBO example is similar to the PROMPT_OKCANCELCOMBO example, except here the user can edit the text box and type in any name; this way, the user is not limited to the selections in the list. This script returns the user's selection or entry. If the user selects Cancel, the response string is Empty. The default value must be included in the list, or the text box that displays initially will be blank.
    Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim askme As Variant
      Dim destination As String
      Dim city(4) As Variant
      city(0) = "Bangkok"
      city(1) = "Berlin"
      city(2) = "Bombay"
      city(3) = "Boston"
      city(4) = "Sydney"
      askme = ws.Prompt (PROMPT_OKCANCELEDITCOMBO, _
      "Where do you want to go?", _
      "Select destination. If not in list, type name of city.", _
      city(3), city)
      If Not Isempty (askme) Then
        destination = Ucase (askme)
        Messagebox "Enjoy your flight!", , "Destination: " + _
        destination
      End If
    End Sub
  9. This PROMPT_OKCANCELLISTMULT example displays a list of names, from which the user can select one or more. The default value must be included in the list (Mary Tsen appears as the default selection). This script returns the user's selection(s). If the user selects Cancel, the response string is Empty.
    Sub Click(Source As Button)
      Dim ws As New NotesUIWorkspace
      Dim askme As Variant
      Dim names(3) As Variant
      names(0) = "Bill Chu"
      names(1) = "Michael Bowling"
      names(2) = "Mary Tsen"
      names(3) = "Marian Woodward"
      askme = ws.Prompt(PROMPT_OKCANCELLISTMULT, _
      "Select a Name", _
      "Select one or more names as recipients for this request.", _
      names(2), names)
      If Isempty(askme) Then
        Messagebox "User canceled", , "No one selected"
      Else
        Forall ask In askme
          asklist = asklist & ask & Chr(10)
        End Forall
        Messagebox asklist, , "Recipients"
      End If
    End Sub
  10. This PROMPT_PASSWORD example displays a dialog box where the user can enter a password. Notes/Domino does not display the password on the screen. If the password supplied is not xyzabc the user is prompted two times to enter the correct password.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim askme As Variant
      Dim  count As Integer
      count = 0
      Do Until askme = "xyzabc" 
        askme = workspace.Prompt(PROMPT_PASSWORD, _
        "Password", "Please type your password.")
        count = count + 1
        If count > 2 Then
          Messagebox "Invalid password."
          Exit Sub
        End If
      Loop
    End Sub