MPL OptiMax Samples

 

Visual Basic - Display results using MsgBox


Private Sub cmdSolve_Click()

    Dim MPL As OptiMax
    Dim planModel As Model
    Dim result As Integer

    Set MPL = New OptiMax

    MPL.WorkingDirectory = "c:\mplwin4"
    MPL.Solvers.Add "cplex65.dll"

    Set planModel = MPL.Models.Add("Planning")
    result = planModel.ReadModel("planning.mpl")
    If result > 0 Then
         MsgBox planModel.ErrorMessage
    Else
        planModel.Solve
        MsgBox planModel.Solution.ResultString & ": " & _
               planModel.Solution.ObjectValue
    End If

End Sub