visual basic

27
Visual Basic Week 1

Upload: sumana

Post on 14-Jan-2016

57 views

Category:

Documents


1 download

DESCRIPTION

Visual Basic. Week 1. What is Visual Basic?. Visual Basic is an easy to learn programming language Can develop Windows based applications Visual Basic is an easy yet powerful programming language. Advantages of VB. Simple Popular = lots of resources - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Visual Basic

Visual Basic

Week 1

Page 2: Visual Basic

What is Visual Basic?

• Visual Basic is an easy to learn programming language

• Can develop Windows based applications

• Visual Basic is an easy yet powerful programming language

Page 3: Visual Basic

Advantages of VB

• Simple

• Popular = lots of resources

• Many tools available on the Internet to save you some programming time

Page 4: Visual Basic

Disadvantages of VB

• Not suitable for programming sophisticated games

• Slower than other languages

Page 5: Visual Basic

Getting Started

Page 6: Visual Basic

Start New Project

Page 7: Visual Basic

Name Project

Page 8: Visual Basic

Development Environment

Page 9: Visual Basic

Getting Started (continued)

• Look at the form with the title bar Form1

• Everything you place on this form will appear in your program

• To run your program click on the Play button on the toolbar

Page 10: Visual Basic

Getting Started (continued)

• To stop the program click the form’s X button or select the Stop button on the tool bar

Page 11: Visual Basic

Properties

• Every component/object of your program has properties that determine its look and function– For Example: Font, Fore Color, Icon, Text

• To see the properties window, select View -> Properties Window from the menu bar

Page 12: Visual Basic

Properties (continued)

Page 13: Visual Basic

Properties (continued)

Page 14: Visual Basic

Changing Properties

• Change the form’s Text property

Page 15: Visual Basic

Adding Controls

• There are many control that can be added to your program– For example: buttons, text boxes, scroll bars

and more

• The controls are listed in the toolbox

Page 16: Visual Basic

ToolBox

Page 17: Visual Basic

Adding Controls

• Double Click

• Drag and Drop

• Click and Locate

Page 18: Visual Basic
Page 19: Visual Basic

Changing Properties

• Right-click on the control

• Select the control from the properties window control box

Page 20: Visual Basic

Events

• VB is an Event Driven language

• Events are actions that are taken in the program– For example: keypress, mouseover, click and

many more

• Events are coded in the Code window

Page 21: Visual Basic

Code Window

Page 22: Visual Basic

Form_Load Event

• The form load event should look like this:Private Sub Form1_Load(ByVal sender As

System.Object, ByVal e As System.EventArgs) Handles MyBase.Load (The beginning of the Form_Load event)This is the code that belongs to the Form_Load eventEnd Sub (The end of the Form_Load event)

Page 23: Visual Basic

Add a Message Box

• Adding a message box to the form load event

• Add MsgBox(“Hello”)

• Between the Private Sub and the End Sub statements

• Run Program

Page 24: Visual Basic

More Events

• Click the Drop-Down List that appears in the upper left corner of the code window to choose the object

Page 25: Visual Basic

More Events

• Click the Drop-Down List that appears in the upper right corner of the code window to see the events

Page 26: Visual Basic

FormClosing Event

• The FormClosing event occurs when the form is being unloaded when you click the form’s X button

• Type MsgBox("Good Bye") between the Private Sub and the End Sub statements

• Run the program

• Close the program

Page 27: Visual Basic

Command Button’s Events

• Double-click or right-click and select View Code to open the code window for the command button

• Type MsgBox("You have Clicked on the button!" ) between the Private Sub and the End Sub statements

• Run the program and click on the command button