320 likes | 333 Views
Learn event-driven programming in VB.NET, create GUI programs, access databases, and develop business apps in this course. Textbook: Beginning VB.NET. Take labs, tests, and a project to earn grades. Follow the new grading system.
E N D
CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: 342-1418 Email: YangQ
Web Sites http://people.uwplatt.edu/~yangq/cs234/ http://people.uwplatt.edu/~yangq/cs234/ http://people.uwplatt.edu/~yangq/ http://people.uwplatt.edu/~yangq/
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)
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.
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 VB.NET programs.
CS 2340: Textbook Beginning VB.NET, 2nd Edition, Wrox Not .NET 2015
Academic Misconduct https://www.uwplatt.edu/dean-students/student-conduct
CS 2340: Course Work 8 Labs 160 (10 – 30 each) 6 Tests 200 (20 – 40 each) 1 Project 40 Total 400
New Grading System Course Grade Points Percentage Grade Points A 368 - 400 92% 4.0 A- 356 - 367 89% 3.7 B+ 348 - 355 87% 3.3 B 328 - 347 82% 3.0 B- 316 - 327 79% 2.7 C+ 308 - 315 77% 2.3 C 288 - 307 72% 2.0 C- 276 - 287 69% 1.7 D+ 268 - 275 67% 1.3 D 240 - 267 60% 1.0 F below 240 0.0 No Curve
Hands-on Tests In all three VB courses Paper published in Journal of Information Systems Education Volume 16, Number 2, Summer 2005
CS 2340: Programming in VB Different Backgrounds If 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!
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!
Lab 1 10 points Due 9 PM, Monday, September 12, 2011 No Grace Time!
MS Visual Studio • Every PC in Ullrich • Free Copy on your PC • Will receive email about it • Follow instructions to get your copy • Start VS 2015 • Sign in: up to you (not now, maybe later) • Development Settings: Visual Basic
Create a VB.NET Solution • Start MS Visual Studio (Environment: Basic) • New Project… • Visual Basic • Windows • Windows Form Application • Name: UserName_Lab1 YangQ_Lab1 • Create directory for solution: Uncheck • Location: Remember where is your program!
Save Project and Solution Make sure you know where is your program! • Save all • Create Solution folder: Uncheck • Browse location • Check program location
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 Right click the title bar of the window or Drag the window to the position you want
MS Visual Studio IDE IDE Settings Menu Bar / Tools / Options • 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 • …
MS Visual Studio IDE • View Help • Visual Studio 2015 • Search • Google
Properties Window • Right click the form • Properties • Events • Alphabetical • Categorized
Form Properties • Name: frmLab1 • Text • Size • FormBorderStyle • StartPosition • WindowState • . . .
ToolBox • Most controls available on ToolBox • Tabs on ToolBox All Windows Forms Common Controls • Putting a control on form Double Click Drag and Drop
Windows Controls Label Display Information / Output lblName Button User action btnHello . . . Form frmLab1 TextBox Get Input Display Output txtName
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
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.
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
VB.NET is Getting Smarter! MessageBox.Show("Enter Your Name Please!", "Lab 1", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
String Operations ‘ Operators “&” and “+” append strings MessageBox.Show("Hello, " & theName + "!”) MessageBox.Show("Hello, " & theName + "!","Lab 1”, MessageBoxButtons.OK, MessageBoxIcon.Information)
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
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 If End Sub
Grader • Down load the grader program with the input file • Put both files in the same folder as your exe file (normally bin/debug) • Select your exe file and the downloaded input file • Run the grader program and click Single EXE File
Grader • All controls, including the forms, MUST have the correct names • Otherwise, your receive ZERO points!