首页 > 解决方案 > 为什么这个 msgbox 代码会弹出错误?

问题描述

我正在尝试制作一个只有 OK 选项的 msgbox,但需要有描述和标题。

MsgBox ("this is where i put my message", vbOKOnly, "this should be the title")

当我尝试运行代码时,它只会给我一条错误消息

标签: excelvba

解决方案


去掉括号

MsgBox "this is where i put my message", vbOKOnly, "this should be the title"

或者,你可以做

rspns = MsgBox ("this is where i put my message", vbOKOnly, "this should be the title")

不过,后者对您不利。如果您要使用一个消息框,您希望从中捕获响应(例如vbYesNo),这将是一种使用方法,响应将存储在rspns变量中。


推荐阅读