question

osvbnet avatar image
0 Votes"
osvbnet asked osvbnet edited

MessageBox in Thread

Hello,
Inside a thread I should invoke my MessageBoxEx to show it as MODAL:

If Invoke(New QuestionBoxHandler(AddressOf ShowQuestionBox), "Query?") = vbYes Then...
::
Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity.

If I replace = with Is:
'Is' operator does not accept operands of type 'Microsoft.VisualBasic.MsgBoxResult'. Operands must be reference or nullable types.

Private Delegate Function QuestionBoxHandler(ByVal Message As String) As DialogResult
Private Function ShowQuestionBox(ByVal Message As String) As DialogResult
ShowQuestionBox = MessageBoxEx.Show(Message, "TITLE", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
End Function

Any idea how to fix this error? :(

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered osvbnet edited

Try this:

 If CType(Invoke(New QuestionBoxHandler(AddressOf ShowQuestionBox), "Query?"), DialogResult) = DialogResult.Yes Then
    . . .
 End If

or this:

 If Equals(Invoke(New QuestionBoxHandler(AddressOf ShowQuestionBox), "Query?"), DialogResult.Yes) Then
    . . .
 End If

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.