Visual Basic Examples




Problem: Textbook Page 82 and 83, Problems 53 - 58

Demonstrates algebra in VB, subroutine structure, variable declaration, and other basic code in VB. Written in module form meaning it does not use a GUI interface. Output goes to the immediate window.

Textbook Examples 53-58 Page 82-83


Problem: Calculate a simple interest car loan by prompting user for data, processing data using a long formula, and outputting data to a message box.

Demonstrates use of input box and message box for input and output. Also shows how to break down complicated formulae into small chunks.

Monthly Car Payment in VB PDF


Problem: Input a number from an external file, print the number, its square, and its cube in neat columns.

Demonstrates inputting from external file and some algebra in VB

Print number, squared and cubed in columns


Problem: Input a word from and external file and write the word and its middle three letters to an external file

Demonstrates input and output to external files

Input Output To External Files


Problem: Given a test score, translate to a letter grade

Demonstrates the use of While/Wend and If/Then/Else statements

Letter Grade Translator in VB PDF


Problem: Input numbers from and external file, pass numbers as arguments to a sub, add numbers, output total to immediate window.

Demonstrates how to pass arguments to subs in VB

Sub Argument Passing in VB PDF


Problem: Create a user interface for a bagel store

Demonstrates simple GUI interface in VB and shows code for the GUI

Bagel Interface


Problem: Sort an external file

Demonstrates selection sort in VB

Selection Sort VB PDF


Problem: Given a file of temperatures, input them into an array, neatly display the array forwards and backwards, sum and average the array, and find the smallest and largest values in the array.

Demonstrates ways to work with arrays

Example of working with array in VB PDF


Problem: Given a file of teacher names and their current pay, write a program to input the data, calculate 8% raises for each and print a nice chart to display the name, new pay, and old pay of the teacher. Number of teachers in the file is unknown until run time.

Demonstrates using subroutines to break a problem down into manageable steps.

Pay Calculator VB PDF


Problem: Given a list of names and zip codes for those names, input that list from an external file and store them in a single user defined data type. VB does not have any data type (int, double, etc.) that can hold a name/address combo. That is why you have to use your own data type.

Demonstrates: user defined data types, input from external file, formatting output tables with user defined functions.

VB User Defined Types PDF


Problem: Input items from an external file, put them into an array, sort the array, print the array.

Demonstrate: Input from external file, sorting, array filling

Array Sort VB PDF