Getting Inputs to Add Two Numbers

In this beginner's lesson we develop a simple Visual Basic program which adds together two User Input Numbers.

We start with the Application Design Process for the Form and the Program Pseudocode.

We then build the first version of the Application, which uses two different methods of obtaining User Input from the Form and converting it to numeric format.

The first method involves the Val() function, and the second method involves Casting as a Double CDbl() function.

We then test the application and find there are program crashing issues if the User leaves inputs blank, or enters any non-numerical input onto the Form.

Input Validation using Try.... Catch... End Try is then added to pinpoint all data input errors and send message alerts to the User.

Finally we explain why Casting combined with Validation is the superior method for obtaining User Data Inputs.


LESSON OVERVIEW

This lesson consists of a Video Presentation where we cover the following:

- Introduction and Overview
- Application Design
- Form Detailed Design
- Create Form in Visual Basic
- Save All of Project
- Program Code Version 1
- Code for the Clear Button
- Blank Input Data Problems
- Running a Generated Application
- Difference between Val() and CDbl()
- Adding Try....Catch...End Try
- Using CDbl() instead of Val()
- Version 2 using CDbl and Try...Catch...End Try
- Why using CDbl is best for Numeric Conversions

 

Watch the following YouTube Tutorial Video of the Full Lesson

If you would like to get a FREE copy of the Presentation Slides covered in this video, then click the link below.

Click Here to Download the Presentation

Click Here to Download the Program Code

 

Click here to Return to the Programming Course Page