CB.MacroResult Example

This example subroutine, checkresult, checks the last Crystal Ball macro call. It uses the CB.MacroResult return value to check the status of the last call and display the appropriate message.

Sub checkresult
   Select case CB.MacroResult
   case cbErrNone
      MsgBox "Completed OK"
   case cbErrBadValue
      MsgBox "Bad parameter value"
   case cbErrNoForecastInCell
      MsgBox "No forecast in active cell"
   case cbErrNotReady
      MsgBox "No simulation yet"
   case cbErrNoAssumptionInCell
      MsgBox "Missing assumptions in selected cell(s)"
   case cbErrBadSelector
      MsgBox "Bad value in parameter"
   case cbErrBadCommand
      MsgBox "Bad value in parameter parm_number"
   case cbErrNoCBSheets
      MsgBox "No worksheets with CB information to save" 
   case cbErrTooManyAssumptions
      MsgBox "Too many assumptions"
   case cbErrTooManyForecasts
      MsgBox "Too many forecasts"
   case cbErrBadCorrelation
      MsgBox "Invalid correlation(s)"
   case cbErrBadAssumption
      MsgBox "Invalid assumption parameter(s)"
   case cbErrCallingDLL
      MsgBox "Could not find the DLL"
   case cbErrUnexpected
      MsgBox "An unexpected error occurred"
   End Select
End Sub