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 

Input Boxes
Open a new project., place a command button  on the form and write the following code to it’s click event;
Sub Command1_Click ()
Dim Answer, DefVal, Msg, Title                  ' Declare variables.
    Msg = "Enter a value from 1 to 3."          ' Set prompt.
    Title = "InputBox Demo"                     ' Set title.
    DefVal = "1"                                ' Set default return value.
    Do
        Answer = InputBox(Msg, Title, DefVal)   ' Get user input.
    Loop Until Answer >= 1 And Answer <= 3
    MsgBox "You entered " & Answer              ' Display message.
End Sub

If this is ran, the following dialogue appears when the command button is clicked;

 
Typing a correct value prompts a message box to be displayed from which the focus can be returned to the form, typing an  incorrect value re-displays the InputBox.

If an incorrect type, i.e. non-numeric is input then an error occurs. This is discussed in the next tutorial.
 

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