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
1
vote
3 answers

VBA - if cell contains a word, then messagebox just one single time

My idea was to get an alert every time I digit the word "high" in a cell of column A (also if the word is contained in a longer string). This alert should pop up just if i edit a cell and my text contains "high" and I confirm (the alert shows when I…
jonny_87
  • 21
  • 2
1
vote
0 answers

VBA Message Box does not execute when opeing a New Document in MS-Word 2016

I have created a message box that automatically runs when a new document is opened based on a template: ' Display a pop-up message Sub AutoNew() MsgBox "UPDATE Page numbering if:" & vbCrLf & "" & vbCrLf & "Additional pages are added" & vbCrLf & ""…
JDavis
  • 11
  • 1
1
vote
2 answers

What's the best way to display currency format in VBA MsgBox?

I have concatenated text and some basic calculations showing on my MsgBox. How can I get the number to display in currency format? I have placed a dollar sign before the calculations but it would be better if it had the proper currency format with 2…
1
vote
1 answer

MsgBox displaying old icons. How do I fix this?

So I have minimal experience in VBScript. I only need it for a little project I'm doing and I just need a bit of assistance because I can't find this anywhere else. When it creates a MsgBox, the error icons are the ones from Windows 7. Although this…
Nate0523
  • 21
  • 4
1
vote
2 answers

Autohotkey: MsgBox "Done" after Run

I have a python script I want ran on a shortcut key, but I want the Msgbox to tell me it's done once it finishes. How do I do that? I've tried putting the MsgBox, Done in different places like so F8::Runwait, C:\python36\python.exe …
jason
  • 3,811
  • 18
  • 92
  • 147
1
vote
2 answers

VBA If statement to call Msgbox always calls msgbox

I am trying to use an if statement to check for blanks and return a msgbox if there are blank fields. If there are no blank fields it runs another block of code. However even when you fill out all the fields the msgbox is always returned and the…
The_Ltrain
  • 13
  • 2
1
vote
1 answer

Converting number to text in messagebox

In my main menu form I have provided a button to check the tasks due as a reminder. In this assigned to field is coming as number , because in in my table it is of number type & it is linked to contact table to retrieve the data. So in my message…
RAVI KUMAR
  • 386
  • 1
  • 12
1
vote
1 answer

MsgBox in Jquery, pass info to PHP and retrieve results

As you can see i am noob at jquery / javascript, i need to pass variable to GET or POST written in form and the result from php need to be passed to jquery, i started to write smthing as below, but it doesnt work. anyone help me out please // id and…
Cameleon
  • 453
  • 1
  • 6
  • 16
1
vote
0 answers

vba using message box does not allow to debug

I have a msgbox in my code. I use F8 to check my code. When I get to the message box, it appears on the screen, I then click ok, but it doesn't move to the next line. If I will click F8 again it will start the function again. What could be the…
Hana
  • 89
  • 2
  • 7
1
vote
2 answers

MsgBox with multiple 'past due' items

I am building an LOP (List of Open Points) in Excel 2016 for a manufacturing project. Each action item will have a 'target date' for completion. My intention is every time the document is opened, a macro will run that will scan the document and…
jbbeard
  • 13
  • 2
1
vote
1 answer

Prompt a Msgbox and delete if duplicates are found in excel

I am using following line to remove duplicates in column. ActiveSheet.Range("A:B").RemoveDuplicates Columns:=Array(1, 1), Header:=xlYes Problem is, this is done silently and I don't really know when my data has double values. I need know by using…
VBAbyMBA
  • 806
  • 2
  • 12
  • 30
1
vote
1 answer

How to show all fails if there is any, if not then show no fail box

I want to show MsgBox of fails with correspondent samples. If non show another MsgBox with no fail. I feel I am almost there but have something messing. If I put the MsgBox within the loop the MsgBox appears more than once, if I put it out it shows…
Moe
  • 39
  • 5
1
vote
2 answers

One MsgBox To show all passes and fails

I am trying to make one message box to include passes and fails of samples. All Ranges above 0.24 are a fail and below are a pass, and that to show in one box the passes and fails with correspondent sample # The code below, show the boxes one by…
Moe
  • 39
  • 5
1
vote
2 answers

Why is a Base64 string displayed as empty in Message Box?

I have to encode some HTML source code into base64 format before form submission, and then decode it back to original code in the code behind. Here is the testing code by…
Ursidae
  • 87
  • 9
1
vote
1 answer

Looping within VBA MsgBox

I have some back-end code that produces a MsgBox depending on the content of a front-end user editable sheet ("iButtons"). The below code works fine and pretty quickly but I am conscious of the fact that as the "iButtons" sheet grows I will need to…
tboo132
  • 53
  • 4