配列から選択したテキストを含む MsgBox を表示する機能があります。
'# show the choosen message
Public Function ShowMessage(which)
ShowMessage = MsgBox(Message(which),vbyesno,"title")
end Function
この関数からの戻り値は、MsgBox 自体からの戻り値です。その後、if ステートメントでその値を要求しようとすると、その関数の値の割り当てが間違っているというエラー メッセージが表示されます。
if ShowMessage = vbYes then
MsgBox "clicked ok"
StartProgram("notepad.exe")
else
MsgBox ("some error occurred")
end if
ShowMessage の値を var1 に代入し、if ステートメントを使用すると、エラー メッセージは表示されません。
'# show the choosen message
Public Function ShowMessage(which)
ShowMessage = MsgBox(Message(which),vbyesno,"title")
var1 = ShowMessage
end Function
....
if var1 = vbYes then
MsgBox "clicked ok"
StartProgram("notepad.exe")
else
MsgBox ("some error occurred")
end if
そのステートメントで値に直接アクセスできないのはなぜですか、それともここで何か間違ったことをしていますか?