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

If Statement for Function looping incorrectly

I am trying to recreate a simple program I made once in Python in VBScript to have it run in a dialog box. This is the code: Set objShell = CreateObject("Wscript.Shell") Function Query() query = InputBox("Please input the Subreddit you with to…
1
vote
3 answers

How can I use the Computer Name Environment Variable in VBS with MsgBox?

I am trying to create my own custom dialogs for Windows, making them from scratch using shortcuts/wscript/and VBS to make them as realistic as possible. For some of my errors/dialogs, I want to use the %computername% variable in a dialog to make it…
InterLinked
  • 1,247
  • 2
  • 18
  • 50
1
vote
2 answers

How do I properly configure conditional actions with user input in VBS with MsgBox?

I have been trying to get a VBS script to work for a while now with msgbox. When I use a single msgbox statement, it works. As soon as I start adding conditional input options, then it doesn't work. I posted this question on Super User and I was…
InterLinked
  • 1,247
  • 2
  • 18
  • 50
1
vote
2 answers

Msgbox with two different criteria

I have an excel sheet, with column both A、B、C、D. Both C & D number changes all the time (they have different criteria), since it calculates by stock data that fetches in real-time. I need message box to pop up both when C & D matches my target…
Laura Lee
  • 35
  • 3
1
vote
1 answer

Inconsistent result with msgbox function in ISE and PowerShell console

I am fiddling with the timer object and message boxes and hit a brick wall. I am trying to manage the timer object and popups through reusable functions. I tested most of these functions on their own and in small parts first. Since everything…
1
vote
1 answer

Vbscript msgbox out of file list

I’m new to vbs, but I need to make a script that copies files from one folder to another, then reads a hole list of copied files and make a log file with those names. This is where I got it covered. Next thing I need to do is to make some sort of…
RAFEL
  • 184
  • 1
  • 2
  • 14
1
vote
0 answers

Msgbox for number of rows copied to what sheet

With help from many helpful people on here I have got to the point where the code does exactly what I need it to do! I am really struggling with the MsgBox at the end that display how many rows have been copied to each sheet. I would also like it to…
atame
  • 521
  • 2
  • 12
  • 22
1
vote
1 answer

Wscript.run "No application is associated with the specified file for this operation"

I am trying to launch "GetPID.exe" and store the error code. This is the .vbs code : Set WshShell = CreateObject("WScript.Shell") strPath = Wscript.ScriptFullName Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile =…
loadingnow
  • 597
  • 3
  • 20
1
vote
1 answer

Excel VBA, How to Loop a Msgbox when text in cell changes to "News" to answer of Msgbox in next column

I'm trying to create a MsgBox that automatically pops up with a prompt of "Yes or No" when a cell in a column changes from blank to "News", and to put the answer into the next column. I will be continuing to add to rows over time so it has to…
1
vote
1 answer

Is it possible to change the interface of a MsgBox in VB.net

Im trying to make an instruction msgbox and i want to make it look nice i want it to look like a Dialog Cloud. Should i use a msgbox or other tools ? any suggestions and answers would be awesome !
1
vote
2 answers

VBScript: Getting desktop shortcuts to perform special actions

Truth: I am completely new to this scripting thing and have reached an end-pass. I am trying to write a script that will not only create a shortcut on the user's desktop, but when the user clicks on the icon, I want them to be asked if they really…
user5157829
1
vote
1 answer

MsgBox appears multiple times after data is pulled from a sheet

I'd like to get some help with the following code. I am very new to this but I think it's an easy solution I'm just unable to retrofit suggestions from other searches into my code. The msgboxes are working fine on the first pass to check if the text…
Kate
  • 11
  • 1
1
vote
1 answer

How can I increase the width of a msgbox() in inno setup

Or should have to create my own message box? If so any sample code please Ok, so it is not possible. I will have to do my own msgbox function. Should I use a TForm, Tmemo or Tpannel? How can I have the box hight auto adjustable? If any one has some…
lessj
  • 31
  • 3
1
vote
1 answer

vb msgbox after completion of a process

I am running a batch file with shell function in VB2010 with the following command Shell("C:\test.bat", AppWinStyle.NormalFocus) This process takes a lot of time to complete, might even take a day to complete depending on the input file. I want a…
mamon
  • 27
  • 5
1
vote
6 answers

How to automate response to msgbox

I am developing a C# application to automate the running of a legacy VBScript(vbs) file which calls several VB6 .exe files. The .exe files have message box pop-ups that I need to 'respond' to in order to allow the VBScript process to run unattended.…
kensy
  • 11
  • 1
  • 6