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

MsgBox comes up twice using If answer = Yes/No/Cancel

I am trying to create a macro that will give me a message box before closing Excel to ask if I want to save changes. When I select No from the message box the message pops up again, then the 2nd time that I chose No it does close. I don't know very…
Marleen
  • 15
  • 4
1
vote
2 answers

VBA Excel how to match two column and paste the data in anotherone

i'm new in vba and i would ask something about a VBA code that i made. I've already read this link: VBA - Match Column Data and paste but it's not good for my needs. My target is match column E with column F and give the description inside rows in G…
1
vote
2 answers

Excel VBA formatting and variable output not always working

If a specific value will entered in row "A", a specific price should be inserted into row "D" and after that the entered price should be displayed in a messagebox. The first part was just an easy setup, but with the msgbox I have actually some…
L.Writer
  • 87
  • 7
1
vote
1 answer

autohotkey msgbox closes gui when pressing "ok" button

I made a script with a gui. In the gui I placed a button that opens a messagebox to show more information. The overall use of the script is that it deletes chrome browser history. It just started as a joke but now I try to develop this more and more…
Thimon B.
  • 13
  • 4
1
vote
1 answer

Stop msgbox OK closing text input

Stressed out manager trying to fix a problem in our organisational CRM. We have a macro set up to send 'ad hoc' text messages to clients. The character limit for the text input is 160, and if you exceed that, a msgbox pops up to tell you to reduce…
Kristina
  • 11
  • 1
1
vote
1 answer

Restart Loop At Last Read Row

I'm running a loop to read data from Excel and when I receive an error my script stops and gives me an vbAbortRetryIgnore option within a MsgBox. If I get an error, I want to be able to restart the loop at the beginning of that row that it stopped…
1
vote
1 answer

VBA collections - List found items in MsgBox

I was wondering about making a word searcher in a Word document. Previously, all I managed to create is a code that makes it possible to highlight the words I added to a list: Sub example Dim w(3) as String Dim k, l as Integer w(1)= "word1" w(2)=…
xendrogee
  • 13
  • 4
1
vote
1 answer

'MsgBox' is not declared. It may be inaccessible due to its protection level

I have been using vb.net from a long time, but never had this issue. For some reason Intellisense is not detecting MsgBox(). When I hover over the highlighted red line it says "'MsgBox' is not declared. It may be inaccessible due to its protection…
user8657231
  • 67
  • 1
  • 8
1
vote
0 answers

Add timestamp, duration, developer's note, and relocate affected row based on a "Resolved" drop-down selection

I am working on a tracking document for work for software errors: https://docs.google.com/spreadsheets/d/1UNAUm23iAOlc4VqgW591gGBU758RddcGNdW2SDYCvk8/edit#gid=258517814. When a developer has completed a bug fix, they select "Resolved" from a…
1
vote
2 answers

VB.Net - Specified Cast is not valid But Debugger showing value

The code i am trying to run is a simple one. get text from a Textbox and display that via MsgBox. now i probably have done this a million times but i get a strange error. The Code is : Dim s As String = FromDateTEX.Text.ToString MsgBox(s) I get…
Ali Hanifi
  • 408
  • 1
  • 5
  • 18
1
vote
2 answers

Notify the text in the cell when the event is fired

I was able to manage to be notified when an event's circumstances is met. Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range For Each c In Range("H2:H7") If Format$(c.Value, "HH:MM:SS") = "00:15:00" Then MsgBox "Block…
1
vote
1 answer

Microsoft access VBA MsgBox not responding, what am I doing wrong?

so I have put together an asset check out sheet. There is a Check out button, I want a message to prompt " User ID is required" when it is clicked , if the user ID field is left blank . However, that is not the case with my current code, it just…
Komakino_1251
  • 220
  • 2
  • 13
1
vote
1 answer

How to add the input from InputBox into MsgBox

I want to add the inputted text from an MsgBox into a Msgbox I got this but it don't work. Can anyone help me? Dim x x = MsgBox("Welcome to this software. Are you new with this?", vbYesNo + vbQuestion, "Welcome!") Dim f f = strMessage…
1
vote
1 answer

Time out on msgbox

Is there a way to add a timeout to the message box so if there no input it defaults to no? I would like it to default to No after 1 hour @echo off Call :YesNoBox "Are you sure you want to do that?" if "%YesNo%"=="7" ( Call :MessageBox "You answered…
user14875
  • 11
  • 1
1
vote
1 answer

(VBA) For loop and DLookup (MS ACCESS)

I have a query named TimeQuery. I want MsgBox will show all [start_hour] values where [id]=1 then 2 etc. ... I have a problem. When i will use: a = DLookup("Hour([start_hour])", "TimeQuery", "[id]=1") it works good, but when use [id]=counter it…