By using t2do.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

T2Do.com

 


dispYN

Function dispYN(sMsg As String, Optional vModal) '
'Version: 1.000
'Purpose: Displays a Y/N dialog and returns true if Yes is pressed otherwise returns false
    On Error Resume Next
    
    Dim lResponse As Long
    Dim bModal As Boolean

                          
    
    lResponse = MsgBox(sMsg, vbQuestion + vbYesNo, "")
    If lResponse = vbYes Then
         dispYN = True
     Else
         dispYN = False
     End If
    
    DoEvents ' to allow repainting

End Function

Newer verisioin
  • support modal and default methods
  • Support autorun mode

    Function dispYN(sMsg As String, Optional vDefault, Optional vModal) '
    'Version: 1.001
    'Purpose: Displays a Y/N dialog and returns true if Yes is pressed otherwise returns false
        if IsMissing(vDefault) then
           'have to run because default set
        else
            if gbJustRun Then
                dispYN = vDefault
                Exit Function
            End If
        End If

        On Error Resume Next
        
        Dim lResponse As Long
        Dim bModal As Boolean

                              
        if IsAutorun Then
            dispYN = True
        else
            lResponse = MsgBox(sMsg, vbQuestion + vbYesNo, "")
            If lResponse = vbYes Then
                 dispYN = True
            Else
                 dispYN = False
            End If
        
            DoEvents ' to allow repainting
        End If
    End Function

  •