Title of Message box not setting up

喜夏-厌秋 提交于 2020-01-16 21:59:28

问题


I am writing some code in Visual Basic 6. It also uses the Msgbox funtion. Now I searched this and I got to know that if you want to set the title of the Message box then this is the syntax:

Msgbox(<Prompt>,<Title>)

For example, I write this:

MsgBox ("Incorrect Answer!","QM")

It says:

Compile Error Expected: =

Can someone tell me what is the problem?


回答1:


With VB6, you can either request a response, and do something based on the answer, or you can simply display a message.

If you want to know what button was clicked, you need to use the function format - that is, you must use the brackets.

If you simply want to display a message, then you don't use the brackets.

So if you want to just display the message, then continue, do this:

MsgBox "Incorrect Answer!", , "QM"

But if you want to know which button the user clicked (e.g. to offer them a try again, cancel, then you need a variable, and you use the brackets to signifify that it's a function:

Dim response = MsgBox("Try again?", MsgBoxStyle.YesNo, "QM")

You can then look at the response variable to find out which button the user clicked.

A couple of pages for reference:

http://vb6reference.tomswebdesign.net/msgbox.html

https://msdn.microsoft.com/en-us/library/139z2azd(v=vs.90).aspx



来源:https://stackoverflow.com/questions/30962795/title-of-message-box-not-setting-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!