CSCI 207 - Programming in Visual Basic
Fall 2018

Syllabus  Sample Programs

Week Starting  

8/27

Chapter 1-Introduction to Computers and Problem Solving & Other Information about the course

  • Take Role & 1st day attendance
  • What is Programming?
  • What is a compiler?
    • Visual Studio Express Edition
    • Installing it
  • File management / Windows Explorer - Very Important!!!
  • Getting started with our 1st VB Program
  • Importance of truly understanding the first few chapters
    • Terms
    • Don't underestimate the importance of knowing where you saved your program
    • Using the compiler
    • AWA - Alternate work assignments
    • Designing a Program (Software Engineering)
    • What is an algorithm?
    • Flowcharts & Pseudo code
    • More notes

Link to download Visual Basic and some other tools.

 

Writing your first Visual Basic Project

  1. Set up workspace
  2. Start new project
  3. Set up Environment
  4. Plan
  5. Place Controls on Form
  6. Set Properties
  7. Write Code
  8. Run
  9. Save & re-open
  10. Modify
  11. We'll pick some small exercises from the book to do.

Chapter 2 - Visual Basic Controls and Events
(Most of these notes are hands on stuff so I'll do a demo in class and probably go through these quicker than usual)

Lets do some examples in class from the book.

Lab1: #2 Page 110 & 111, Repair Bill. Create a directory on the filestore domain under your account and call it "Lab1". Place this project files in that folder.


Save your homework and labs to:

** In windows Explorer **

\\filestore.cs.edinboro.edu\CSCI207\Fall2018

Use your CS username and password, as if you are login in at the CS lab

9/3

Chapter 3 - Variables, Input, and Output

  • Very important chapter
  • Talk about strings
  • Bring in Questions
  • Look at date and masking

Start Chapter 4

Possible ones to look at:

  • #80 Day of Birth p. 107
  • #32 Federal Income Tax p. 158
  • #27 Age on Various Planets p. 172
  • #29 Investment p. 172-173

 

 

9/10

Cover anything we didn't already in Chapter 4

If time, start chapter 5, some in class sample.

** MsgBox parameters ** (for pop up boxes)

In-class example :Compound Interest (we worked on this already)

We could make some functions for the interest problem.....

A = P\left(1 + \frac{r}{n}\right)^{nt}
  • A = final amount
  • P = principal amount (initial investment)
  • r = annual nominal interest rate (as a decimal)
  • n = number of times the interest is compounded per year
  • t = number of years

 

What is Critical Thinking, and how does this relate to programming.
Blooms Taxonomy

 

 

9/17

Chapter 4 - Decisions

  • If Statements
  • Case Statement
  • Boolean Math
  • Calling other event functions
  • Making one function handle more than one event
  • Some in-class examples
  • possibly look ahead at looping
  • use more functions.

Let's try a problem requiring decisions like nested if or Case statements.  Also lets look at the various types of input such as text box, radio button, list box.

We're ahead so lets look at Chapter 5's notes

 

9/24

Chapter 5 - General Procedures

  • Sub Procedures
  • Function Procedures

  • Review for Exam
  • Let's talk about the design of the pick up sticks game

Exam 1 - 9/28

Will be on:

  • Chapters 1 thru 5
  • If Statement
  • Functions
  • Procedures
  • Boolean
  • Case Statement

 

 

10/1

Chapter 6 - Repetition 

 - Loops
 - Do While
 - Do Until
 - For - Next Loops

Let's start a project today that will use loops for your take home project next week:

We'll write a program to run a linear regression using least-squares:

What is that?  This is a way to predict or model data where it is thought that one variable effects the other. (Independent variable → dependent variable)

This is done by taking known pairs of data where is looks at though there is a correlation and applying it to a calculation.

Write a program where the users enters in two pieces of data (paired) into a list box per line separated by a comma. (You can change this if you want; may be easier to have 2 list boxes)  Grab that data and run the least-squares approximation formula. 

Formula: (see below because this box is too small)

Ok, so you all know that a straight line uses the form y=mx+b where m is the slope and b is the y-intercept.

You are going to use the formula below to get the m and b

Then provide some input for the independent variable (m) and you tell the user y.  Y will be the predicted correlated value for m.

For example, If I gave you 30 pieces of paired data that is height and weight, then I put in a a height into an input box, click the button, your program should predict this person's weight.

 

10/8

Work on the Least-squares project described above for your out of class project

m= (n*(sum of xi * yi) - (sum of xi) * (sum of yi)) / (n * (sum of xi * xi) - (sum of xi)2  )

-- or --



b = ((sum of yi) - m * (sum of xi))/n


-- or --




Make a functions for:

  • sum of xi * yi

  • sum of xi

  • sum of yi

  • sum of xi * xi

  • (sum of xi)2


10/15

Chapter 7 - Arrays

- More organized way to store a lot of related data
- Some consider this the most complex topic of the course.
- Not that hard, just another way to store a lot of related data.


Good example of using parallel arrays:

American to British Translations -> Dictionary.txt


Good 2-D Array Example: Number 25 page 373

Text file for the 2-d array example: Rain.txt Months.txt


Good 1-D Array example

  • Load states and their abbreviations into an array of records
  • display
  • find something
  • Save the states.txt file to the bin folder in the debug folder in the project folder.
  • Project->bin->debug->put text file here.

1-D Array example

Let's compute the average of a list of numbers.  Make sure you load the numbers into an array first.  Then loop again and determine the average.  We are using an array as practice.
List of Numbers


Sorting an Array Example

Write a simple program that sorts a file, we can use the egg data text file , Use either bubble or selection sort. (page 317)
Eggs.txt


Example implementation of an array of Records. 

Justices.txt

Page 356 & 357: 28,29,30,31


Sample 2-D problem 28 page 374
GS-Employees.txt
GS-Pay.txt

 

10/22

Chapter 8 - Text Files

Let's edit the Justice program, add some new features.

This week I also want to make sure we've practiced the Try-Catch block.

Some text files to mess with:

USPres.txt
USStates.txt
AgeAtInaug.txt

Lets look at #20 - 26 page 428 & 429
Cowboy.txt
CowboyCSV.txt

Let's do an old exam I dug up, I want you to give it an honest try first.

Sample Exam 2

If there's time let's assume they are not sorted, and we need to sort them first.


 

 

10/29

Let's do a practice exam:

Load this file into an array of structures: Famous.txt
- Read the data in, put the name in one list box, the date in another list box
- Make a button that puts just the people born in the 70's in the 2nd list box
- Button that displays their name and ages together in the 2nd list box; sorted by birth date


Exam 2 - 11/2

 

11/5

Chapter 9 Additional Controls and Objects

Multiform Projects

Practice:

  • p. 478 - Roll Dice -> images
  • Menu Strip
  • Multiple Forms

In-Class Lab:

Maybe:

p. 476 #53 - The birthday problem (finish this)

and/or

Add a tool-tip to one of our earlier programs

Add a a picture box that plots our linear regression.

p. 477 #54 - Carnival Game

 

 

11/12

Chapter 10 - Database

Do some more examples of database queries.

Download the following databases:

Megacities

Gradebook

 Do an example in class of a project with a database connection

 

11/19

Web Applications - Making a web page with Visual Basic

Sample Car Loan Site

Mobile Friendly Loan Calculator

Maybe Chapter 11

You will notice a WWW folder in your directory on the cs domain. Put any of your web applications there. Don't make any subdirectories other than the ones VB creates on its own.

The URL for the your web pages will be:

http://csci207.cs.edinboro.edu/USERNAME

Your path in Windows explorer is:

\\filestore.cs.edinboro.edu\students\USERNAME\CSCI207\WWW

When creating change the framework to 3.5, create your project in the WWW directory, if asked choose to "open the existing website".

Also!! Delete the web.config file from WWW folder. For some reason doing this lets people see it off of the server (vs. localhost) EVERY time you save it.

Thanksgiving Break

 

11/26

Continue working on the web application

Review for the Exam

Web Stuff:

12/3

Review for Final Exam:

Look at #1 page 506 Membership List

Download text file: Memberphones

Solution for the Membership list

 


Final Exam: Wednesday, December 12th 10:15 → 12:15 (Final Exam)


Assignments:

We start then you finish for grade:
Lab 1 Auto Repair
Lab 2 Investment Calculator
Lab 3 Age on Planets
Lab 4 Eggs
Lab 5 Regression Computation
Lab 6 Supreme Court Justices
Lab 7 Megacities Database
Lab 9 Loan Calculator On-Line (send me URL)


Assignment #

Due Date

Description

1

9/13 Restaurant Menu; Page 176

2

10/17

The Image Editor Project:
Image Editor Assignment Page

Notes:

  • The .PPM files are not layed out row by column as the image properties says
  • In a Visual Basic array, the 1st parameter is the row , the 2nd is the column
    for example x(10,15); this would have 10 rows and 15 columns.
  • The tricky part is loading the image data into an array of the size you want but the values in the file are not layed out like the image is.
  • You probably want to trim the right most space of every line. RTRIM
  • Here is what I did to display the image in a picture box:

I am painting the picturebox1 pixel by pixel.

Where Image.XDimension and Image.YDimension is the width and height of the image that is being looked at. These were read in from the file near the top

Sub DisplayImage()
Dim b As Bitmap = New Bitmap(Image.XDimension, Image.YDimension)
For y As Integer = 0 To Image.YDimension - 1
   For x As Integer = 0 To Image.XDimension - 1
   b.SetPixel(x, y, Color.FromArgb(Image.ImageArray(y, x).red, Image.ImageArray(y, x).green, Image.ImageArray(y, x).blue))
   Next
Next

PictureBox1.Width = Image.XDimension - 1
PictureBox1.Height = Image.YDimension - 1
PictureBox1.Image = b
End Sub

3 10/31

Game of Pass the Pigs

Implement this in Visual Basic. Use some image when you roll.

4 12/5

What If Loan Analyzer

Create a web page that is based off of your 1st Exam. A user can use your page to ask questions of a loan and determine "What If" analysis.

CSS I used to make mine mobile friendly

Good Background Generator: http://bg.siteorigin.com/

  1. Based off of 1st exam (use radio buttons to select the part of the loan you want to determine.
  2. Must be mobile friendly
  3. Check text boxes, so that users must have numbers in them before it will process. have an alert show if they are empty or contain something other than numbers.
  4. Make sure it works if the text box you are determining starts out blank (this seems obvious but test it anyway.)
  5. Test your project on your phone.

Notes:

a) I will run your page on my phone, check for blank fields and characters in the text boxes.

b) the rate function will not always converge to an answer, so it will either crash or give a crazy negative answer.

c) web site for a rate formula (you'll have to solve for the rate "r")

d) My Example (optimized for a cell phone)