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
2
votes
1 answer

Remove countdown from vbscript yes-no Box

I have this script that will display a yes-no box with a 30 second countdown, and if the user has not selected an option after the time is up, then the VBScript automatically selects the option "Yes" and returns to a Batch Script. How do I remove…
user1914378
2
votes
2 answers

vb6 how to enter in debug mode while in msgbox

I've made some searches but not found this question, sorry. In a vb6 loop Ive a msgbox showed. Any way to enter in debug mode (as using F8) ? I need this in order to change the conditions of the msgbox. And not, I can't restart the project because…
Guillermo
  • 57
  • 1
  • 6
1
vote
0 answers

MATLAB msgbox and java.awt.Robot issue?

I had a function script that was working great. Part of it includes a little java.awt.Robot command that creates a custom mouse cursor. The script works exactly as I intended it to, without any bugs/errors so far as I can tell through repeated…
Ryan Simmons
  • 873
  • 3
  • 17
  • 29
1
vote
2 answers

Find empty cells and print their names in MsgBox

I am working on an archive system where a user lists information about a machine using data validation. This information all gets transferred to a table. The table looks like this: | Unit | Machine | PC | Software | Who | Why | In order to even make…
heiavieh
  • 27
  • 4
1
vote
1 answer

Excel VBA, MsgBox Yes or No, but must be "Si" or "No"

I have a fairly easy question that I think there should be an easier way to do it, but I haven't been able to find the answer that I want. Pretty simple, I have a MsgBox with +vbYesNo, But my end user is a Spanish speaker, so all the statements are…
1
vote
1 answer

Use MsgBox in Inno Setup to ask questions before Installation

How to make installer to ask a question before opening the installer? For Example: It will ask "Are You Over 18?" then user can select whether "Yes" or "No". If user selects "Yes", installer will open. if user selects "No", installer will close…
Knight
  • 25
  • 4
1
vote
1 answer

VBA - Msgbox inside a Loop

I have the attached userform. Whenever I click on the "Proceed!" button, I have it check if the sum of batches weight is more than the first assigned weight in the Product Details frame; if yes it asks me to proceed or not, I the answer was "Yes" it…
Taher Alaa
  • 19
  • 5
1
vote
1 answer

Prevent a MsgBox from a different VBA script from popping up

I have written a script in the workbook that sends a msgbox warning users not to copy and paste cells whenever they do so. Target.PasteSpecial xlPasteValues If Application.CutCopyMode = xlCopy Then MsgBox ("Please do not copy and paste…
Amatuer
  • 13
  • 3
1
vote
1 answer

Run Sub if msgbox response is Yes. Exit if No

I have a message box that appears when the workbook is opened. It finishes with a question asking if help is needed. If the answer is "No" I want to Exit Sub and allow normal usage. If the answer is "Yes" I want it to run another macro to send me an…
1
vote
6 answers

Using MsgBox and get error msg 1004 when I select "Cancel" - Need the macro to just end normally

First I selected "Yes" to the question "Change Worksheet Name?". Then the message "Type new Worksheet Name" appears. Instead of typing in a new name and selecting "OK", I select the "cancel" button and my error messages are displayed. How do I…
JasperX99
  • 11
  • 2
1
vote
1 answer

Warning before overwriting existing data in VBA

I have the below code that creates a pop-up when new data is pasted into the specified range (A15 : E33). What I would like is when the user attempts to paste data into the range the pop up shows up and if the user selects no the data isn't pasted,…
RBRN1231
  • 67
  • 5
1
vote
2 answers

How to use a formula to generate a date as a default value in an input msgbox?

I am trying to make my input message box a bit more sophisticated by using a formula to generate a default date in an input message box in excel. Currently, it just gives a default value of "dd-mm-yyyy" to guide the user and then deposits it in cell…
1
vote
1 answer

Go to a referenced cell when clicking "ok" in the message box

So my code starts on a different sheet with a button click. The code below stops the user from continuing with an error message if the user does not put in a value in cell "B38" on the "Pricing checklist" sheet. Is there a way to bring the user to…
1
vote
2 answers

How to have Msgbox appear or not appear selectively

Sub Process_A() \ MsgBox "Process completed." End Sub Sub Process_B() \ MsgBox "Process completed." End Sub Sub Process_C() \ MsgBox "Process completed." End Sub Sub All_Processes() Call…
Scotty
  • 11
  • 1
1
vote
1 answer

If any row in range (G11:G25) contains boolean (true) then run function, else msgBox

The function I'm running (clearRowContents) in sheet 'Section 2' will clear contents and validation for any checked item (col H) in a list as well as the checkbox itself (col G). The remaining unchecked boxes and list items will then be sorted to…