How can I display an error dialog when there is an error with MLEvalString in Spreadsheet Link EX 3.0.1 (R2008a)?
1 view (last 30 days)
Show older comments
I am using Spreadsheet Link EX and I would like to have an error dialog appear when there is an error in my MLEvalString command.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
When the MLShowMatlabErrors command is set to "yes", the MLEvalString subroutine returns the full error message. A wrapper subroutine can be used to create an error dialog box which displays any errors that were encountered.
Private Sub MLEvalStringWithErrBox(myValue As String)
'Execute the MATLAB command
Dim Result, Msg, Style, Response
'Define message
Msg = "Invalid MATLAB command"
'Define buttons
Style = vbOKOnly + vbExclamation
If Trim(myValue) = "" Then
Exit Sub
End If
Result = MLEvalString(myValue)
If Result <> 0 Then
Response = MsgBox(Result, Style)
End If
End Sub
The following subroutine can be used to test the above code:
Sub test()
MLEvalStringWithErrBox ("a = [2 3]")
MLEvalStringWithErrBox ("a^2")
End Sub
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!