Visual Basic Programming in CST 106K01

 

There have been many programming languages developed and used for computers.  These include BASIC, Fortran, Algol, Cobol, APL, C, C++, C#, Java, Java Script, and others.

 

BASIC was an early language for the mainframe and the personal computer.  BASIC runs in a DOS environment.  With the popularity of Windows, Visual Basic is a modernized version of the older BASIC.  We’ll be using a modified version of VB that comes with both Word 2000 and Excel 2000.

 

In Word and Excel, these small VB programs are called ‘macros’.  Unfortunately, this is also the way a computer virus can be attached to a Word or Excel document.  To use VB in Word or Excel you must turn off the security precautions provided by those programs.  The first VB program will show you how to do that.

 

I’ve prepared a number of sample programs for you to look at.  The first of these are Word documents. While these should open within WebCT, you may want to save these on your desktop for convenience.

 

The first program, MsgBox.doc, will put a windows message on the screen.  Follow the directions.

 

The second program, MsgBox2.doc, does some simple arithmetic.

 

The third program, Calculate.doc, performs the multiply function as a calculator would.

 

The fourth program, Calculate2.doc, is a little neater.  It lets the user enter numbers more directly and performs more math functions. 

 

The fifth program, SlotMachine.doc, is a slot machine! This one is incomplete and waits for you to complete it. There is a handout for this program that you will have to obtain from me with detailed instructions.

 

The sixth program, FileIO.doc, shows how to save calculations in a file on your hard drive, or in MyDocuments. This will be very useful when we use our programming skills to solve complicated formulas for us easily.

 

In #7, TrigTable.doc will create a table of Sine, Cosine, Tangent values for us for a desired set of degree increments.

 

Here are some executable files to look at and play with.  Can you figure out how to create the forms and write the necessary code?

 

TrigTable.exe  Creates a table of Sine, Cosine, Tangent values.  Enter the number of lines you want!

 

MyMoney.exe   The Microsoft Slot Machine ( Or Lucky Seven )

 

K3Mapper.exe  Professor Antonakos’ 3 variable Karnaugh Map ( EET 115 and EET 267)

 

RLCSeries.exe  Resonant Circuit Calculator for an RLC series circuit ( Try R = 2.5, L = .001, C = .000001 )

 

You have to use MS Visual Basic to create the executable; the version in Word and Excel won’t do it.