dcsimg
June 19, 2018
Hot Topics:

Basics of VB Programming

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

Message Boxes are used to display information to the user. You see them all the time in Windows and other programs.

Message boxes can be called like this:

MsgBox Prompt, Buttons/Icon, Title

The prompt is basically what you want it to say, the buttons/icon is what buttons you want and which icon you want and title is really self explanatory. e.g.

Msgbox "This is a test.",vbCritical,"Title"  

You can use the following constants for buttons:

  • vbOkOnly
  • vbOkCancel
  • vbYesNo
  • vbYesNoCancel
  • vbAbortRetryIgnore
  • vbRetryCancel

and these constants for icons:

  • vbQuestion
  • vbInformation
  • vbExclamation
  • vbCritical

An important thing that you need to be able to do is to translate what the user has done. e.g.

Dim iRes As Integer
iRes=MsgBox("Test Question?",vbYesNo+vbQuestion,"Title"
If iRes=vbYes Then
  Msgbox "The Yes button was clicked."
Else
  Msgbox "The No button was clicked."
End If

To include the contents of a control, such as a text box, you can use the ampersand character (&) to concentate the prompt string (see No Strings Attached). e.g.

Msgbox "The contents is:" & Text1.Text




Page 2 of 6



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date