Guaranteed Hits to your web site!












Learn Visual Basic 6.0


3. Exploring the Visual Basic Toolbox


The Message Box

  1. One of the best functions in Visual Basic is the message box. The message box displays a message, optional icon, and selected set of command buttons. The user responds by clicking a button.

  2. The statement form of the message box returns no value (it simply displays the box):
    where
    You have no control over where the message box appears on the screen.

  3. The function form of the message box returns an integer value (corresponding to the button clicked by the user). Example of use (Response is returned value):
  4. The Type argument is formed by summing four values corresponding to the buttons to display, any icon to show, which button is the default response, and the modality of the message box.

  5. The first component of the Type value specifies the buttons to display:
  6. The second component of Type specifies the icon to display in the message box:
  7. The third component of Type specifies which button is default (i.e. pressing Enter is the same as clicking the default button):
  8. The fourth and final component of Type specifies the modality:
    If the box is Application Modal, the user must respond to the box before continuing work in the current application. If the box is System Modal, all applications are suspended until the user responds to the message box.

  9. Note for each option in Type, there are numeric values listed and symbolic constants. Recall, it is strongly suggested that the symbolic constants be used instead of the numeric values. You should agree that vbOKOnly means more than the number 0 when selecting the button type.

  10. The value returned by the function form of the message box is related to the button clicked:
  11. Message Box Example:

    Message Box



  12. You've seen message boxes if you've ever used a Windows application. Think of all the examples you've seen. For example, message boxes are used to ask you if you wish to save a file before exiting and to warn you if a disk drive is not ready


Pen Line


Counter Hit Counter Hit


This Homepage is special brought to you by CK Tan
Hosted by www.Geocities.ws

1