visual basic
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 PresentationTRANSCRIPT
![Page 1: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/1.jpg)
Visual Basic
Week 1
![Page 2: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/2.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/3.jpg)
Advantages of VB
• Simple
• Popular = lots of resources
• Many tools available on the Internet to save you some programming time
![Page 4: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/4.jpg)
Disadvantages of VB
• Not suitable for programming sophisticated games
• Slower than other languages
![Page 5: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/5.jpg)
Getting Started
![Page 6: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/6.jpg)
Start New Project
![Page 7: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/7.jpg)
Name Project
![Page 8: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/8.jpg)
Development Environment
![Page 9: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/10.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/11.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/12.jpg)
Properties (continued)
![Page 13: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/13.jpg)
Properties (continued)
![Page 14: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/14.jpg)
Changing Properties
• Change the form’s Text property
![Page 15: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/15.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/16.jpg)
ToolBox
![Page 17: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/17.jpg)
Adding Controls
• Double Click
• Drag and Drop
• Click and Locate
![Page 18: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/18.jpg)
![Page 19: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/19.jpg)
Changing Properties
• Right-click on the control
• Select the control from the properties window control box
![Page 20: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/20.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/21.jpg)
Code Window
![Page 22: Visual Basic](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/22.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/23.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/24.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/25.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/26.jpg)
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](https://reader036.vdocuments.site/reader036/viewer/2022062322/56814751550346895db49295/html5/thumbnails/27.jpg)
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