Professional Documents
Culture Documents
VB2010 Toturial
VB2010 Toturial
VB2010 Toturial
com
3122
.2:
.........................
................................
7
................................................................................................
.3
................................
...
9 ................................................................................................
.3 Hello world
...............................
22................................................................................................
.5
.........................
................................
26
................................................................................................
.2 Properties
................................
28.. ................................................................................................
.3 ( )
................................
33. ................................................................
.4 ( )
.5
.6
................................
............
36
................................
......................
................................
43
................................................................
.........................
................................
4:
................................................................................................
.2 Events
................................
......
52
................................................................................................
.3
................................
...........
54
................................................................................................
.4
..........................
................................
59
................................................................
.5
.........................
................................
62
................................................................................................
.2 Variables
.3
.....................
................................
64
................................................................
................................
67
.... ................................................................................................
.4
.4
......................
................................
6:
................................................................
...........................
................................
75
................................................................
.6
.........................
................................
76
................................................................................................
.2
..........................
................................
78
................................................................................................
.2.2 IfThen :
............................
79
................................................................................................
.......................
................................
83
................................................................
.4 Arrays
.......................
................................
84
................................................................
.2.5 for/each :
.3.5 for/next :
.6
................................
...............
88
................................................................
.........................
................................
89
................................................................
................................
..............
91
................................................................
.7
.........................
................................
94
................................................................................................
.2
.2
.4
.5
.6
.7
................................
...........
96
................................................................................................
................................
..............
97
................................................................................................
................................
........
:1
................................................................................................
................................
.....
:2 ................................................................................................
................................
..........
:3
................................................................................................
................................
:5
.... ................................................................................................
.........................
................................
:8
................................................................................................
Microsoft
VB Express
2010
algoharism.blogspot.com
.Hello World
algoharism.blogspot.com
:.1
1. Start menu >> Programs >> Microsoft Visual Studio 2010 Express >> Microsoft Visual Basic
2010 Express
2. New Project
3. Windows Forms Application
4.
3
1
algoharism.blogspot.com
algoharism.blogspot.com
.2
.
.
Solution Explorer
- 2
Solution Explorer - 3
algoharism.blogspot.com
- 4 Properties
( ...)
- 5
algoharism.blogspot.com
Toolbox
- 6 ( \ )
10
algoharism.blogspot.com
.3 Hello world
Visual Basic
.
- 2 () . Toolbox
- 3 Common Controls
- 4 .
Button
Button
Double click
.Button
11
algoharism.blogspot.com
- 5 Double Click
- 6
)"! Hello World "(MessageBox.Show
12
algoharism.blogspot.com
- 7 Debug
Debug
.
F5 .Debug
- 8 Button 1 .
- 9 X
13
algoharism.blogspot.com
- 21
.Save
14
algoharism.blogspot.com
.4
3 Buttons (
) ( ) .
.
Hello World .
15
Microsoft
VB Express
2010
algoharism.blogspot.com
algoharism.blogspot.com
.1 Properties
.
Button
.
17
algoharism.blogspot.com
- 1 :Location
()
X : X( Y
Y )(
.
18
algoharism.blogspot.com
X= 81
Y= 94
- 2 :Text
.
19
algoharism.blogspot.com
- 3 :Backcolor
- 4 :Forecolor
- 5 :Font
20
algoharism.blogspot.com
- 6 ):(Name
.
BtnOk
OK
.
21
algoharism.blogspot.com
.2 ( )
.
Button
()
label
TextBox
22
Radio button
List Box
Combo Box
algoharism.blogspot.com
ListBox Textbox
: " ":
.2 :
Text box
Labels
Combo Box
List box
Radio Box
Check Box
Button
.3 .Combo box
Combo box
Edit items
23
algoharism.blogspot.com
( ):
List Box
24
algoharism.blogspot.com
.3 (
)
menu ToolBox
.
25
algoharism.blogspot.com
Ctrl+S
:
Menu strip
Status Strip
Tool Strip
: " " :Menu strip
- 2 Menu Strip
- 3 Type Here
- 4 4 :
26
algoharism.blogspot.com
- 5 MenuStrip1
27
algoharism.blogspot.com
28
algoharism.blogspot.com
- 3
- 4 :
- 5 ()
:
29
algoharism.blogspot.com
- 3 Status Strip .
30
algoharism.blogspot.com
Edit Items .
31
algoharism.blogspot.com
.4
( ).
:
- 2 " ":
Text Boxes
Labels
Buttons
Labels
Buttons
( . ).
.
32
algoharism.blogspot.com
- 3 (
button "" " ")
.
- 4
( button
).
:
:Tab key- 2
Tab Text Boxes
.
Tab :
- 2 Debug
F5 .
- 3 :
( )
33
algoharism.blogspot.com
- 4 Tab ( | )
:
34
algoharism.blogspot.com
35
algoharism.blogspot.com
- 7 .
:LayoutToolbar- 3
.
layout view toolbars layout
36
algoharism.blogspot.com
Layout Toolbar :
Aligns left - 2
- :
Ctrl
.
37
algoharism.blogspot.com
Aligns right - 3
Aligns top - 4
: .
: .
38
algoharism.blogspot.com
.5
( credit card )
(.)Tab order
39
Microsoft
VB Express
2010
algoharism.blogspot.com
Events Events
algoharism.blogspot.com
.1 Events
( )
Visual Basic Express " " Event Driven
.Programs
Event
.
: " "Hello World :
- 3 :
- Events
41
algoharism.blogspot.com
:Button 1 Button 1
: Click ( )
Public Class
End Class
Method
: Method Public
class End Class
Code Block
Button1_Click
( Click )Event Button 1 Show
MessageBox ( Hello World Response ) Click
F7 Shift+F7
( ) .
- :
- Events
42
algoharism.blogspot.com
.2
.
properties
Events
Events Properties
.
- Events
43
algoharism.blogspot.com
- Event
Events
Double Click
- Events
44
algoharism.blogspot.com
Lesson03
- 3 :
Button
1
TextBox 1
- Events
45
- 4 :
algoharism.blogspot.com
Click
Button1
text
TextBox1
" !"
- Events
46
algoharism.blogspot.com
- :
" "
()
. Event
- Events
47
algoharism.blogspot.com
.3
.
- 2 :
( )
.
" " :
.
:
- Events
48
algoharism.blogspot.com
( ) http:// : .
- 3 :
.
:
Tools >> Options :
1
2
:
- Events
49
algoharism.blogspot.com
50
Events -
algoharism.blogspot.com
.4
-2 events button Button1
:
)MessageBox.show("Name of Event
:
Click
Enter
Leave
MouseHover
Event Event F1 .
-3 textbox :
)MessageBox.show("Name of Event
Events:
keyPress
KeyDown
KeyUp
TextChanged
- Events
51
Microsoft
VB Express
2010
algoharism.blogspot.com
...
algoharism.blogspot.com
.1 Variables
Variable
( )
.
:
.2
.3
.4
.5
Data types
2 byte
4 byte
1 byte
4 byte
8 byte
8 byte
1 byte
8 byte
Integer
Long
\
true 2 false 1
Boolean
Single
double
Currency
String
Date
....
Object
variant
:
Dim VariableName As DataType
53
algoharism.blogspot.com
:
\
Data types
Integer
Boolean
double
String
:
Lesson04 - :
54
algoharism.blogspot.com
55
algoharism.blogspot.com
.2
.
:
Button1 :
56
algoharism.blogspot.com
39 :43
' Example 2
Dim firstTextBox As String = TextBox1.Text
Dim secondTextBox As String = TextBox2.Text
Label1.Text = firstTextBox & " " & secondTextBox
firstTextBox String
Text TextBox1
secondTextBox String
Text TextBox2
Label1 :Text
( firstTextBox )Textbox1
( + &) ( )
+ secondTExtBox
Debug
F5 :
33: 37
57
algoharism.blogspot.com
" "2
2 "
"3 3
Button1
58
algoharism.blogspot.com
.3
(
)
.
- .
.
:
Implicity- 2 :
o
.
o .
Explicity- 3 :
o .
o
.
:
: :Implicit
- 2
- 3 :
59
algoharism.blogspot.com
46 myValue ( Integer 3 )
: 47 myOtherValue ( Double 9 )
4.25
: 48 myOtherValue ( myValue
9 3)
:4: myValue 3( Integer)
2 (String) Show MessageBox String
33
myOtherValue myValue
)Double (8 Bytes) Integer(2 bytes
- 4 Debug
MessageBox.Show 39
)myValue(message
)Integer (2Bytes)String (1Byte
60
algoharism.blogspot.com
Double
3.14
(8 Bytes)
Integer
3
(2bytes)
61
: Integer Line 37
3
(2 bytes)
String
Line 39
4
(1 byte)
Microsoft
:
Visual
Basic
2010Express
:Explicit
algoharism.blogspot.com
- 2
- 3 :
62
algoharism.blogspot.com
- :
63
algoharism.blogspot.com
.4
:
statement expression :
:
Dim x As Integer
x + 3
Expression
.Statement
:
Expression
:
2<3 .....
Statement
Dim x as Integer
MyInteger=3
MessageBox.ShowHello world
:Expression (
) expression
). (data type
64
algoharism.blogspot.com
.5
OK
.
Text box
Labels
Combo Box
( )
List box
( - - -)
Radio Box
Check Box
Button
ok cancel
65
Microsoft
VB Express
2010
algoharism.blogspot.com
statements
algoharism.blogspot.com
.1
Statements
Statements .
- Statements Expressions
:
Branching Statements .2 .
Recursion Statements .3 .
Arrays .4 .
Recursion Statements
Branching Statements
expression
:
:
For Each .2
If.Then .2
For Next .3
Select Case .3
Do WhileLoop .4
. :lesson5
ComboBox
( )
ListBox
( -)
TextBox
Button
statements
67
algoharism.blogspot.com
.1.2 IfThen :
.expression
Button1
statements
68
algoharism.blogspot.com
( expression ) :
""
""
If..Then :
statements
69
algoharism.blogspot.com
ComboBox1.text
ComboBox1
""
>< If Combox1.text
>< :
else
then
" "
""
= Messagebox.show
=If ComboBox2.text
else
then
" "
= Messagebox.show
statements
" "
= Messagebox.show
70
algoharism.blogspot.com
" "
"" " " "
".
statements
71
algoharism.blogspot.com
listbox )( ListBox1.SelectedItem.ToString .
statements
72
algoharism.blogspot.com
.3 Arrays
( )
Array .
array :
45
Dim:
myArray(2): myArray:
(2):
( ) As String:
(2 myArray(0): )2
=
46 myArray(1):34748
myArray(2):4
49
MEssageBox.Show(myArray(2)) 4
statements
73
algoharism.blogspot.com
)myArray(2
String
()
4(2)
myArray
myArray
)myArray(1
)myArray(0
""
""
)myArray(2
3
""
3 4 1
statements
74
algoharism.blogspot.com
debug :4
statements
75
algoharism.blogspot.com
} { debug
.4
statements
76
algoharism.blogspot.com
.1.4 for/each :
:
myArray person
61
for each person
:
( ) ( )
.
statements
77
algoharism.blogspot.com
.2.4 for/next :
:
:67 i integer . 1
68 :69 i 1 6
6 1 6
:6: .
:for/next
Var1
counter
Var2
counter
Counter
integer
Var3
counter
statements
78
algoharism.blogspot.com
......
79
statements
algoharism.blogspot.com
.5
for/next :if then
:82 myArray .
:84 i integer
:85 i for/next 1
( 2 )myArray.length
.
Arrays myArray )( myArray ( )2
statements
80
algoharism.blogspot.com
89 :8: if .for
:)dont debug
for
if
i
= myArray 1
myArray 2
= 1 ( = )2-5 1 4
:
"" myArray i
: for
if 2
""
if 3
""
4
if
""
:
)myArray(i
0
)myArray(0
1
)myArray(1
2
)myArray(2
debug 2
( ) 1 2 1
2 3 .
( )Visual Basic .
statements
81
algoharism.blogspot.com
button1 i 1
listbox1 2
( listbox1 )Ctrl
button1 .
statements
82
algoharism.blogspot.com
.6
2 :
:2 textboxes listbox 2 : : listbox textbox
:
+
*
/
.
-3 Dvd Array
4
label label
.
statements
83
Microsoft
VB Express
2010
algoharism.blogspot.com
algoharism.blogspot.com
.1
.
Start menu
programs Microsoft Visual Basic 2010 Express
New Project Windows Forms Application MyFirstVBApp
85
algoharism.blogspot.com
.2
.2 Toolbox Containers
TableLayoutPanels
Toolbox
86
algoharism.blogspot.com
.3 properties
TableLayoutPanel1
TableLayoutPAnel .
TableLayoutPanel
.4
TableLayoutPAnel
Edit
Columns and Rows :
87
algoharism.blogspot.com
.5 Toolbox ( PictureControl
) .
PictureControl
Dock in Parent Container
88
algoharism.blogspot.com
.6 checkbox toolbox
(
.)picturebox
text " ".
.7 toolbox containers
FlowLAyoutPanel Dock in
parent container
FlowLayoutPanel
5
.
.8
:
FlowLayoutPanel toolbox 5( button1
button2 button3 )button4 . FlowLayoutPanel
text property " " "
" " " " ".
flowdirection
FlowlayoutPanel RightToLeft .
"" Ctrl
4
properties autosize
True .
89
algoharism.blogspot.com
.3
"" ) (Name
closeButton " " showButton "
" clearButton " " . backgroundButton
90
algoharism.blogspot.com
.4
DialogBoxes
.
- 2 toolbox Dialogs OpenFileDialog
ColorDialog :
:Title
OpenFileDialog Paint file
open
filter
91
algoharism.blogspot.com
.5
:
showButton - 2
: " " showButton
OK OpenFileDialog
.PictureBox1
" " clearButton - 3
:
Private Sub clearButton_Click() Handles clearButton.Click
' Clear the picture.
PictureBox1.Image = Nothing
End Sub
.
:" " backgroundButton - 4
Private Sub backgroundButton_Click() Handles backgroundButton.Click
' Show the color dialog box. If the user clicks OK, change the
' PictureBox control's background to the color the user chose.
If ColorDialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.BackColor = ColorDialog1.Color
End If
End Sub
92
algoharism.blogspot.com
.ColorDialog1
:" "closeButton - 5
Private Sub closeButton_Click() Handles closeButton.Click
' Close the form.
Close()
End Sub
: checkbox - 6
Private Sub CheckBox1_CheckedChanged() Handles CheckBox1.CheckedChanged
' If the user selects the Stretch check box, change
' the PictureBox's SizeMode property to "Stretch". If the user
' clears the check box, change it to "Normal".
If CheckBox1.Checked Then
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
Else
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
End If
End Sub
.
F5
93
algoharism.blogspot.com
.6
.
Build Publish
94
algoharism.blogspot.com
Project Properties
95
algoharism.blogspot.com
96
.3114/3113
Visual Basic - .3112
Visual Basic Express 2005 -
.3121 - http://msdn.microsoft.com/en-us/beginner/bb308891.aspx
MSDN http://msdn.microsoft.com/en--
.3121 us/library/dd492135%28VS.100%29.aspx
-
http://knowledge.moe.gov.eg/NR/rdonlyres/327B0AF2-677C-459F-B6C7.3121 - 6F2A6708E9DD/15719/1672009.ppt
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
http://algoharism.blogspot.com/search/label/
http://store.ovi.com/content/94223
http://twitter.com/algoharism
http://algoharism.blogspot.com/search/label/
http://www.facebook.com/algoharism
http://algoharism.blogspot.com/search/label/
114