Questions tagged [msgbox]

The MsgBox function is used in Visual Basic to display a dialog box to the user, wait for a button to be clicked and return the result to the caller. Use this question for using MsgBox specifically; for the .NET MessageBox class, use the "messagebox" tag instead.

Summary

The MsgBox function is exclusive to the Visual Basic programming language. It is commonly used in , or Visual Basic for Applications (), but can also be used in Visual Basic .NET for backwards compatibility. (However, in , it is recommended to use the MessageBox class from the .NET Framework instead.)

Function signature

As listed on MSDN:

Public Function MsgBox( _
   ByVal Prompt As Object, _
   Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _
   Optional ByVal Title As Object = Nothing _
) As MsgBoxResult
  • Prompt is used to set the text you want to display in the dialog box.
  • Buttons is used to set which buttons are displayed in the dialog box. If omitted, only the OK button is shown by default.
  • Title is used to set the title text for the dialog box. If omitted, the application name is displayed by default.

The return value is a numeric value indicating what action the user took in response to the dialog (i.e., which presented button was clicked).

Related tags

Useful questions

Links

403 questions
87
votes
17 answers

How to use \n new line in VB msgbox() ...?

What is the alternative to \n (for new line) in a MsgBox()?
Wasim A.
  • 9,660
  • 22
  • 90
  • 120
57
votes
2 answers

Differences Between vbLf, vbCrLf & vbCr Constants

I used constants like vbLf , vbCrLf & vbCr in a MsgBox; it produces same output in a MsgBox (Text "Hai" appears in a first paragraph and a word "Welcome" appears in a next Paragraph ) MsgBox("Hai" & vbLf & "Welcome") MsgBox ("Hai" & vbCrLf &…
Lawrance
  • 975
  • 3
  • 9
  • 17
13
votes
3 answers

MsgBox Yes/No Excel VBA

I have a Yes/No MsgBoxin my VBA script that returns a question for the user to answer. Whenever the "Yes" or "No" buttons are pressed, besides the script running its respective code, another MsgBox with the numbers "6" or "7" pops up. How do I…
franciscofcosta
  • 833
  • 5
  • 25
  • 53
13
votes
7 answers

Translate text using vba

Probably could be a rare petition, but here is the issue. I am adapting an excel of a third-party to my organization. The excel is developed in English and the people of my organization just speaks Spanish. I want to use exactly the same code that…
MariPlaza
  • 357
  • 2
  • 5
  • 16
13
votes
8 answers

Understanding what response codes come back from MsgBox

I'm very new to programming and I'm just starting to learn VBA with excel. I came across on this website and did the examples here but I have question about this code: I know the variables are declared using "Dim" statement "Message" here is the…
tintincutes
  • 5,618
  • 25
  • 67
  • 86
9
votes
9 answers

msgbox that disappears automatically after certain time

Is there any type of msgbox in vb.net that gives a message and it disappears automatically after a certain time? Or is there any method to hide the msgbox, without user's clicking OK?
Furqan Sehgal
  • 4,917
  • 33
  • 108
  • 167
9
votes
4 answers

How do you make a MsgBox with a "Do Not Ask This Again" or "Don't Ask Me Again" Checkbox in VB6?

I ask this partly because I want to know the best practice way of doing this, and partly because the top google result I got was a forum thread from 2002 in which the question wasn't even answered. I inherited some VB6 code, and there are some…
user15486
7
votes
2 answers

How to keep msgbox always on top in vba?

While my macro runs, I do my other works. But then when msgbox pops out stays behind my other windows. How can I see it on top, when it pops out? Thank you.
Emre
  • 121
  • 1
  • 2
  • 8
7
votes
1 answer

How to use msgbox in R

How can I display a message box in R ? I'm looking for something similar to msgbox in VBA, so I can for example alert the user about a problem. Additionally I would like to allow some user interaction. So for example I could ask the user what day…
dekio
  • 810
  • 3
  • 16
  • 33
6
votes
5 answers

MsgBox focus in Excel

I am calculating a lot of data with VBA in Excel and want to show a MsgBox when it's done. The MsgBox actually shows the time it took for the calculation. The problem is when the user decides to do something else while the computation happens. Excel…
dan
  • 3,439
  • 17
  • 54
  • 82
6
votes
1 answer

How to create an alert message in Google app script while deploying a web app?

I am trying to create a web app using Google app script, that if you press a button, you may get an alert message. In the home.gs file I tried this : function let_user_decide() { Browser.msgBox('Greetings', 'Press Yes or No?',…
Yair Saban
  • 95
  • 1
  • 1
  • 9
5
votes
1 answer

Is there a message box which displays copy-able text in Python 2.7?

I'm trying to write a Python program that gets a string as input and displays the string in a message box with the last letter removed from each word. I've successfully written the code to remove the last letter from each word and I came to know…
5
votes
2 answers

Confirmation Message BOx function for asp.net?

This is my Delete function after a click. Can anyone show me how to do a simple confirmation function? ASP.net C#. Previously I had this ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "confirm('Are you…
WeakTaenie
  • 247
  • 2
  • 6
  • 14
5
votes
1 answer

Suppress MsgBox from another Subroutine in VBA

I have a VBA sub that makes a call to a sub that was written by someone else. occasionally, the other sub opens a MsgBox with an OK button. The other sub takes a long time to run, and I am calling it hundreds of times, so I want to be able to run…
Eric
  • 688
  • 2
  • 9
  • 23
4
votes
3 answers

Excel VBA restarting same Subroutine within itself based on VbMsgBoxResult

I'm trying to get my Sub to restart based on MsgBoxReults. The code I have doesn't contain any errors, but won't restart based on the users choice (hopefully, having an IF statement within another IF isn't the issue) Please assist. Sub…
J VBA
  • 178
  • 2
  • 5
1
2 3
26 27