Skip to content
ThinkforceOne

ThinkforceOne

Solutions to help you achieve more with your tools.

  • Home
  • Windows
  • Mac OS
  • MS Office
  • TextScript
  • Printing
  • CAD
  • Design
  • Hardware
  • About
  • Toggle search form

Create Message box in VBA or VBScript on Windows

Posted on 2023-04-202023-04-20 By Alan Salihi

Do:

Use the funciton to create this.

Example:
Create a text file and paste the following code in it.
Save the file as VBS file extension.

x=msgbox("Message Text" ,0, "Window Title")

Buttons:

The button value is calculated by adding the values of each of the Groups 1 – 4 to gether:
1+256+48=305
where:
1 : Buttons “OK” and “Cancel”
256: Second button from left is default.
48: Icon type is Alert.
see the tables below for more information.

Message:

Use either:
The character codes for a carriage return and line feed, Chr(13) & Chr(10).
The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf.

Explanation:

MsgBox (prompt, [ buttons, ] [ title, ] …)

PromptDescription
Message-TextRequired. 
String expression displayed as the message in the dialog box.
Maximum length approximately 1024 characters (depending on the width of the characters used).

For multi-line text: separate the lines by using either:
– a carriage return character (Chr(13)),
– a linefeed character (Chr(10)),
– or carriage return – linefeed character combination (Chr(13) & Chr(10)) between each line.
0 (buttons)Optional. 
Numeric expression (number) – a combination of values specifying the number and type of :
– buttons to display,
– the icon style to use,
– the identity of the default button,
– and the modality of the message box.

If omitted, the default value for buttons is 0.
Window-TitleOptional.
String expression displayed in the title bar of the dialog box.

If you omitted, the application name is placed in the title bar.
Syntax prompts
ConstantValueDescription
Group 1
ConstantValueDescription
vbOKOnly0Display OK button only.
vbOKCancel1Display OK and Cancel buttons.
vbAbortRetryIgnore2Display Abort, Retry, and Ignore buttons.
vbYesNoCancel3Display Yes, No, and Cancel buttons.
vbYesNo4Display Yes and No buttons.
vbRetryCancel5Display Retry and Cancel buttons.
Group 2
vbCritical16Display Critical Message icon.
vbQuestion32Display Warning Query icon.
vbExclamation48Display Warning Message icon.
vbInformation64Display Information Message icon.
Group 3
vbDefaultButton10First button is default.
vbDefaultButton2256Second button is default.
vbDefaultButton3512Third button is default.
vbDefaultButton4768Fourth button is default.
vbApplicationModal0Application modal; the user must respond to the message box before continuing work in the current application.
vbSystemModal4096System modal; all applications are suspended until the user responds to the message box.
Group 4
vbMsgBoxHelpButton16384Adds Help button to the message box.
vbMsgBoxSetForeground65536Specifies the message box window as the foreground window.
vbMsgBoxRight524288Text is right-aligned.
vbMsgBoxRtlReading1048576Specifies text should appear as right-to-left reading on Hebrew and Arabic systems.
Button Combinations
ConstantValueDescription
vbOK1OK
vbCancel2Cancel
vbAbort3Abort
vbRetry4Retry
vbIgnore5Ignore
vbYes6Yes
vbNo7No
Return Values

Resources:

  • MsgBox function (Visual Basic for Applications) | Microsoft Learn
  • Visual Basic how-to topics | Microsoft Learn

Post Views: 26
TextScript, Windows

Post navigation

Previous Post: Vertical/Portrait Videos in iMovie iOS
Next Post: Display files side by side on MacOS

Related Posts

Folder Security Permissions hero Change Folder Permission under Windows 11 and 10 Tech
PDF24 Convert Image to PDF Combine or Convert Multiple Images into one PDF File on Windows 10/11 PDF
Arranging App Windows in Windows Windows
USB-C ports deactivate when laptop sleeps Hardware
Show Hidden Files on Mac OS and Windows Mac OS
Create macros in Notepad++: EOL Break lines or join lines using custom delimiter Tech

Share this

CATAGORIES

Categories

  • AutoCAD
  • CAD
  • Canva
  • Design
  • Hardware
  • iOS
  • Mac OS
  • MS Excel
  • MS Office
  • MS OneNote
  • MS Word
  • PDF
  • Printing
  • Tech
  • TextScript
  • Uncategorized
  • Windows
POSTS

Post

  • December 2024
  • November 2024
  • June 2024
  • May 2024
  • April 2024
  • February 2024
  • December 2023
  • August 2023
  • April 2023
  • March 2023
  • December 2022
  • November 2022
  • July 2022
  • June 2022
  • May 2022

About

  • Privacy Policy
  • About
  • Contact
  • Copyrights

Connect with us

  • Facebook
  • Twitter
  • Instagram
  • YouTube
April 2023
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
« Mar   Aug »

Copyright © 2025 ThinkforceOne.

Powered by PressBook Grid Blogs theme

We are using cookies to give you the best experience on our website.

You can find out more about which cookies we are using or switch them off in .

ThinkforceOne
Powered by  GDPR Cookie Compliance
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.

If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.