instructor: adil ibrahim office: 212 ullrich phone: 342-1401 email: ibrahima 1

25
Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1 CS 2340 Programming in VB.NET

Upload: dina-price

Post on 24-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Instructor: Adil Ibrahim

Office: 212 UllrichPhone: 342-1401Email: ibrahima

1

CS 2340Programming in VB.NET

Page 3: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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.

3

CS 2340: Course Description

Page 4: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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.

4

CS 2340: Course Outcomes

Page 5: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Starting Out With VB.NET, 3rd Edition, Tony Gaddis – Kip Irvine

Addison Wesley

5

CS 2340: Textbook

Page 6: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

8 Labs 160 (10 – 30 each)

6 Tests 200 (20 – 40 each)

1 Project 40

Total 400

6

CS 2340: Course Work

Page 7: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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 Curve

7

Course Grading

Page 8: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Different BackgroundsIf you have a very good background You should get an A You may not get an AElse If you have a good background You do not want to get a DElse (Don’t have any background in VB) You can get an A!

Come to class every day and do your work!

8

CS 2340Programming in VB.NET

Page 9: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Every one could get an A!That has never happened!

Every one should pass CS 2340!That has never happened either!

Our Slogan:Just Do It!

9

CS 2340Programming in VB.NET

Page 10: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

10 pointsDue 9 PM, Friday, September 20, 2013

No Grace Time!

10

Lab 1

Page 11: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Every PC in Ullrich Free Copy on your PC Will receive email about it Follow instructions to get your copy

11

MS Visual Studio 2012

Page 12: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Start MS Visual Studio 2012 New Project… Visual Basic Windows Windows Form Application Name: IbrahimA_Lab1 Create directory for solution: Uncheck

12

Create a VB.NET Solution

Page 13: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Make sure you know where is your program!

Save all Create Solution folder: Uncheck Browse location Could change project / solution names Check program location

13

Save Project and Solution

Page 14: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Title Bar Menu Bar Tool Bars Solution Explorer Properties Window ToolBox Auto Hide . . .

14

MS Visual Studio IDE(Integrated Development Environment)

Page 15: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Form - Window Text Size FormBorderStyle StartPosition WindowState . . .

15

Form Properties

Page 16: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Properties Events Alphabetical Categorized

16

Properties Window

Page 17: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Most controls available on ToolBox Tabs on ToolBox All Windows Forms Common Controls

Putting a control on form Double Click Drag and Drop

17

ToolBox

Page 18: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

TextBox Get Input Display Output

Label Display Information / Output

Button User action. . .

18

Windows Controls

Page 19: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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

19

Click Event

Page 20: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

Dim theName As String

theName = txtName.Text

‘ This is comment‘ To remove spaces from both endstheName = txtName.Text.Trim()

We should get variable values from controls at the beginning, then use the variables, not the

controls, in the code.

20

Declaring Variables

Page 21: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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

21

Class MessageBox

Page 22: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

‘ Operators “&” and “+” append stringsMessageBox.Show("Hello, " & theName + "!”)

MessageBox.Show("Hello, " & theName + "!", "Lab 1”, _ MessageBoxButtons.OK, _ MessageBoxIcon.Information)

22

String Operations

Page 23: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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

23

Page 24: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

The Click Event Procedure Pseudo Code

Private Sub btnHello_Click(...) Handles btnHello.Click

‘ Declare variable(s)

‘ Get input

‘ If empty input

‘ Display a message

‘ Else

‘ Display a different message

End Sub

24

Page 25: Instructor: Adil Ibrahim Office: 212 Ullrich Phone: 342-1401 Email: ibrahima 1

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

25