My class notes indicate my plans for the class. They sometimes communicate information that is useful to know for class and, thus, can be a reference for you. Sometimes they merely indicate talking points or planned activity. They will often have links that could be useful. All in all, they are probably worth reading/reviewing before and/or after class. Certainly, students who will be or have been absent should look here.
Day 1 — Course Intro
Logistics
- Today
- Seating arrangements & roll
- Course & instructor introduction
- Success in this course
- Brief discussion of Programming & PcPI
- Wonderings? Comments?
Roll & Seating Chart
- Temporary seating chart today; revise/finalize it next time
- Why choose a seat
- to see/hear better
- to be near friends
- to be near helper/helpee
- to have access to electrical power
- to be closer to/farther away from me
- Change places if you want
- Take roll; produce seating chart
Instructor & Course Introduction
Programming & PcPI
This course hopes to teach (that you learn) programming (in Visual Basic). So, ...
- What is programming?
- ?
- Preparing a set of instructions for the computer to carry out.
- Basic elements/aspects/skills/understandings of programming
- "simple" data and collections of "simple" data representing the "problem" being solved
- determining the manipulations of the data that "solve" the problem
- sequencing action statements that accomplish the desired manipulations
- selecting between alternative actions (with action/no action a possibility)
- repeating actions a given number of times or under specified conditions (so long as something remains true or until something becomes true)
- modularizing a set of actions—creating a new action by combining basic actions (and/or previously created actions)
(data, actions, sequence, selection, repetition, modularization)
- Wonderings? Comments?
Programming is problem solving
Like giving directions in a foreign language, programming is a problem solving activity. But, for people learning to program, there are three problems, not one. In our example, you'd first have to figure out just what directions you wanted to give. Then, you would have to translate those directions into the foreign language (and translations are not simple word for word substitutions). But if you don't know the foreign language, you have to learn the language before/as you do the translation. Similarly for programming—3 problems:
- Developing the solution (probably an outline of actions needed to solve the problem)
- Translate the solution into code, including making sure the problem representation in data the computer understands will work
- Deciding which language pieces you need to translate the solution into—may involve learning pieces you didn't
PcPI (didn't get to this in class)
Programming is often taught like math. We show you a "thing" and ask you to work on a bunch of "things" like it. Then we show you another "thing" and ask you to practice things like it. And another, and another, and ... But, they (math folks) and we (computer science folks) don't usually address what the "things" are good for—how they help us solve problems. We (several of my colleagues and it) think you will learn better if you see the how/why—the context of the problems.
PcPI (problem-centric programming instruction) attempts to focus on problems as we teach programming (rather than just teaching the language being used). So, many of the exercises and problems will be presented with a story/context or as a word problem. That means that you will have to figure out what to to before you start doing it, i.e., it will be (hopefully) a problem solving process.
In most problem solving contexts all you have to do is solve the problem. In programming you have to develop a solution to the problem and then covert the solution to a computer program. For you, there is the additional burden of learning how to program while you are doing the problem solving.
Just like riding a bike, playing a musical instrument, performing a beautiful dive, etc., programming is easy, if you know how to do it. If you don't know how to do it, it might come to you fairly easily, but it might also be quite daunting. With PcPI we are trying our best to work on all three problems: solving the problem, converting the solution to code, and learning the code and how it works.
So, ...
- Assignments will have lots of practice exercises to cover learning the programming language
- Most of them will have a problem context that is an "every day" kind of problem (for someone). Those that don't will be in the form of a generalized problem, e.g., "Find the largest of three values."
-
- Units IV & V will have slightly larger problems that involve choosing or repeating the kinds of things learned in Units II & III
- We will talk about problems, problem solving, and a process you can use when you have trouble.
Wonderings? Comments?
Course Success
Our goal is to be successful? What does that mean? What can we do to make the course successful? (Discuss student responses to the following.)
- What does success look like? For you?
- What does success look like? For me?
- What can I do to enhance the likelihood or degree of success for reaching our goals?
- What can you do to enhance the likelihood or degree of success for us all?
- Attend class and think/question during presentations and discussion. (What is being said? Do I understand/does it make sense? Do I agree? ...)
- Read suggested parts of the text. Review class notes after class.
- Ask questions when you don't understand/agree.
- Persist when I am too dense to see your point.
- Do all the assignments to the best of your ability.
- Seek help when you have difficulty on the assignments. (e-mail, office hours, classmates, ...)
- Look things up—in the text, on the web, in my class notes
- Start thinking about what you want to do for your project.
- ?
- Anything else? Wonderings? Comments?
Next Time/To Do:
- Plans:
- Final seating chart
- Visual Studio demo (if computers have been updated; otherwise we will discuss problem solving, problem representation, and algorithm development)
- To prepare for class:
- If you have a Windows machine, download and install Visual Studio (Mac folks have to use a PC or figure out how to run windows on their machines.) Start it up (to make sure it works).
Any final questions? comments? wonderings? . . . See you Thursday.
Day 2 — Visual Studio Demonstration (Flyby vs demo AND problem solving demo)
Logistics
- Roll & finalize the seating chart
- Demonstration of Visual Studio (if laptops ready to go)
- Problem example (if laptops not ready)
- Wonderings? Comments?
Visual Studio
Even though our computers are not ready, I will want to provide an overview of using the system. We will do this more step by step in class, next time. The text below describes the overview, I will merely run the through the process at this time.
Overview
Visual Studio is an IDE (interactive development environment) for creating programs in a variety of languages, including Visual Basic. The first programming task is to create the forms/windows for the program. Then code can be written to indicate what happens with each of the form elements/controls.
Typically each VB program is a project which has a number of forms or windows, one of which is a start form called Form1
. Forms have properties each having default or assigned values. We will want to change the values for some of the properties (e.g., name and text). Then we will start producing our forms. When we have them created we will need to identify which form we want to use as our start form.
We will typically just ignore Form1
, the default form Visual Studio creates as we produce the form(s) needed for our program(s). (Ask me why if you want to know.) The general process for doing a VB program/project is:
- Start a new project (naming it while doing so)
- Create our first form for the project (naming it while doing so), and:
- Change appropriate/desired form property values using the Properties window, probably:
Text
, Size
(manually or via Properties), ControlBox
; perhaps ForeColor
, Font
, BackColor
; and possibly something else.
- Add controls using the Toolbox window, commonly:
TextBox
, Label
, Button
, GroupBox
, CheckBox
, RadioButton
; perhaps: PictureBox
, ListBox
, MenuStrip
and other elements needed by your project, e.g., OpenFileDialog
, DateTimePicker
, ProgressBar
, ComboBox
, etc.
- Change properties of the various controls we place on a form, commonly:
Name
, Text
; perhaps: Font
, ForeColor
, BackColor
, AutoSize
, Size
, TextAlign
, ReadOnly
, Multiline
, Checked
, TabIndex
, etc.; and possibly something else.
- Adjust the size of the form and the layout of elements on the form, perhaps via the Format tab
- Check to see that it shows up and works like we want by using the Start tool on the toolbar at the top of the window, perhaps after setting the value of StartForm property of the project.
- Use Save All to ensure the project is recorded on persistent storage
- Creating remaining forms
- Producing code for the forms and form controls
The material below in the next class notes provides details of this process.
Problem Solving
Last time we talked about programming and problem solving. Remember that one part of programming is determining how to represent the problem using the data definitions available in the programming language. VB has controls that are a kind of data but there is other data underlying those controls. There are three (I forgot one last time) kinds of data in VB—numbers, characters, and Booleans. Boolean data consists of just two values, True and False. Our solution and our program needs to be in terms of those kinds of data.
Determining the problem representation and developing a solution/algorithm are a chicken and egg situation. One doesn't necessarily come first and they both are necessary. The material below suggests we think first about possible general solutions; then problem representation, then algorithm development.
Missing Card Problem
- Discuss the problem—you have a deck of cards, one unidentified card is removed, the task is to determine the missing card.
- Identify possible solutions
- students work with a classmate to discuss how to approach the problem (3-5 minutes)
- list the approaches and briefly discuss them
- comments? wonderings?
- How can we represent this problem for the computer? (list any suggestions)
- Likely representations of this problem for a computer program
- card
- a pair of strings ("Spades", "Hearts", "Clubs", "Diamonds" & "Ace" and"Two", ... "Queen", "King")
- a pair of numbers (1-4 for suit and 1-13 for rank)
- a single number (probably 0 - 51) each with an interpretation that yields a unique pair of values for suit and rank
- deck
- an array or other collection of string pairs
- an array or other collection of number pairs
- an array or other collection of numbers
If we wanted to use pictures of cards in our program, we would merely need to know which card. In this case we would likely use a single number for a card and the collection of numbers for the deck.
- Solution/Algorithm
Regardless of the algorithm, the following will likely be the general solution.
initialize-deck
shuffle-deck
remove-a-card
determine-missing-card
report-missing-card
The part we are most interested in is the "determine-missing-card" part (module).
- One solution/algorithm (make piles by suit)
for each card we have
get/look-at-the-card
if the-card-is-a-spade
put-it-in-the-spades-pile
if the-card-is-a-heart
put-it-in-the-hearts-pile
if the-card-is-a-club
put-it-in-the-clubs-pile
if the-card-is-a-diamond
put-it-in-the-diamonds-pile
set pile-found to false
repeat until pile-found
choose suit pile to work with (set current-suit)
set count to 0
for each card in the pile
add 1 to count
if count < 13
set pile-found to true
set missing-card-suit appropriately
sort-the-pile (Ace down to Two)
for each card in the pile
if card-does-not-match-position
set missing-card-rank appropriately
report the missing card
Once we decide how to represent the cards, the above "algorithm" can actually be translated pretty much directly into code. The code would depend on the presentation of the deck and the programming language we were using, but not much else.
- An alternative solution/algorithm (a checklist)
create a checklist (has a value for each card)
for each item in the list
set it's value to False
for each card in the deck
get/look at the card
set the checklist item for that card to True
for each item in the checklist
if checklist item's value is False
set missing card values
report the missing card
- Comments? Questions? Wonderings?
Next Time/To Do:
- Plans:
- step by step Visual Studio demo
- zipping and submitting project code
- To prepare for class:
- Download and install Visual Studio if desired.
Any final questions? comments? wonderings? . . . Have a good weekend. See you Tuesday.
Day 3 — Visual Studio Demonstration/Practice
Logistics
- Roll
- Demonstration of Visual Studio
- Wonderings? Comments?
Laptop Use in ITTC 328
- Go to the cabinet; pick a laptop unplug it; and note its location/number
- Return to your seat and open the lap top; if it doesn't light up, press the power button
- If it asks for a bit locker password, enter
compsci1
- When directed, press CTRL-ALT-DELETE and log into your UNI active directory, be patient
- Start Visual Studio
- Do your work
- Log out
- Return the laptop to the cart, in the appropriate position above its number, and plug it in
Getting Started
The practice activity will be essentially the preparation of the forms we'll use in Unit II. The process overview is:
- Access the computer & log in
- Start Visual Studio—don't sign in
- (First time only, we hope) Choose Visual Basic as the preferred development setting (and wait patiently)
Before we go any further we need to sketch out our forms for the project. We need three forms—a start form, a numerics form, and a strings form. The ACSII art below approximates a sketch done on the board.
- Start form
========================================
| VB Practice Options |
|--------------------------------------|
| |
| ---------------- |
| ( Numeric Basics ) |
| ---------------- |
| |
| ---------------- |
| ( String Basics ) |
| ---------------- |
| |
| ---------------- |
| ( E X I T ) |
| ---------------- |
| |
| |
========================================
- Numeric Basics form
==========================================================
| Basic Numeric Tasks, Operations, Functions, etc. |
|--------------------------------------------------------|
| |
| --------------------- ------------ |
| Input 1: | | ( Basic Math ) |
| --------------------- ------------ |
| --------------------- ------------ |
| Input 2: | | ( Advanced ) |
| --------------------- ------------ |
| --------------------- ------------ |
| Input 3: | | ( Functions ) |
| --------------------- ------------ |
| --------------------- |
| Input 4: | | |
| --------------------- |
| |
| |
| --------------------- |
| Result/Output: | | |
| --------------------- |
| |
| |
| ------------- |
| ( E X I T ) |
| ------------- |
| |
==========================================================
- String Basics form
========================================================
| Basic String Tasks, Operations, Functions, etc. |
|------------------------------------------------------|
| |
| --------------------------------- |
| "Small" Text: | | |
| --------------------------------- |
| --------------------------------- |
| Bigger Text: | | |
| | | |
| | | |
| | | |
| --------------------------------- |
| |
| --------------------------------- |
| Result/Output:| | |
| --------------------------------- |
| |
| |
| ------------ ------------ ------------ |
| ( Basic ) ( Advanced ) ( Functions ) |
| ------------ ------------ ------------ |
| |
| ------------- |
| ( E X I T ) |
| ------------- |
| |
========================================================
The general process for this activity is shown below. After that a more detailed set of directions is provided.
- Create a new (named) project
- Add a form
- Create and name the form
- Add controls to the form
- Change their properties appropriately
- Double-check form appearance
- Save All regularly
- Add other forms with appropriate controls and appearance
- Add code to connect the forms
- Test the project
Let's Do It!
First, we'll do a step by step or the first/start form.
First Form
- Everybody have Visual Studio running? (Handle any problems)
- Create new, named project
- Double check: Visual Basic is selected; Windows Forms Application is highlighted
- Enter project name in text box near bottom of the screen (I suggest
VB-practice_xxx
where "xxx" is replaced by your initials)
- Note the path of the project so you can find it. You may want to click the Browse button to put the file on your desktop or some other special place
- Click the OK button (be patient)
- Add a new, named form
- Click on the Project tab
- Select Add Windows Form… (at top of menu choices)
- Change name from Form2.vb to something else (I suggest Start.vb
- Click the OK button
A new form appears. I suggest you hide the Form1.vb (Design) window by clicking the X on its tab.
- Set form properties
- Find the Properties window; make sure the form is selected (thin line surrounding it and little adjustment squares at right, bottom and lower-right corner)
- Text
Set the Text property. I suggest something like "VB Practice Options"
- ControlBox
Find the ControlBox property, click on it, select False from the menu.
- Other stuff
Explore and perhaps chance other properties such as Font, BackColor, ForeColor
- Add a button for the numeric practice form
- Add another button (for the string practice button)
You can use the process above to add the next button OR you can copy and paste the first button and change it properties appropriately. Those directions follow
- change the Text property value ("String Basics")
- change the Name property value ("btnStrings")
- Other stuff?
- Add the Exit button
- change the Text property value ("E X I T")
- change the Name property value ("btnExit")
- change the color property value (to red)
- change the Font property value (to something squarish & bold and probably larger)
- Check the layout, adjusting positioning, etc. of the elements within the form
- Save All
Questions? Comments? Wonderings?
Next Form
Okay, let's move on the the "Basic Numeric Tasks ..." form. The new things here are:
I think/hope the above material allows you to complete the second form. If not, let me know.
Third/Last Form
Okay, let's move on the the "String Tasks ..." form. Remember that you can copy and paste a label & text box pair from the previous form to this one. The "new" things here are:
It was suggested in class that we could copy and paste the buttons from the second file as a group ... and that works! And the names and text properties are copied as well and that is okay because there can controls can have the same name IF they are on different forms.
I think/hope the above material allows you to complete the last form. If not, let me know.
Next Time/To Do:
- Plans:
- "running" the program
- zipping and submitting project code
- practicing all this
- To prepare for class: bring any questions you have
Any final questions? comments? wonderings? . . . Have a good weekend. See you Thursday.
Logistics
- Roll
- Today: Unit-I practice activity (some demonstration then worktime)
- Wonderings? Comments?
Last time we were working on a project that we might use when we start Unit II. I mentioned running the program but did not do anything with that. So we'll do that right quick. So ... start up Visual Studio with your program from last time loaded.
To Run the Program
When you run a Visual Basic program, it will load its start form. Typically that is the first form created in the project. But we have been ignoring that original form (Form1.vb) and creating a different start form. To make things happen correctly we need to change the start form, i.e.,
- click on the Project tab
- select the project Properties … (at the bottom of the menu)
- find the Startup form: selector (about the middle of the window)
- click on the selector and choose the form you want to start
- close the properties tab/window (by clicking on the X next its name)
Once you've done that click on Start icon and see what happens. Hopefully the form you choose shows up. And nothing else should happen since we haven't provided and instructions to be carried out in the form. You'll need to click the red square on the toolbar to get the program to stop.
To make/allow the buttons to work, you'll need to put code like the following in each button click handler that is supposed to open a new form. (Double click on the button and insert the code below, being sure to substitute for "form name" appropriately.)
Dim newWindow As New form name
newWindow.ShowDialog()
To make the exit buttons work you'll need to insert the following code in their click handlers.
Me.Close()
Zip and send the project
To share/submit your project, you will want to have the computer compress the folder into one file. The process for doing that is:
- be sure you get to the project folder (the one that contains everything else)
- right-click on the folder
- select
Send to
- select
Compressed (zipped) folder
You may have a chance specify where you want the file to appear and what you the file to be named. Just be sure you can find it.
- change the name of the file
Gmail will not allow you to attach .zip
files, so you have to fool it by changing the name. I suggest changing .zip
to .zipped
or .zipp
. To do so:
- right click on the file name and select
Rename
- add
ped
or p
to the name
You should now be able to attach the file to your Gmail mail message. But you might have difficult here. You many not be able to see the .zip
extension in which case changing the name does not affect the extension. You will need to fix it by:
- opening up the Control Panel in Windows (click on the Start icon and select Control Panel)
- selecting Appearance and Personalization
- selecting Folder Options
- clicking on the View tab
- clicking on Hide extensions for known file types so it is not checked
Problems/questions/wonderings?
Next Time
- We will finish Unit I (I hope)
- Closing comments/questions?
Day 3 — VB Forms & Controls; Comp.Demo I expectations
Logistics
- Roll
- Today: Finish Demo; Recap for Comp.Demo I
- Comments/Questions?
Our Sample Project (continued)
Last time we had gotten started on our first/sample project. The project demonstrates how to: use Visual Studio, create a new project, specify a Windows form application and name the form, and adjust some of the form properties. We got most of the controls on the form but will still need to do the picture box and related resources and the menu strip that allows the file menu to show up.
And this is a good time to demonstrate compressing files and uncompressing. Any questions before we start?
First, an announcement. Our tech folks seem not to have figured out just how we can save Windows files to flash drives. So, we'll have to muddle through by you zipping it and sending yourself a copy of the file via e-mail or count on me uploading my file to the notes directory on the server and you downloading and unzipping before/as class starts. That'll be our first task today.
- download, unzip, and load my program into Visual studio on your machine
- go to the notes directory (http://www.cs.uni.edu/~east/teaching/vb/current/notes/)
- click on the zipped project from last time (
jpe_sample0114.zip
— watch/determine where it gets stored (I suggest the desktop)
- unzip it
right-click on the file, then select Extract all
(there may be other choices on non-lab machines).
- find the
.sln
file and double-click it to start Visual Studio
open folders starting with the one with the same name as the zipped file until you find the file
- Questions/difficulties/comments/wonderings?
- Pick up where we left off last time
Next Time
- You should have completed the Unit I learning activity We'll address questions/difficulties in class.
- We'll start on Unit II—I provide information that should prepare you for Unit II practice.
- We'll have the Unit I competency demo in class on Tuesday.
- Closing comments/questions?
Day 4 — Unit I Review; Comp.Demo I Expectations
Logistics
- Roll
- Today: Recap for Comp.Demo I; Start Unit II
- Comments/Questions?
I believe we have seen just about everything we need to see. At the end of last class period a couple students notified me of difficulty in changing the name of their zipped file from something.zip
to something.zipped
. If you cannot see the .zip
you cannot change it. Windows typically doesn't show the extension on a file unless it is uncommon. So, you don't see the .xlsx
of Excel files or the .docx
of Word files or the .pdf
of PDF files or the .zip
of compressed files. If you can't see the .zip
on your file you need to change a setting on your computer. To do that:
- Go to the Start menu and select Control Panel. The goal is to change the Folder Options
- Different systems may show different things
- if your system shows Folder Options, click on it.
- if it doesn't, look for Appearance and Personalization (the main topic, not one of the subtopics) and click on it. You should see Folder Options, click on it.
- Click on the View tab
- Find Hide extensions for known file types and make sure it is not checked
- Click the Apply button
- Click the Okay button (you should be done)
Unit I Recap
As a result of this unit you should be prepared to create Visual Basic projects with:
- multiple forms (in the same project)
- a variety of form elements/controls (text boxes, labels, group boxes, radio buttons, check boxes, buttons, picture boxes, and possibly some others
- changing form and element/control properties, in particular:
Name (using standard prefixes), Text, BackColor, ForeColor, Font (font, style, size), ControlBox, ReadOnly, Size (manually or via property values), AutoSize, TextAlign, and probably some others
Note that some of these properties apply to all or nearly all controls while others may apply only to a few
And you should be able to compress/zip projects, change their names, send the compressed folder as an e-mail attachment, and decompress/unzip them. The competency demo will require that you do this.
Next Time
- Work on Unit II
- Competency Demo I.a
-->