Lucas Raphael Pianegonda
Lucas Raphael Pianegonda

Reputation: 1181

How does one convert vbYes / vbNo to Boolean?

This code displays a MsgBox and asks a question. The result is returned in a VbMsgBoxResult and is converted to Boolean.

Dim gobox as VbMsgBoxResult
dim go as boolean

gobox = MsgBox("Question?", vbYesNo, "Descriptive Titel")
If gobox = vbYes Then
go = True
Else
go = False
End If

Is there an easier way to convert VbMsgBoxResult to Boolean?

Upvotes: 1

Views: 1474

Answers (1)

Storax
Storax

Reputation: 12167

Maybe just

go = (MsgBox("Question?", vbYesNo, "Descriptive Titel") = vbYes)

Upvotes: 2

Related Questions