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

How to put output, MsgBox Result on new column

I am tracking payments made on a large excel file. In column C, I have the date we received the payment, in column I, I have the date paid. I'd like to calculate how many months between column C (when we rcvd invc) and column I (when invc was…
Vee
  • 21
  • 2
2
votes
2 answers

Generate dialog result from a custom message box class

I am developing a custom messagebox class like the following- Public Class MyCustomMsgBox Private MyForm As Form = New Form Private lblHeadline As Label = New Label Private lblMessageBody As Label = New Label Private btnNo As…
s.k.paul
  • 7,099
  • 28
  • 93
  • 168
2
votes
1 answer

Custom CSS chat bubble

I created a chat bubble using CSS. But I did not get the output I want. Here is my code, body{ background-color: lightgreen; } .bubble { margin: 100px; display: inline-block; position: relative; width: 300px; height: auto; …
2
votes
0 answers

Open a MsgBox with focus under Windows 10

I am unable to open a MsgBox with focus under Windows 10. I use VBA 6 (Sax ActiveX Scripting Control, © 1993-2006, Polar Engineering) to write commands for Dragon speech recognition software. These "commands" are small programs triggered by…
2
votes
1 answer

Msgbox in PowerShell script run from task scheduler not working

I have a PowerShell script that creates a schedule task to launch the script. The idea is there are some task in the script that requires reboot. At the end of the PowerShell a message box should prompt the user to let the user knows that all the…
nickyung
  • 23
  • 5
2
votes
2 answers

If statements - msgbox

I'm now trying to write an IF statement to say something to the effect of: If file is more than 5 days old, do not run macro. If more than 5 days old, run macro. I would like to this to be a yes or no dialogue box. Here is my code. Please help. I'm…
2
votes
1 answer

VBA MsgBox Limitations - output more than 1024 characters

I want to display long message in MsgBox (more then 1024 characters). What method can i use. I found this: Dim objShell As Object Set objShell = CreateObject("Wscript.Shell") Can You tell me are there any methods to achieve this? Maybe someone…
tomek198823
  • 115
  • 2
  • 11
2
votes
2 answers

In C# is there a way to shorten reference calls like Microsoft.VisualBasic.Interaction.MsgBox() to something like myMsgBox()?

I'm new to c# so I apologize if this is a stupidly obvious question, or if I worded it in a bad way. I'm working on a VC# project that requires the use of the MsgBox() and InputBox() methods pretty frequently, and it's getting frustrating to either…
blitzilla
  • 31
  • 2
2
votes
2 answers

MsgBox SelectionChange define range

I have written the following code: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim myValue As Variant If Range("B22") = "Yes" Then myValue = InputBox("InsertInitialDetach") Range("C22").Value = myValue End If End…
RobertC
  • 51
  • 1
  • 7
2
votes
4 answers

Excel VBA IF then IF statement

I am using an "If Then If msgbox vbYesno" Statement and I am not sure how to get out correctly of it (I know Goto is not clean). Can someone tell me what my mistake is? I did not find anyone using something similar. Sub IF_THEN_IF() If…
Pierre44
  • 1,711
  • 2
  • 10
  • 32
2
votes
6 answers

VBA - Open a msgbox when cell value = 1

I need help with a very basic vba macro. When the value in A6 is equal 1 a msgbox needs to appear in the workstation. I developed the below code but the problem is that when I add any other information in the spreadsheet (for example, if I write "i…
2
votes
3 answers

VBA - MsgBox a 2D Array (Matrix)

I am trying to visualize a 2D Matrix (Array) using a MsgBox, but the code I have doesn't give me the correct representation. Sub test() Dim M(22, 7) As Double TwoD_Array_Matrix_In_MSGBOX (M) End…
Trenera
  • 1,435
  • 7
  • 29
  • 44
2
votes
1 answer

Excel MsgBox with VBA for multiple linked range

I need some help with an excel problem. It is a combination of the two problems below: 1) Excel - Popup message with sound alert when cell value meets certain criteria 2) VBA code to show Message Box popup if the formula in the target cell exceeds a…
Ming
  • 23
  • 3
2
votes
1 answer

VBA, constantly listen to changes in cells that meet specific criteria

I am new to VBA, I have an excel sheet that contains data on stocks. column A - stock ticker column B - stock name column C - "the variable number",the number that changes all the time. When the number in column C is between [-4;4], then a message…
Laura Lee
  • 35
  • 3
2
votes
2 answers

Getting return value from .vbs called from Windows CMD

I've got a CMD file that writes a MsgBox popup command to a VBScript file, then turns around and immediately executes it. Originally it just used an "OK" button to dismiss the warning that user version was out of date. I want to modify it to use…
Mark Seagoe
  • 480
  • 8
  • 15
1 2
3
26 27