cs 2340: programming in vb instructor: dr. qi yang office: 213 ullrich phone: 342-1418 email: yangq...
TRANSCRIPT
![Page 1: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/1.jpg)
CS 2340: Programming in VB
Instructor: Dr. Qi Yang
Office: 213 Ullrich
Phone: 342-1418
Email: YangQ
1
![Page 2: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/2.jpg)
Web Sites
http://www.uwplatt.edu/csse/courses/CS234/
http://www.uwplatt.edu/csse/courses/CS234/
http://www.uwplatt.edu/~yangq
http://www.uwplatt.edu/~yangq/
2
![Page 3: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/3.jpg)
Three VB.NET Courses
• CS 2340: Programming in VB Prerequisite: CS1430• CS 3340: Windows Programming Prerequisite: CS2340 & CS2430 or CS2630• CS 3870: Web Protocols, Technologies and Applications Prerequisite: CS3340 Co-requisite: CS3630 (Database)
3
![Page 4: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/4.jpg)
CS 2340: Course Description
An introduction to event driven, object oriented programming techniques in VB.NET.
Students will design, code, and debug Graphic User Interface (GUI) programs and apply the techniques to business applications.
4
![Page 5: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/5.jpg)
CS 2340: Course Outcomes
Upon completion of this course, students should be able to
• Design and develop Graphical User Interfaces;
• Understand and code Event-Driven procedures;
• Program Visual Basic controls proficiently;
• Access database from VB.NET programs; and
• Design, develop and test Visual Basic programs.
5
![Page 6: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/6.jpg)
CS 2340: Textbook
Beginning VB.NET, 2nd Edition, Wrox
Not .NET 2010
6
![Page 7: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/7.jpg)
CS 2340: Course Work
8 Labs 160 (10 – 30 each)
6 Tests 200 (20 – 40 each)
1 Project 40
Total 400
7
![Page 8: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/8.jpg)
New Grading System
Course Grade Points Percentage Grade Points
A 368 - 400 92% 4.0
A- 356 - 367 89% 3.7
B+ 344 - 355 86% 3.3
B 328 - 343 82% 3.0
B- 316 - 327 79% 2.7
C+ 304 - 315 76% 2.3
C 288 - 303 72% 2.0
C- 276 - 287 69% 1.7
D+ 260 - 275 65% 1.3
D 240 - 259 60% 1.0
F below 240 0.0
No Curve8
![Page 9: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/9.jpg)
Hands-on Tests
In all three VB courses
Paper published in
Journal of Information Systems Education
Volume 16, Number 2, Summer 2005
9
![Page 10: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/10.jpg)
CS 2340: Programming in VB
Different BackgroundsIf you have a very good background
You should get an A
You may not get an A
Else If you have a good background
You do not want to get a D
Else (Don’t have any background in VB)
You can get an A!
Come to class every day and do your work!
10
![Page 11: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/11.jpg)
CS 2340: Programming in VB
Every one could get an A!
That has never happened!
Every one should pass CS 2340!
That has never happened either!
Just Do It!
11
![Page 12: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/12.jpg)
Lab 1
10 points
Due 9 PM, Monday, September 12, 2011
No Grace Time!
12
![Page 13: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/13.jpg)
MS Visual Studio 2010
• Every PC in Ullrich
• Free Copy on your PC
• Will receive email about it
• Follow instructions to get your copy
13
![Page 14: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/14.jpg)
Create a VB.NET Solution
• Start MS Visual Studio 2010
• New Project…
• Visual Basic
• Windows
• Windows Form Application
• Name: YangQ_Lab1
• Create directory for solution: Uncheck
14
![Page 15: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/15.jpg)
Save Project and Solution
Make sure you know is your program!
• Save all
• Create Solution folder: Uncheck
• Browse location
• Could change project / solution names
• Check program location
15
![Page 16: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/16.jpg)
MS Visual Studio IDE(Integrated Development Environment)
• Title Bar• Menu Bar• Tool Bars• Solution Explorer• Properties Window• ToolBox• Auto Hide• Docked, Floating and Tabbed Document Drag to the arrow you want or Right click the title bar of the window
16
![Page 17: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/17.jpg)
MS Visual Studio IDEIDE Settings
Menu Bar / Tools / Options• Show all settings• Environment
– Document• Detect when file is changed outside the environment: Uncheck
• Projects and Solutions– Always show solution: Check– Save new projects when created: Check
• Text Editor– Basic
• Tabs: Tab size : 3 Indent size: Same as Tab size
• Windows Forms Designer• …
17
![Page 18: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/18.jpg)
MS Visual Studio IDE
Help Features
• How Do I
• Dynamic Help
• Contents
• Search
• Index
18
![Page 19: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/19.jpg)
Form Properties
• Form - Window
• Text
• Size
• FormBorderStyle
• StartPosition
• WindowState
• . . .
19
![Page 20: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/20.jpg)
Properties Window
• Properties
• Events
• Alphabetical
• Categorized
20
![Page 21: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/21.jpg)
ToolBox
• Most controls available on ToolBox
• Tabs on ToolBox
All Windows Forms
Common Controls
• Putting a control on form
Double Click
Drag and Drop21
![Page 22: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/22.jpg)
Windows Controls
TextBox
Get Input
Display Output
Label
Display Information / Output
Button
User action
. . .
22
![Page 23: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/23.jpg)
Click Event
• The button’s Click Event
Users click a button when they want to do something.
• Event Procedure
VB function that will be called when the event happens
• We will write the event procedure• Click Event procedure template
Double click the button
23
![Page 24: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/24.jpg)
Declaring Variables
Dim theName As String
theName = txtName.Text
‘ This is comment
‘ To remove spaces from both ends
theName = txtName.Text.Trim()
We should get variable values from controls at the beginning, then use the variables, not the controls, in the code.
24
![Page 25: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/25.jpg)
Class MessageBox
• Method Show
MessageBox.Show(“Please Enter Your Name”)
• Caption (Title), MessageBoxButtons and MessageBoxIcon
MessageBox.Show("Enter Your Name Please!", _
"Lab 1", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
• Line continuation char: “ _”
VB has NO statement terminator
25
![Page 26: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/26.jpg)
String Operations
‘ Operators “&” and “+” append strings
MessageBox.Show("Hello, " & theName + "!”)
MessageBox.Show("Hello, " & theName + "!", "Lab 1”, _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)
26
![Page 27: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/27.jpg)
If Statement
If theName = "" Then
MessageBox.Show("Enter Your Name Please!", "Lab 1", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Hello, " & theName + "!", "Lab 1", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information)End If
27
![Page 28: CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ 1](https://reader035.vdocuments.site/reader035/viewer/2022062407/56649e015503460f94aebeac/html5/thumbnails/28.jpg)
The Click Event Procedure
Private Sub btnHello_Click(...) Handles btnHello.Click
Dim theName As String
theName = txtName.Text.Trim()
If theName = "" Then
MessageBox.Show("Enter Your Name Please!", "Lab 1", _
MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
Else
MessageBox.Show("Hello, " & theName + "!", "Lab 1", _
MessageBoxButtons.OK, _
MessageBoxIcon.Information) End IfEnd Sub
28