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

Is it possible to have VBA MsgBox as type vbYesNo and vbExclamation simultaneously?

I am trying to get a message box in vba to display as a regular yes no box: But with the Exclamation icon as well: I can do either easily by vba. Like the vbExclamation version code below: MsgBox "Are you sure you want to continue?",…
Joe
  • 616
  • 2
  • 12
  • 27
1
vote
3 answers

Message box to take the row number when multiple errors are shown

I am using this code to receive an error message every time when in column "W" a text is inserted. When this happens the text is deleted and a box message appears:"The row W" & r & " must contain only digits!" which tells the row number of the…
geocc
  • 31
  • 6
1
vote
2 answers

can't continue script from .bat file after closing msgbox

I have a script that saves 2 files in a backup folder. I want to get a message box if the copy command was successful or not. @echo off Echo msgbox"Saving test1 to \backup directory." + vbNewLine + "Successfull!",0,"Backup file..">test1.vbs Echo…
nolags
  • 633
  • 1
  • 11
  • 30
1
vote
1 answer

How to deactivate msgbox in a sub VBA?

Sub prelim() MsgboX "Hello World" End Sub Sub Main() Call prelim End Sub In the above code Sub prelim can't be edited.I want msgbox when I run Sub prelim but when I run Sub Main I don't want the message box to get popped out. How to do…
Kosmo
  • 59
  • 1
  • 10
1
vote
2 answers

Command Button in msgbox vba possible?

si it possible to add a command button in the msgbox window in vba? For example, i want to add a cancel button that stops the code rather than continuing it. I could create a new userform, but it would be nice if i save some space and use the msgbox…
wwla
  • 41
  • 1
  • 9
1
vote
0 answers

How do I display a message box once I quit wscript

I have been trying to learn Web Scraping using VBScript since VBA for Outlook does not work like VBA for Excel So I am trying to display a message box to see whether or not my script is getting to specific points. I can display the first message box…
1
vote
1 answer

is excel in ready mode when msgbox displays?

Just curious. This is a more theoretical (related to Excel VBA) question. Rather than a trying to solve a particular problem. I have learnt that Excel has ready, cut, copy and other modes. I am just wondering what mode it is when a msgbox is…
chinghp
  • 117
  • 2
  • 13
1
vote
1 answer

MsgBox doesn’t give a value

In the column “V34:V99” there are digits 1,2,3,0 in the scattered order . I want to count how many situations will be (n) (three consecutive 1 к=3, without taking into account zeroes) ,if 2 or 3 occur , then k=o . I wrote the code but it doesn’t…
maxim465
  • 195
  • 10
1
vote
2 answers

Auto populating MsgBox

I was wondering if anybody could help me turn the below into a msg box. Basically i want it to first check whether any of the below range's say CHECK and if they do a msgbox will appear explaining which rule has been breached. I have had an attempt…
Peter Mogford
  • 478
  • 1
  • 4
  • 15
1
vote
1 answer

Display All Array Element Values in One MsgBox VBA

please bear with my code. (I'm not a good coder and not familiar with all VBA syntax.) I'm creating a database for all our household books. I'm not using ACCESS or SQL, just simply recording all UserForm input data to an Excel Sheet. In my UserForm,…
Karen88
  • 157
  • 1
  • 2
  • 5
1
vote
2 answers

cmd msg command text size and color

I have got a .bat file to run in my shool that warns users that any damage made to the devices will be punished unless reported. I want the text in this msg box to be bigger and a different color/font. how cane I do that? my msg command looks like…
laundmo
  • 318
  • 5
  • 16
1
vote
1 answer

Access VBA - Msgbox

Looking for a workaround here. One that preferably doesn't involve making a bunch of user forms. Background: I've got an Access DB used for scanning items in and out of the office. After each item is scanned, it verifies that the item is okay to…
Brock
  • 45
  • 7
1
vote
1 answer

VBA alert when the result is different by 0

I have this code: DM.OnUpdate="CalculDiferenta" DM.OnInsert="CalculDiferenta" Sub CalculDiferenta If Dsrid.Value=50000 Then stl.first Do While Not Stl.Eof Diferenta.Value=Cantv.Value-Cantc.Value Stl.Next Loop end if End Sub It calculates the…
Ionut P.
  • 63
  • 10
1
vote
1 answer

Is it possible to react to a VBScript msgbox from a PowerShell script?

I've been working to make manual processes more of a one-click process and I've run into an issue with these msgbox popups from a VBScript script. Essentially, I am using PowerShell and doing something like: foreach ($loc in $locs): & cscript…
abou
  • 47
  • 4
1
vote
1 answer

macro range / specific cells msg box

can you help me with macro please? I have a 3 code which show me msg box only if - specific value. But dont work for me. :/ I dont known why. some errors, I would like to make all ranges and after show me msgbox when value be fulfill. Someone…
Fiínek Cahů
  • 67
  • 1
  • 2
  • 11