Unit I — Course Intro; Visual Studio Intro

CS 1130 Visual Basic—Spring 2017

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

Roll, Partnering & Seating Chart

Instructor & Course Introduction

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.)

Programming & PcPI

This course hopes to teach (that you learn) programming (in Visual Basic). So, ...

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:

PcPI

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 I) 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, ...

Wonderings? Comments?

Next Time/To Do:

Any final questions? comments? wonderings?   . . .   See you Thursday.

Day 2 — Introducing Visual Studio & Visual Basic

Logistics

Laptop Use in ITTC 328

If you have your own computer you can ignore this. If you need to use our laptops, please note the following.

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 and is stored as a folder containing a number of files and other folders. Each project has a number of forms or windows, one of which is a start form called Form1. Forms have properties most 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 shown below. It assume you are using the lab computers but should apply in most any situation.

Note: You will need to be familiar with your Google Drive or bring a flash drive to save your work.

We want to produce a project with forms similar to the images below. This project show a wide variety of the controls or form elements you might use.

Start form for VB project with buttons to connect to other forms. VB form showing various controls

The steps for creating the project are provided below. You should be able to refer back to these notes when doing your own work.

Start a New Visual Basic Project

You'll need to start up Visual Studio and make sure it is set for you in Visual Basic. Then start a new project, give it a name, and save it all. Details below.

Questions? Comments? Wonderings?

At this point, Visual Studio should open and a form window (titled "Form1") should appear. There may be some other elements showing. The ones we are interested in are:  ToolboxSolution Explorer,  & Prioperties. If they do not seem available you should find them by looking in the View tab. Make sure they are all available. You might experiment with "pinning" them to the window, unpinning them, closing them entirely, and reopening them using the View tab.

Create the "start" Form

The next step is to create our start form. We could rename "Form1", but that sometimes creates problems so I suggest we just ignore Form1. Close it up and create what we want.

Questions? Comments? Wonderings?

Adjust the Start Form Properties

Change appropriate/desired form property values using the Properties window.

Questions? Comments? Wonderings?

Save All the Project

As with other things on the computer, you need to save your work occasionally. In Visual Studio saving means using Save All. Be sure to use Save All when saving your work. The first time you Save All, you will want to note where the file is being saved and perhaps change that location. I suggest you browse the computer and Save All the project to either your flash drive or to the "Desktop".

Add the Two Buttons

Our picture shows two buttons on the form that we need to add. We use the Toolbox to accomplish adding controls to the form.

Questions? Comments? Wonderings?

Add the Sample Form

Should be very similar to the above, just use different values for the Text and (Name) properties. A brief process is:

Questions? Comments? Wonderings?

Add the Form's Elements/Controls

Title label

The form has a Text property that might be thought of as a title but you might want have another title in the body of the form.

Questions? Comments? Wonderings?

Text box & label pairs

Text boxes can be used for input from the user or to display results the program might produce. Typically, the programmer has a label for each text box to indicate the desired input or the value displayed.

Questions? Comments? Wonderings?

(Got to about here on Day 2)

Set of Radio Buttons

Radio buttons allow us to choose one item/value/choice for a set of possibilities. If you choose (click on) one it shows to be selected. If you choose (click on) a different on, the first one become unselected and the second shows to be selected. Note that VB groups all radio buttons together to allow only one to be selected, unless they are grouped by the programmer. Thus, we will place our radio buttons in a group box so they won't interfere with any other radio buttons that might get added later.

Questions? Comments? Wonderings?

Set of Check Boxes

Check boxes allow us to indicate one or more items/values/choices for a set of possibilities. If you choose (click on) one it shows to be selected. If you choose (click on) a different on, both show to be selected. Clicking on a selected one, changes it to unselected. We typically place our associated check boxes in a group box. It can help the user know what the check boxes refer to.

Questions? Comments? Wonderings?

List box

The big white thing in the middle is a list box. It is used when you need to have a list that you can put things in but be able to select them individually. The process for it is similar to all the others.

Questions? Comments? Wonderings?

Picture box

A picture box allows VB to show images easily. The images can be changed using code relatively simply. The picture boxes can be of most any size and the images can be scaled to fit inside the box. Placing one in your form is like everything else.

Now we need to get the pictures for the cards. I have some prepared. We will need to download the zipped set of images, unzip them, and import them as resources for our program. Details are given below.

Now to load the pictures into our resources.

Next, we will want to put one of the card images into the picture box. We do so by setting a value to/for its Image property.

Questions? Comments? Wonderings?

Menu strip

I think the only thing left is the menu strip. The Control for the menu strip doesn't actually show up on the form, it appears in an area below the form. The process is similar to others.

Questions? Comments? Wonderings?

Run the Program

Now let's see what happens when we attempt to run the program we created.

Zip and send the project

When you want me to run your program (e.g., when you submit a project) you will need to send it to me via e-mail. To do that, you will have to compress the folder into one file and change its name so Gmail will be willing to let you attach it to a message. The process for doing that is:

Day 3 — Visual Studio Intro (cont.) & First Assignment

Logistics

Continue/Finish Day 2 Activity

If you have a Windows machine and have not gotten Visual Studio installed, please follow use one of our lapstops to follow along today. We will start by downloading and unzipping a project folder containing what I had gotten done last time. The process for using our laptops is:

Downloading and unzipping the project

Questions? Comments? Wonderings?

Continue/Finish preparing the form

Next Time

Any final questions? comments? wonderings?   . . .   See you Thursday.