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

VBA to show message box if update query changes 1 row, show another if none

I'm working on running an append query (to change someones login password) in access, currently it checks to make sure the password matches and that they knew the original password. However, I run into a problem where if the update query:…
Dm3k1
  • 187
  • 3
  • 8
  • 21
1
vote
1 answer

Access VBA - Display table row data in a Msgbox

I'm rather new to programing with Access VBA and I've not been able to find out anywhere that could help me with this problem. I'm working with a table that contains a list of postcode for the London Area. I have a list of 2248 postcodes and for…
user2474825
  • 11
  • 1
  • 2
1
vote
1 answer

Listbox Help wanted (simple script)

I am not an expert but try to figure it out about ~6 hours now, I have a selection window with 2 items, and whatever what i choose it say i choose No1 item. Later on i replace nr1, nr2, with actions if the selections could working. Please help! I…
1
vote
4 answers

Msgbox Yes No & cancel button working in VB.NET 2010

Below is my code for a MsgBox. The Yes button is working, but when I click No or Cancel it still deletes the data... strup = "DELETE FROM student WHERE urno =" & CInt(txtUrn.Text) & ";" Dim command As New OleDb.OleDbCommand(strup,…
CrashOverride
  • 338
  • 3
  • 10
  • 22
1
vote
1 answer

excell 2007 macro validate data entered into cell and show msgbox if incorrect

Please can someone help with the following code. it gives me an error at the following line: Set range = "C5:L14" This is the complete code: Private Sub Worksheet_Change(ByVal Target As Excel.range) Dim ws As Worksheet Dim range As Worksheet Set…
user1955214
  • 57
  • 1
  • 6
  • 14
1
vote
3 answers

moving contents from cell to msgbox with spaces?

I've got an interesting problem - I'm trying to write VBA code that will take the contents of a cell and put it into a msgbox. The problem is that I can't figure how to put carriage returns into this string. My code looks something like this. Dim…
1
vote
1 answer

How to Override msgbox Button to Unload Userform in VBA?

I'm very new with vba excel. I'm trying to develop little tool for report formatting tasks in vba excel. I know if i put below code into a button, it will unload my form but how can i override a msgbox's button to unload whole userform? Unload…
t1w
  • 1,408
  • 5
  • 25
  • 55
1
vote
1 answer

Any alternatives for jquery msgbox

I am trying to include a prompt dialog in my project. Jquery Msgbox is good, but they have only allow inputs types like text, checkbox and select. I want to use textarea as I want users to leave their feedback. Is there any jquery plugin that…
Josh Randall
  • 1,284
  • 4
  • 18
  • 31
0
votes
1 answer

PowerShell : How to run a script by double clicking on it ? (without 'Run with Powershell')

[EDIT BELOW : The problem was not the MsgBox] I got a problem : my MsgBox works fine when I run the code from ISE but does not show up when I execute it by double clicking on .ps1 file. I tried all what internet could give me (on others forums and…
Rom
  • 1
  • 1
0
votes
1 answer

I am a beginner with vbscript and this msgbox popup many times as it reads the string mutilple times. Can we do something so it only throw one msg

If InStr(currentoption,"INTUM")>0 Or InStr(currentoption,"SHIM")>0 Then MsgBox "INSTALLER SHIM ET/OU INTUMESCENT ( VOIR W.O. ET CARTABLE INSTRUCTION INSTALLATION DE SHIM ET INTUMESCENT.)" ,vbExclamation End If everytime we have this option in…
0
votes
1 answer

Closing a MsgBox after a certain amount of time in VB.NET?

I need to open a MsgBox that closes itself automatically after a certain amount of milliseconds, regardless of user input. How can I achieve this? Using most recent version of VB.NET Attempted to use a timer but the code executed on timer tick would…
0
votes
0 answers

Message box pop up after set time elapses since file open

Scenario is, there are about twenty team members who take turns opening and editing a non shared excel file. Problem is that many times users forget the file open for extended periods which stops others from accessing to make their updates. What I…
Razaray
  • 1
  • 1
0
votes
1 answer

Excel VBA Scheduled message pop up box reminder

I want to create a script that sends a msg box at a specific time on a specific day of the week. eg every Monday at 10am. Sub Reminder() Dim time As Range Set time = Sheets("Main").Range("W11") If time.Value = "Monday 10:00"…
Amatuer
  • 13
  • 3
0
votes
0 answers

How to add an icon to the title of messagebox in VB.NET 2010

I tried to add an icon to the title of the messagebox. I researched at web, but I can't find a good answer. How do I add an icon to the title of the messagebox? Look to this messagebox: I tried msgbox and messagebox.show but I can't find how to add…
0
votes
2 answers

How to call the MsgBox Function

How do I “Call” Vba’s MsgBox function? Is this the same as just using the actual function itself? I want to make a MsgBox function that returns the date and time.
buddy
  • 1
  • 1