CST2601 Visual Basic I
Notes on Programming basics


Here is a short program.  The code is shown below.

Put comments at the beginning of the program describing the program and include your name.

 "Form_Load" is a good place to initialize variables that you are going to use.  "Form_Load" subroutine is run once as the form is loaded and displayed.

Notice that I used intermediate variables to hold the results of my computations.  Only at the end do I actually display the results to the label objects.

I created a folder called "CircleArea" on my D:\VBStuff subdirectory.  First I saved the project in the folder.  Then I saved in the form in the same folder.  All the files that comprise this project are in one folder for easy management. 

'Program Circle Area
'Written for CST2601
'Author: Allen Benusa
'Revision: 1.0

Option Explicit
Dim radius As Integer
Dim circumference As Single
Dim area As Single
Const PI As Double = 3.14159265


Private Sub Form_Load()
radius = 0
area = 0
End Sub


Private Sub cmdCompute_Click()
radius = txtRadius.Text           'Get the input

circumference = 2 * PI * radius   'Do the computations
area = PI * radius ^ 2

'Display the formatted results
lblCircumference.Caption = Format(circumference, "###,###.00")
lblArea.Caption = Format(area, "###,###.00")
End Sub