visual basic intoduction
DESCRIPTION
programming course by engsaadTRANSCRIPT
![Page 2: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/2.jpg)
Visual Basic 2010Introduction
![Page 3: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/3.jpg)
Agenda
Development cycle.
Programming languages.
Object Oriented Programming.
Programming concepts.
Software.
Integrated Development Software.
Install VB 2010 Express.
VB 2010 Introduction.
![Page 4: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/4.jpg)
System Development Cycle
Analyses
Design
Programming
Testing
![Page 5: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/5.jpg)
Programming languages
![Page 6: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/6.jpg)
Compiled languagesFast
Run time
![Page 7: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/7.jpg)
Interpreted LanguagesSlow
Run time
![Page 8: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/8.jpg)
Object Oriented Programming
Encapsulation.
Inheritance.
Polymorphism.
![Page 9: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/9.jpg)
Encapsulation
It is the exposure of properties and methods of an
object while hiding the actual implementation of it.
In other words, the object is treated as a black
box developers who use the object should have
no need to understand how it actually works.
![Page 10: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/10.jpg)
Inheritance
less programming is required when adding functions to
complex systems. This don by inherit all or some of
the structure and/or methods in one class to another.
![Page 11: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/11.jpg)
Polymorphism
Example, a screen cursor may change its shape from
an arrow to a line depending on the program mode.
![Page 12: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/12.jpg)
![Page 13: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/13.jpg)
Classes & objects
Consider the classes at a school; children of a
particular age may be grouped together and put in
one class. They will all learn the same set of things
and will all be tested in the same way. That doesn’t
mean everyone in a class is the same – it just means
there are certain things they have in common.
Aly is one of the class students, so Aly is an object
inside the class. Aly have a variety of properties.
![Page 14: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/14.jpg)
IntegratedFormed or united into a whole.تكامل
![Page 15: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/15.jpg)
A process in which something passes by degrees to a different stage.
Darwin
Development
![Page 16: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/16.jpg)
Environment
![Page 17: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/17.jpg)
Integrated Development Environment
IDE
![Page 18: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/18.jpg)
Events & Actions
Events are things that happen to an object.
Actions are things that an object does.
![Page 19: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/19.jpg)
Written programs or procedures or rules and associated documentation stored in memory.
Beta Software.
Alpha Software.
Software Package.
Systems Software.
Computer Software.
Documentation.
Software
![Page 20: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/20.jpg)
A small temporary window in a graphical user interface, which request information from the user; after the information has been provided the user
dismisses the box with `ok' or `cancel‘.
Dialog Box
![Page 21: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/21.jpg)
Toolbox
![Page 22: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/22.jpg)
ToolboxCommon Controls
![Page 23: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/23.jpg)
www.Google.com
![Page 24: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/24.jpg)
www.Google.com
![Page 25: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/25.jpg)
Combination Box
![Page 26: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/26.jpg)
CheckBox
![Page 27: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/27.jpg)
RadioButton
![Page 28: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/28.jpg)
ListBox
![Page 29: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/29.jpg)
Learn By Doing
![Page 30: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/30.jpg)
Install VB 2010 ExpressStep BY Step
![Page 31: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/31.jpg)
![Page 32: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/32.jpg)
![Page 33: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/33.jpg)
![Page 34: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/34.jpg)
![Page 35: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/35.jpg)
![Page 36: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/36.jpg)
![Page 37: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/37.jpg)
![Page 38: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/38.jpg)
![Page 39: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/39.jpg)
![Page 40: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/40.jpg)
![Page 41: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/41.jpg)
![Page 42: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/42.jpg)
![Page 43: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/43.jpg)
![Page 44: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/44.jpg)
Add one button and one label
![Page 45: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/45.jpg)
Select label1 and press control and hold it then click (select) button1
![Page 46: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/46.jpg)
Now you can change Font property for both
![Page 47: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/47.jpg)
![Page 48: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/48.jpg)
Adjust AutoSize property to true then double click on Button1
![Page 49: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/49.jpg)
Type yellow phrase between Private Sub and End Sub
![Page 50: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/50.jpg)
Press F5 you should have this form
![Page 51: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/51.jpg)
Rename button1
![Page 52: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/52.jpg)
Label1.text = nothing “ ”
![Page 53: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/53.jpg)
Let both buttons have the same size
![Page 54: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/54.jpg)
Fix button2 just like button1
![Page 55: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/55.jpg)
Double click on Button2
![Page 56: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/56.jpg)
![Page 57: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/57.jpg)
Menu BarSave Your Work
![Page 58: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/58.jpg)
Menu BarSave Your Work
![Page 59: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/59.jpg)
Form_Load
• Open new VB project
• Double click on any part of the form.Form_Load
Object = Form
Event = Load
Lets type something between private sub and end sub.
Me.height = 1000
Me.width = 100
Me.opacity = 0.9
![Page 60: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/60.jpg)
Subroutine
Open new VB project.
Insert button from toolbox.
Double click this button.
And type between private sub and end sub:
– Dim prog as string ‘Declaration
– Prog = “hello world” ‘Assign value for declared
variable
– Msgbox (prog) ‘statement
![Page 61: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/61.jpg)
VB 2010 Data Types
• Numeric data:-– Price , weight ,age …etc
• Non-numeric data.
![Page 62: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/62.jpg)
Numerical Data Ranges
Type Storage Range of Values
Byte 1 byte 0 to 255
Integer 2 bytes -32,768 to 32,767
Long 4 bytes -2,147,483,648 to 2,147,483,648
Single 4 bytes +/-3.402823E+38 to -1.401298E-45
Double 8 bytes +/-1.79769313486232e+308 to -4.94065645841247E-324
Currency 8 bytes -922,337,203,685,477.5808 to 922,337,203,685,477.5807
Decimal 12 bytes+/- 79,228,162,514,264,337,593,543,950,335 if no decimal is use +/- 7.9228162514264337593543950335 (28 decimal places).
![Page 63: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/63.jpg)
Arithmetic Operations
Numerical Data
X= 13.5 Mod 12 then X = 1.5
Operator Mathematical Function
+ Addition
- Subtraction
^ Exponential
* Multiplication
/ Division
Mod Modulus (return the remainder from an integer division)
\ Integer Division (discards the decimal places)
![Page 64: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/64.jpg)
Nonnumeric Data
Data Type Storage Range
String (fixed length) Length of string 1 to 65,400 characters
String (variable length) Length + 10 bytes0 to 2 billion characters
Date 8 bytesJanuary 1, 100 to December 31, 9999
Boolean 2 bytes True or False
Object 4 bytes Any embedded object
Variant numeric 16 bytesAny value as large as Double
Variant text Length+22 bytesSame as variable-length string
![Page 65: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/65.jpg)
• Strings can be manipulated using the ‘&’ sign and the ‘+' sign.
• In Ex 1,2,3 type this code in the button sub.
– Ex 1:-• Dim txt1, txt2, txt3 As String
• txt1 = “hello"
• txt2 = “world"
• txt3 = text1 + text2
• Label1.Text = text3 ‘Output = helloworld
Nonnumeric DataString Manipulation
![Page 66: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/66.jpg)
• Ex 2:-
– Dim txt1, txt3 As String
– Dim Txt2 As Integer
– txt1 = "VB"
– txt2 = 2010
– txt3 = txt1 & txt2
– Label1.Text = text3 ‘Output = VB2010
Nonnumeric DataString Manipulation
![Page 67: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/67.jpg)
• Ex 3:-
– Dim txt1, txt2, txt3, txt4, txt5, txt6 As String
– txt1 = " Visual_"
– txt2 = "Basic_“
– txt3 = "2010“
– txt6 = txt1 + txt2 + txt3
– Label1.Txt = txt6 ‘Output = Visual_Basic_2010
Nonnumeric DataString Manipulation
![Page 68: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/68.jpg)
Variable Names
• The following are the rules when naming the variables in
Visual Basic 2010:-
1. It must be less than 255 characters.
2. No spacing is allowed .
3. It must not begin with a number.
4. Period is not permitted.
• Ex:• Student_name
• X1
• ComputerName
![Page 69: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/69.jpg)
Declaring Variables
1. Assign name.
2. Assign data type.
• Dim variable name As Data Type
• Dim variable name, variable name As Data Type
3. Defines the number of characters the string can
hold.
• Dim variable name As String * n
• where n defines the number of characters the string can hold.
• Ex: Dim name As String * 10
![Page 70: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/70.jpg)
Constants
• Constants values do not change during the
running of the program.
– Declaring a Constant :-
• Const constant name As Data Type = Value
– Ex: Const Pi As Single = 3.14
![Page 71: Visual basic intoduction](https://reader033.vdocument.in/reader033/viewer/2022061112/54577112af7959234b8b579f/html5/thumbnails/71.jpg)
Issue
• We need to calculate area & circumference for:-
• Circle..
• Square..
• Rectangle..
Writing mathematical equations for computer