Chris's Event Programming with Visual Basic course.

Contents
Introduction

Conventions

Starting VB3

The development environment

Help Documentation

The "On-line" Tutorial

Starting a new project

Making an application

Working with Forms

Modal forms

Multiple Document Interface (MDI)

Building the interface

Menus 

Tool Bars & Control Arrays

Building a Control Array

Z Order

Custom controls

Handling Data

Input Boxes

Message Boxes

Error Trapping

The Data Manager

Data Aware Components

Debugging code

Compilation of code 

Message Boxes
We have already used many of these to provide visual feedback that an event has occured, but they can also be used to determine logical events. Add a new form to your current project, amend the code above so that it now reads;
Sub Command1_Click ()
Dim Answer, DefVal, Msg, Title, resp                     'amended
    Msg = "Enter a value from 1 to 3 to continue, or 4"  'amended
    Title = "InputBox Demo"
    DefVal = "1"
    Do
        Answer = InputBox(Msg, Title, DefVal)
    Loop Until Answer >= 1 And Answer <= 4               'amended
    If Answer = 4 Then                                    'new sequence
        resp = MsgBox("Change Forms?", 52)               '2nd argument is 4 (yes no)+ 48 (info icon)
        If resp = 6 Then                                  '6 is yes and 7 is no
            form2.Show
        End If
    Else
        MsgBox "You entered " & Answer
    End If
End Sub

When this is ran you can see that the message box directs the processing of forms according to the response. See the VB3 on line help for all the values available for the type argument.
 
 
 

Visual Basic and all other Microsoft products mentioned in this series are trademarks of the Microsoft Corporation.