intermediate visual basic cisp 371 crc prof. chapman

26
Intermediate Visual Basic CISP 371 CRC Prof. Chapman

Upload: lesley-marsh

Post on 16-Dec-2015

236 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

Intermediate Visual Basic

CISP 371CRCProf. Chapman

Page 2: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

VB Capabilities

Most people think that Visual Basic is only useful if you want to build a GUI program that runs on a desktop PC.

But VB is much more powerful than that.

Page 3: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

VB Capabilities

VB can be used to work with databases and to build web sites.

Who needs Java or Javascript or PHP? Who needs SQL or Oracle or MySQL? Not a master VB programmer.

Page 4: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

VB Capabilities

VB can handle

Windows desktop GUI applications Windows web applications Database connectivity Extension of the language

OOP Application security

Page 5: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Windows Desktop GUI Apps

This was covered in the prerequisite course CISP 370.

More to come about what I expect you all to know in this area.

Page 6: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Language Extension

The rest of what VB can do can is defined within the huge class library called the .NET Framework.

As the first part of this course we’ll work with this library.

Page 7: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

OOP

You will learn how to effectively use the .NET Framework. You will also extend the .NET Framework into customized classes using the OOP concepts of inheritance, polymorphism, and encapsulation.

These concepts are vital when programming VB web apps and database connectivity.

Page 8: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

OOP

You will be able to create advanced memory storage for your program’s data.

You’ll learn to communicate between modules with events and exceptions, to organize data and procedures into classes, to create expandable array-like objects called collections, and to save organized data to a file using serialization.

Page 9: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Database Connectivity

The subset of the .NET Framework that deals with connecting an app to a database is called ADO.NET.

These classes let you use a database as a permanent storage area for your application’s data.

Page 10: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Database Connectivity

You can use VB to copy databases into memory, search the data with VB, edit the data, and save the data back to the database.

Working with an existing database with VB does not require SQL.

Page 11: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Windows Web Applications

The subset of the .NET Framework that deals with connecting an app to a database is called ASP.NET.

These classes let you create an event-driven web page that contains controls.

Page 12: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Windows Web Applications

You can use VB to build web sites using the same techniques as building desktop applications.

Page 13: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

What You Already Know

This is contained on Blackboard in the document “CISP 370 topics”.

If you don’t feel comfortable with any of these topics, plan to meet with me ASAP during office hours for a quick tutorial.

Page 14: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

What You Already Know

Let’s look at two examples

TextBox input data validation

Complicated multiple-window WinApp to play craps

Page 15: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Simple CISP 370 WinApp

This WinApp accepts input in the TextBox and then validates the input as a positive integer. If input is invalid, then a MessageBox dialog informs the user.

Page 16: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

Simple CISP 370 WinApp

Read the code behind MainForm to see the

btnProcess_Click() event handler definition

the validation technique using Val() and an If statement

Page 17: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

In the past, the last homework in my CISP 370 asked for a WinApp with three windows that played the game of craps.

The user could place bets and enable a log file to keep track of their bets.

The application would determine whether a bet had won or lost and update the user’s bankroll.

Page 18: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

“GUI sketches” are a method to design the application before writing a single line of VB.NET code.

In these sketches the developer communicates their vision for the abilities of each window.

Page 19: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

sketch of window

control names

what usercan do inwindow

Page 20: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

After the windows have been sketched out, then the developer writes the code behind each window.

Page 21: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

The main window is always on the screen and is where the user rolled the dice and managed the game. The user can navigate to the other windows and exit the app here.

Page 22: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

The bets window allows the user to place a bet prior to their next roll. The allowable bets depend on the current state of the game (has the point been set?), the table minimum bet, and the total amount of money the user has.

Page 23: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

More Complicated WinApp

The show-all-bets window displays the currently placed bets and their amount.

Page 24: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

What You Don’t Yet Know

How to use .NET Framework classes directly (instead of having Visual Studio automatically generate the necessary code).

How to build customized classes that are based upon the .NET Framework.

How to group code together into a coherent class that other programmers would find useful.

Page 25: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

What You Don’t Yet Know

How to connect your app to a database using the ADO.NET library.

How to build active web pages using .NET techniques and the ASP.NET library.

Page 26: Intermediate Visual Basic CISP 371 CRC Prof. Chapman

CISP 371 Chapman

My Goal

Students who finish this course have enough knowledge about using and expanding the .NET Framework library to do whatever they like with Visual Basic.

VB – it’s not just for desktop applications any more!