You are on page 1of 276

1

..

http://knigaluby.ru

______________________________________________________________________

2001

0. _______________________________________________________________________ 8
0.1. ? ____________________________________________________________________ 8
0.2. , .____________________________________________________________________________________ 8
0.3. Visual Basic? _____________________________________________________________________________ 9
0.4. Visual Basic? _____________________________________________ 10
0.5. _____________________________________________________________ 10

I. _____________ 12
1. ______________________________________________________________________ 13
1.1. ? ___________________________________________________________________________ 13
1.2. , __________________________________________________________________________ 14
1.3. - __________________________________________________________________________ 14
Visual Basic_______________________________________________________________________ 14
_______________________________________________________________ 15
__________________________________________________________________________ 16
, , , ____________________________________________ 17
Visual Basic __________________________________________ 18

2. - "" ____________________________________________________________ 20
2.1. _______________________________________________________________________________ 20
2.2. ___________________________________________________________________________________ 20
2.3. ____________________________________________________________ 21
2.4. _______________________________________________________________________________ 21
2.5. . ____________________________________________________________________ 22
2.6. - _______________________________________________________________ 23
2.7. ___________________________________________________________________ 24
2.8. _______________________________________________________________________________ 24
___________________________________________________________________________ 25
___________________________________________________________________ 26
_________________________________________________________________ 26
2.9. ______________________________________________________________________________ 27
2.10. - MsgBox _____________________________________________________________________ 28
2.11. ____________________________________________________________________________ 28
2.12. ________________________________________________________________________________ 30
2.13. - _________________________________________________________________ 30
______________________________________________________________________________ 30
______________________________________________ 31
__________________________________________________ 31
__________________________________________ 31
________________________________________________ 31

3. Visual Basic __________________________________________________________ 32


3.1. , ___________________________________________ 32
3.2. Visual Basic ________________________________________________________________________ 32
3.3. Visual Basic ________________________________________________________ 33
3.4. Visual Basic ______________________________________________________________ 33
3.5. . _______________________________________________ 33
3.6. Visual Basic__________________________________________________________________________ 35
3.7. Visual Basic _______________________________________________________________________ 36
_______________________________________________________________________ 37
3.8. _____________________________________________________ 37

II. Visual Basic ___ 40


4. _____________________________________________________________ 41
4.1. . _____________________________________________________ 41
4.2. _________________________________________________________________ 43
InputBox___________________________________________________________________________________ 43
_______________________________________________________________________________ 44
______________________________________________________________ 45

_________________________________________________ 46
. ___________________________________ 46
4.3. _________________________________________________________________________________ 48
4.4. . ____________________________________________________ 48
4.5. ______________________________________________________________ 50
Integer Long - __________________________________________________________________ 50
Single Double - ____________________________________________________________ 50
? Currency ______________________________________ 51
___________________________________________ 51
________________________________________________________________ 51
4.6. ________________________________________________ 52
4.7. __________________________________________________________________________ 54
4.8. Print ________________________________________________________ 55
4.9. __________________________________________________________________________ 56
4.10. _______________________________________________________ 57
4.11. ______________________________________________________________________________ 57

5. _______________________________________________________ 58
5.1. () ______________________________________________________________________ 58
5.2. If ______________________________________________ 58
5.3. If _________________________________________________________ 60
5.4. ____________________________________________________________________________ 61
5.5. If ______________________________________________________________________________ 62
5.6. ___________________________________________________________________ 64
5.7. If. __________________________________________ 64
If ____________________________________________________________________ 64
________________________________________________________________________ 65
______________________________________________________________________ 65
5.8. Select Case ____________________________________________________________________ 66
5.9. . __________________________________________________________________________ 68
________________________________________________________ 68
______________________________________________________________________ 69
_______________________________________________________________ 69
5.10. MsgBox ______________________________________________________________________________ 70

6. ___________________________________________________________ 72
6.1. GoTo. . _____________________________________________________________ 72
________________________________________________________________ 74
6.2. If _____________________________________________________________________ 74
6.3. Do ____________________________________________________________________________ 75
Do . Loop _______________________________________________________________________ 75
Do . Loop While __________________________________________________________________ 76
Do . Loop Until __________________________________________________________________ 76
Do While . Loop __________________________________________________________________ 77
Do Until . Loop __________________________________________________________________ 77
Do ____________________________________________________ 78
Exit Do___________________________________________________________________________ 78
_________________________________________________________________ 79
6.4. For _____________________________________________________________________________ 79
Exit For __________________________________________________________________________ 80
6.5. _______________________________________________________________________________ 81

7. _______________________________________________________________ 82
7.1. . . _____________________________________________________________ 82
7.2. . . . _________________________________________________ 82

8. ___________________________________________________ 86
8.1. ___________________________________________________________ 86
8.2. ___________________________________________________________________________________ 86
8.3. ______________________________________________________________________________________ 87
8.4. ____________________________________________________________________________________ 88
8.5. ________________________________________________________ 89
8.6. ______________________________________________________________________________ 89
8.7. ____________________________________________________________________ 90

9. __________________________________________________________________________ 92
9.1. . , , _______________________________________________________ 92
9.2. ____________________________________________________________________________ 93

9.3. - Visual Basic _________________________________________ 94


____________________________________________________________________ 94
___________________________________________________________ 94
9.4. - Line Shape _____________________________________________________________ 96
9.5. . ZOrder ______________________________________________________ 96
9.6. Visual Basic ______________________________________________________________________________ 97
9.7. 3 - _________________________________________________ 98
Pset _______________________________________________________________________________ 100
Line _______________________________________________________________________________ 100
Circle _____________________________________________________________________________ 101
CurrentX, CurrentY, Step____________________________________________________________________ 101
Cls ________________________________________________________________________________ 102
Point ______________________________________________________________________________ 102
PaintPicture ________________________________________________________________________ 102
9.8. ____________________________________________________ 103
9.9. __________________________________________________ 105

10. ______________________________________________________________________ 106


10.1. ___________________________________________________________ 106
10.2. Stop, End Exit Sub _____________________________________________________________ 108
10.3. ______________________________________________________________________ 110
10.4. ___________________________________________________________________________________ 111
10.5. _____________________________________________________________________ 111
__________________________________________________________________________ 113

11. , , ______________________________________________ 115


11.1. Date ______________________________________________________________________________ 115
_______________________________________________ 116
11.2. ______________________________________________________________________________________ 117
____________________________________________________________________________ 117
11.3. "-" ________________________________________________________________ 118
Boolean ________________________________________________________________ 121
__________________________________________________________________________ 121
____________________________________________________ 124
____________________________________________________________________ 126
11.4. ___________________________________________________________________________________ 127
___________________________________________________ 127
__________________________________________________________________________ 127
"" _______________________________________________________________ 128
______________________________________________________________________________ 128
_______________________________________________________________________ 129

12. ___________________________________________________ 130


12.1. ______________________________________________________________________________ 130
MouseDown MouseUp_____________________________________________________________ 130
MouseMove _______________________________________________________________________ 131
_____________________________________________________________________________ 132
12.2. __________________________________________________________________________ 132
KeyDown KeyUp _________________________________________________________________ 132
12.3. - () _________________________________________________________________________ 133
12.4. _______________________________________________________________ 140

III. Visual Basic - __ 141


13. ________________________________________________________________________ 142
13.1. ______________________________________________________________________ 142
13.2. _______________________________________________________ 142
13.3. ___________________________________________________________________________ 144
13.4. ________________________________________________________________________ 145
13.5. _______________________________________________ 145
13.6. _________________________________________________________________ 147

14. _____________________________________________________ 149


14.1. Variant __________________________________________________________________________________ 149
14.2. __________________________________________________________________ 149
14.3. ___________________________________________________________________________________ 151
____________________________________________________________________ 151
________________________________________________________________________________ 152

14.4. (Frame) ________________________________________________________________________________ 153

15. ____________________________________________________________ 154


15.1. (CheckBox) ___________________________________________________________________________ 154
15.2. (OptionButton) __________________________________________________________________ 155
15.3. (HScrollBar VScrollBar)_____________________________________________________ 156
15.4. Slider, ProgressBar _____________________________________________________________________________ 156
15.5. (ListBox) (ComboBox) ___________________________________________________ 157
(ListBox) ___________________________________________________________________________ 157
ComboBox ( " ") ________________________________________________ 157
ComboBox ( " Combo") _______________________________________________________ 158
ComboBox ( " Combo") ________________________________________________ 158
, ListBox ComboBox. __________________________ 158
15.6. ____________________________________________________ 159
MonthView DTPicker_____________________________________________________________ 159
UpDown __________________________________________________________________________________ 160
DriveListBox, DirListBox, FileListBox _________________________________________________ 160
RichTextBox _______________________________________________________________________________ 161
ListView TreeView ________________________________________________________________________ 161
(TabStrip) (StatusBar) _____________________________________________ 161
MSChart__________________________________________________________________________________ 161
PictureClip________________________________________________________________________________ 161
ImageCombo ______________________________________________________________________________ 161
MSComm _________________________________________________________________________________ 161

16. , , _________________________________________________ 162


16.1. ______________________________________________________________________________________ 162
ASCII_____________________________________________________________________________ 163
16.2. ______________________________________________________________________________________ 163
16.3. Shell ________________________________________________________________________________ 167
16.4. . On Error ___________________________________________________________ 167

17. . _________________________________________ 169


17.1. . __________________________________________________________________ 169
17.2. ________________________________________________________________________ 170
___________________________________________________________________ 172
17.3. _______________________________________________________________________ 172
17.4. ____________________________________________________ 173
17.5. . ___________________________________________________________________________ 173
17.6. __________________________________________________________________________________ 175
17.7. , _______________________________________________________________ 176

18. , _______________________________________________ 178


18.1. "" Windows____________________________________________________ 178
18.2. CommonDialog _____________________________________________________________ 178
Common Dialog ______________________ 179
18.3. Toolbar ___________________________________________________________________ 180
18.4. - " " _______________________________________________________________ 182

19. ____________________________________________ 185


19.1. _________________________________________________________________ 185
19.2. _________________________________________________________________________________ 186
19.3. . Project Explorer._________________________________________________________ 186
_____________________________________________________________ 186
____________________________________________________________ 187
19.4. ______________________________________________________________________________ 187
________________________________________________________________ 187
__________________________________________________________________ 188
__________________________________________________________ 188
19.5. ___________________________________________________________________________________ 189
19.6. ______________________________________________________________________________ 190
19.7. ? _____________________________________________________________________ 190

20. ___________________________________________________________ 193


20.1. - " " ______________________________________________________________ 193
20.2. "". ________________________________________________________________ 194
20.3. ________________________________________________________ 195
20.4. __________________________________________________________________________ 195
20.5. _____________________________________________________________________ 195

20.6. _______________________________________________________________________________ 196


- _________________________________________________________ 196
____________________________________________________________ 196
20.7. . _________________________________________________________________ 199
20.8. ______________________________________________________________________________ 202
_________________________________________________________________________ 202
________________________________________________________________ 202
, _________________________________________________________________ 203

21. Visual Basic ___________________________________________________________ 204


21.1. , Web- HTML ________________________________________________ 204
21.2. Web- _______________________________________________________________________ 204
21.3. Web- _____________________________________________________________________ 205
21.4. _____________________________________________________________________ 207
21.5. __________________________________________________________________________ 209

22. Visual Basic ________________________________________________________ 210


22.1. _______________________________________________________________________ 210
22.2. Visual Data Manager ____________________________________ 211
22.3. . Data DBGrid. SQL. _____________________________ 212

23. _____________________________________________________________________ 215


23.1. Visual Basic_______________________________________________________ 215
ActiveX ___________________________________________________________________________________ 215
Windows API ______________________________________________________________________________ 215
- MDI ________________________________________________________ 215
OLE _____________________________________________________________________________________ 215
23.2. ________________________________________________________________ 215

1.
__________________________________________________________ 218
24. ___________________________________ 219
24.1. . . __________________________________________ 219
24.2. ____________________________________________________________ 220

25. __________________________________________________ 221


25.1. . _______________________________________________ 221
25.2. ___________________________________________________________________ 222
25.3. . ? __________________________________________________ 222
25.4. ___________________________________________________ 223
25.5. ______________________________________________________________________ 223
25.6. _______________________________________ 225
25.7. ___________________________________________ 226
25.8. ____________________________________________________________ 226

26. __________________________________________________ 229


26.1. ______________________________________________________________ 229
26.2. _______________________________________________________ 230
26.3. _____________________________________________________________ 231
26.4. ________________________________________________________________ 231
26.5. _________________________________________________________ 234

2. Windows. ______________ 236


Windows _________________________________________________________________________________ 236
. ____________________________________________ 236
Windows __________________________________________________________________ 236
____________________________________________________________________________________ 237
______________________________________________________________________ 238
________________________________________________________________________________ 238
. (, ) ________________________________________ 239
___________________________ 239
_____________________________________________________________ 239
_____________________________________________________________ 241
- _________________________________________ 242
, ________________________________________ 242
________________________________________________________ 243

_________________________________________ 244
_______________________________________ 270
____________________________________ 271

0.
- Visual Basic! , .
: , .
, : . . ,
. . .
, . , , ! , ,
, , . Visual Basic .
, . " " ,
. Visual Basic
, . .
, , ,
. Visual Basic .
Visual Basic , , Delphi ( Object Pascal), Visual C++ .
, , . , , ,
. , Visual Basic
, , .

0.1. ?
. , , , Visual Basic .
, . . ( 132).
, .
, , , , . , ,
, , !
, , . , , -, (
), , . , , 0.2.
, , Visual Basic,
. , , .
, , Visual Basic. ?. Visual Basic , . , : , , ,
. , , ? , ? , Visual Basic, ,
. Visual Basic . Visual Basic
. , , ,
(Help). , . ,
, .
, Visual Basic,
- .
, . ,
. , , ,
, . Windows, Visual Basic, .
, . , , . , Visual Basic
.

0.2. , .
, .
: , ,

9
, .
.
, , . , , , , , , .
, .
. - , -
. , . ,
.

, :
""
"",

: , , ,
:
( - , , )
-
.
.

( , , , -, ,
)
: ( )
:

( )

, , " "
, :
: -
- " "
- ( )

( ),

, , . (3D) Quake Unreal. ,


, , .
(, Direct X), ,
. -
, 3D-.
, Visual Basic, Delphi C++,
, . , , , C++, : , !
, , 3D, . .
, , - .
, , , . , . , 3D-. ,

( ) (). . , , ,
, , , , . , , -.

0.3. Visual Basic?


Visual Basic? , , . .
, , , . , , . , - , . , ,
. .
. , , , () .

10
. , , .
, .
. , . ,
, . Visual Basic, Delphi, Visual C++ ( , ) - .
, , , , , .
, . .
Delphi Visual Basic Visual C++.
Visual Basic. , ,
. . , , Visual Basic ,
.

0.4. Visual
Basic?
, Windows.
, , Visual Basic 6.0, - . , .
. Visual Basic ( - ).
. , Visual Basic 5.0 Visual Basic 6.0
, . , , .
Visual Basic, Visual Basic.NET, .
, , , . , .

0.5.
:
I. .
:

Visual Basic.

, Visual Basic .
- "", , Windows.
II. Visual Basic . .
. Visual
Basic - , , . , , , .
-. , , , , , ,
Visual Basic.
III. Visual Basic . . , , , ,
Visual Basic. , , , .
, , .
1. . , , .
2. . ,
. , , Windows,
, , Visual Basic.
, Visual Basic .
.

11
,
.
.


. e-mail: lukin63@mail.ru.
www.learncomp.narod.ru.

12

I.
, , , : " Visual Basic
, ". , , . , .
- .
1 Visual Basic.
2 , , . - Visual Basic.
3 " Visual Basic",
Visual Basic.

13

1.
Visual Basic.
.

1.1. ?
, , . 1 . , "" , , .
Visual Basic, . , , , , .
, . ,
.

,
1.
2.
3. ""
4. ""
5.
6. ""
7.
8.
9.

1.
2. , ,
3. ,
4. 1
5. ,

1.
2.
3. ..
""
1. ..
2. ...

1.
2.
3. ..
..
...
,
1.
2. ..
,
1. , -
2.
..

14

, - . - . " , ", -
"".
9 .
, "", . , "
" " ". " ", , " ". .
""?
" " , , "
" " "? , ,
. ? , , ,
, , .
, , .
. , . , , . , .
, , , - . , (, , , ),
. , " , " , .
Visual Basic . , ,
. .
.

1.2. ,
, Visual Basic , .
: , , , , , , .. , 3 :
1. , , ..
2. 2 , ,
( , , ) .
- . , : " - ", - - " - ".
3. , . - , ,
: .
. , . , . .
, , . 1 , , 2 , 3 . , ,
, - 1 -
- , .
. , , . , , .

1.3. -
Visual Basic - - , , , , Visual Basic. .
. . , , , , . - ,
. : " - " " - -". , ,
. , , - ,
. ! . , .

Visual Basic
, , , Visual Basic. Visual Basic , 3.2, , , , 3.4. Visual Basic, - (. ).
, File, Add Project -
.
( - FileAdd project).

15

, . .
New Standard EXE, Open. ,
, ( ):

, ,
. . - ? .
, - , , . ,
Windows.
. ,
. .
1 . , : , ..
, - Visual Basic . Visual Basic
. Toolbox ( ), , Visual Basic. , , ,
. - , , .
Toolbox ,
.
: "" Visual Basic , ,
, .


, . (CommandButton) . ,

16
"". ""? - , , , "" . "". . Command1.
8 - . , , - . . - . , , . ,
Delete. . , , .
(TextBox). .

[design] () Visual Basic. , Visual Basic , (1


) (2 ).
. . ,
2 ( ) 3 , . Start ( ).
. ? , ,
Visual Basic , . Visual Basic. . , ,
Windows. .
, .
. . . . -
, , .
. . , . .
Visual Basic ,
, . - Windows
.
[run] (, ) Visual Basic. ,
Visual Basic , (3 ),
(1 ), (2 ) .
, , . End
. Visual Basic [run]
[design]. - . .


. - .
- ! , Visual Basic , , , , . . , - , . , .
. () :

Form1.BackColor = vbRed
, .
Form1
- ( Visual Basic )
BackColor
- " ", , ( )
vbRed
- (Red - , vb - Visual Basic)
, :
Form1. =
: , - , . . . = 140
. =
Visual Basic . , , - ? . , [design]. Command1. -

17
- . ,
(Code).

. ,
( ).
, - . Private Sub Command1_Click() " , (- - Click) Command1". Private ""
. Sub "". , : " , , , Command1".
, . . End Sub, " ".
, , ,
Command1.
Form1.BackColor = vbRed. , 2. .
.
, Visual Basic . , ( BackColor) .
.
, . . : ViewCode.
, - , : ViewObject.
. :

. , - , .
, .
. , . Start.
. - .
! . . . .
End.
, , " Visual
Basic ".

, , ,
. -, , , . , Visual Basic, 3.5. Windows, File Save Project, ,
, , . Visual Basic
. .
, Visual Basic, ,
. , Visual Basic
() File Open Project.
, File New Project.
. ,
Visual Basic, . , :


Visual Basic ( , ) - File Remove Project. Visual
Basic Project Explorer . Project Explorer : Project - No Open

Projects.

File Open Project File New Project.


, , Visual Basic
. File Open Project File New Project
File Add project, Visual Basic

18
. , Project Explorer. ,
, . , File Remove Project,
, Visual Basic .
, , , , . . . .
, 3.5.

Visual Basic
- , Visual Basic - (, ) . , . .
, :

Form1.BackColor = vbRedd
Visual Basic . .

Private Sub Command1_Clictk()


Visual Basic . .

Form1.BackColo = vbRed
Visual Basic , . , , , , .
Help Visual Basic , . .
OK Visual Basic . .

Foorm1.BackColor = vbRed
Visual Basic , .
Debug, Visual Basic . .

Form1.BackColor = = vbRed
Visual Basic , . . .
, , , .
, , .
Visual Basic .
. , . , , , . ,
End Sub? , ?
, .


, . - FileRemove Project. , .
.
- , . , . :

Text1.FontSize = 16
Text1 - , FontSize - . :
Text1 16. :
Private Sub Command1_Click()
Form1.BackColor = vbRed
Text1.FontSize = 16
End Sub
Visual Basic Private Sub Command1_Click() End Sub. Start. , . , , . :
, .
. "
". :
Text1.Text = " "
Text1 - , Text , .
( Text1 Text) . :
Text1 - " ". :
Private Sub Command1_Click()
Form1.BackColor = vbRed
Text1.FontSize = 16
Text1.Text = " "
End Sub
, .
. :

19

- Command2. (vbYellow),
12, " "
, Command1, Command2 . , , - , Command2. . :

. .
, 1.1.

, .

, Form1.

, .
- : , .

("..", " , "). - " , ".

- " ", "", - .

?
, . ? , - , , . . ,
. . Toolbox
Image () - , , , .. . - . ,
, . ,
. , , ,
, .
Visual Basic . , Timer,
" ". Toolbox .
. , Microsoft Multimedia Control 6.0, ,
. Visual
Basic.

20

2. ""
Visual
Basic. , Visual Basic. . Visual Basic. . -, ,
. , , , " "
, .

2.1.
1 , Visual Basic.
- . , Windows. , Windows ( Visual Basic), :
. - Microsoft ? ,
, , , ,
"".
, ( ):

- ,
.

2.2.
. :

21

, .

2.3.
, BackColor, FontSize, Text. . [run] ,
(, Form1.BackColor = vbRed). , [design]. , ( ,
!).
[design]? . Command1. . , , . (. 1.3). , , . : . ( alphabetic)
( categorized).
- Command1. Width (),
- . , , 200. ,
. [run], Command1.Width = 200.
- . ,
.
- . - . ,
- . .
.

2.4.
(Name). (Caption). . , .
, Visual Basic ( - ) , , , , . .
. (Name) - . , - Form1.
, , . . ? . , ,
, , . ( ), ().
. (Caption). - - Form1. - . .
, . ? , ,

.Width=6000
- ,

Form1.Width=6000
. Command1 _.

! , ,
. , .

22
. 4.3.
+. + . . , Font .
- . - , (Size), (Font Style), (Font) - .
(Regular), (Italic), (Bold) (Bold Italic).
(Font) . . .
. : _, _, _.
.
. : 1, 2, .
(Caption) . Text. ,
, Text .
( , , ).
- Label (), . Label
Toolbox . :

. , Visual Basic
(Label1, Label2, Label3). , ,
, , , , , , , .
. Toolbox Line () . , BorderWidth.
, ! , . .

2.5. .
. 3, 2. .
. . . . , . : 3 2 -
, Text 1 2. -, 1.Text 2.Text. ,
.Text . :

.Text = 1.Text + 2.Text


- . :
Private Sub __Click()
.Text = 1.Text + 2.Text
End Sub
. 3 2. . . , .
5 32. ? , Visual Basic +
, "". . 3 2 , . , . , 1 2,
, Visual Basic , -
.
? Visual Basic ,
. - 1.Text 2.Text, - Val(1.Text)
Val(2.Text). Val - Value - , . :

.Text = Val(1.Text) + Val(2.Text)


, Visual Basic ,
. .
. , .
. :
Private Sub __Click()

23
.Text = Val(1.Text) + Val(2.Text)
End Sub
__________________________________________________
Private Sub __Click()
.Text = Val(1.Text) - Val(2.Text)
End Sub
__________________________________________________
Private Sub __Click()
.Text = Val(1.Text) * Val(2.Text)
End Sub
__________________________________________________
Private Sub __Click()
.Text = Val(1.Text) / Val(2.Text)
End Sub
: *, - /.
.
.

, !
: (, -),
, . Visual Basic
. 5.9.

1 . : .
2

, .
. : 1.Text = "".
. , .

2.6. -
. , . , -. , ,
, , [run].
: .
" " , , - .
- . , -
. - . - ", !"
BackColor ( ) - . . . - . Palette ()
.
ForeColor ( , ).
Appearance ( ) - 3D () Flat ().
BorderStyle ( ). 6 , ,
, [run].
ToolTipText ( ). , , ,
Windows, Word, - ,
, , .
ToolTipText. . .
. .
MouseIcon, MousePointer ( , ).
. MousePointer 2 (). . . .
,
, .
MousePointer 16 . MouseIcon . MousePointer 99. MouseIcon Windows\Cursors Cursors Icons, Graphics, , Visual Basic.
? , . - . .

24

.
MaxButton ( - ). - True
(). False (), .
MinButton ( - ). - True (). False (), .
Moveable ( ). False , [run]
. .
WindowState , : 0 - , 1 -
( Windows) 2 - ( ).
Visible (). - True (). False (), . .
Enabled ( ). - True. False, , . -
.
Alignment.
, .
MultiLine. True, ,
. ScrollBars, .

2.7.
, - . ,
. , , - , , Paint.
. Picture. .
. Open - .
(.9.3). Microsoft Office, Clipart
.
,
- PictureBox Image - .
( Style Graphical).

2.8.
,
.
, (
- ). -. MID, WAV, MP3
. , - MP3.
, , , , WAV.
, , C:\Windows\Media. - Canyon.mid.
. Windows . () Wave ( WAV- MP3-) MIDI ( MID-
RMI-). , ,
.
, Microsoft Multimedia Control 6.0. Toolbox. . : Projects
Components OK. Toolbox. .
. (, ). , .
[run], , :
Properties Controls .
, , Visual Basic :
.DeviceType = "Sequencer"
.FileName = "c:\Windows\Media\Canyon.mid"
.Command = "Open"
.Command = "Play"
: (DeviceType) ,
. mid, rmi Sequencer. wav,

25

mp3 WaveAudio.
, .
(Command) (Open) . .
(Play) .
, , , . ,
, , - - .
, 4
? - , ? , (, ). , Visual Basic
. - (Form_Load) - (,
) . -
.
. :
Private Sub Form_Load()
End Sub
: " , ", "
, ". , 4 . . .
, , ,
"Close".
, - .
Form_Terminate. :
Private Sub Form_Terminate()
.Command = "Close"
End Sub
, Form_Terminate , ,
, End .
, , .


- ,
- , .
C:\Windows\Media. , wav. Chime.wav, Notify.wav, Tada.wav Logoff.wav.
Microsoft Multimedia Control 6.0. . ,
. , . Visible False.
Wav- WaveAudio. , . .

.DeviceType = "WaveAudio"
, - Form_Load.
:

.FileName = "c:\Windows\Media\.wav"
.Command = "Open"
.Command = "Sound"
.Command = "Close"
: "Sound" , "Play", , , .
, . "Play"
Canyon.mid, , . "Sound" Chimes.wav, "".
: , Canyon.mid
Wav-.
, :
Private Sub __Click()
.FileName = "c:\Windows\Media\Chimes.wav"
.Command = "Open"
.Command = "Sound"
.Command = "Close"
.Text = Val(1.Text) + Val(2.Text)
End Sub
Private Sub __Click()
.FileName = "c:\Windows\Media\Notify.wav"
.Command = "Open"
.Command = "Sound"
.Command = "Close"

26
.Text = Val(1.Text) - Val(2.Text)
End Sub

Private Sub Form_Load()


.DeviceType = "WaveAudio"
.DeviceType = "Sequencer"
.FileName = "c:\Windows\Media\Canyon.mid"
.Command = "Open"
.Command = "Play"
End Sub
Private Sub Form_Terminate()
.Command = "Close"
End Sub


Microsoft Multimedia Control 6.0 --. , "CDPlayer".
CD-ROM . :
CDPlayer.DeviceType = "CDAudio"
CDPlayer.Command = "Open"
CDPlayer.Command = "Play"
- Visual Basic. . Visual Basic . Microsoft Multimedia Control 6.0 , .


5-6 , - ,
5-6 . .
, . ,
"", .

Form1.Picture = LoadPicture("C:\Program Files\Microsoft Office\Clipart\Popular\Agree.wmf")


LoadPicture . .
, .
, , , . (Label)

Label1.Caption = " - . 1970 ."


- ?
, .

.Command = "Play"
.Command = "Close"
, , . :
.Command = "Close"
.FileName = "c:\Windows\Media\Canyon.mid"
.Command = "Open"
.Command = "Play"
"Close" , .
"Open" .

3: - " ".
4 " -":


- : , , . " " . .
, . .
- CD-RW, -, . , . - , , , 3.8, .
.

27

2.9.
, , , , , . .
, , ,
.
:

y
x

y
, . . , Visual Basic . , , .
? Left

Top.
Left - .
Top - .
,
. - , Left Top. :


Visual Basic .
. .
Left, Top, Width ( ) Height ( ). , Width Height.
, . Left
Top , .

:

Form1.Left = 2000
"" :

5:

- " " " - !". , ,


.

28

2.10. - MsgBox
- . ,
:

MsgBox (" !")


, Form_Terminate.
, .
5.10.
, , , ?

2.11.
! , , , , ,
. :

: " ", .
"" , , "" - .
" ", .
, .
. , Visual Basic ToolsMenu Editor.
:

29

. Caption " ". ,


. , .
, , ___, Name.
. , , -
Shortcut.
Next "", __.
Next "", __.
Next " ", ___.
4 :

, "" "" " ". . :

- , , , .
, Delete , Insert .
- . . ,
. . , . , ,
, .
. "" .
:
Private Sub ___Click()
End Sub

30
, , "".
:

Form1.Picture = LoadPicture()
Form1.BackColor = vbBlue
, , ( 3 2.8).
"".

MsgBox (" 2000 ")


, .
Visual Basic , ,
. Visual Basic ( ,
3.5). , .

2.12.
- , , , . .
! !
. ProjectComponentsMicrosoft Windows Common Controls-2 6.0. Toolbox
. Animation - . - Animation1.
AVI. , -
Videos, , Visual Studio. :
"C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos".
, , "". , "" FILECOPY.AVI:
Private Sub _Click()
Animation1.Open "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos\FILECOPY.AVI"
Animation1.Play
End Sub
, 2.8 ,
.
. "" , Animation1.Stop, - Animation1.Close.
3 5 12,

Animation1.Play 3, 5, 12
. - - Microsoft Multimedia Control 6.0,
AVI. , , "". , :
.DeviceType = "AVIVideo"
.FileName = "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos\ FILECOPY.AVI"
.Command = "Open"
.Command = "Play"
, , . , .

2.13. -

- . ?
, , ( ):
Private Sub __Click()
.FileName = "c:\Windows\Media\Chimes.wav"
.Command = "Open"
.Command = "Sound"
.Command = "Close"
.Text = Val(1.Text) + Val(2.Text)
End Sub
, . , ?
, , , ( ),
, , !
. - .
-

31
. ,
. :
', , ,
' , :
'Chimes.wav , .
Private Sub __Click()
.FileName = "c:\Windows\Media\Chimes.wav"
' .
.Command = "Open"
' .
.Command = "Sound"
' .
.Command = "Close"
' .
.Text = Val(1.Text) + Val(2.Text) ' , Val
End Sub
, , , .
. , ,
. Visual Basic, , , , .


, . - ,
, . , .
. ,

.Text = Val(1.Text) + Val(2.Text)


.Text = Val(1.Text) _
+ Val(2.Text)

.Text = _
Val(1.Text) _
+ Val(2.Text)
, - .


Visual Basic , , :
.Command = "Open" : .Command = "Sound" : .Command = "Close"
.


Windows :
Windows ( ) .
Visual Basic, , , . , , , , Visual Basic.
- FileMake Project1.exe. ,
, (, ). - .exe . c:\Windows\ ,
Windows, ( ) c:\Windows\ \\, Windows (
, ).
, .exe ,
. , (. 3.8).

, 2.5.
, , , ( . 5.9).
(. 4.5 " ").

32

3.
Visual Basic
, .
Visual Basic, Visual Basic, , Visual Basic ..
, . ,
, .
Visual Basic . , , Visual Basic, ,
. :

4.2
-

6.1
-

7
-

9.1
- . , ,

14.4
- (Frame)

19.3
- . Project Explorer.

2. Windows.
, , .

3.1. ,

, Visual Basic ,
. ,
: , ,
, Windows. ,
, .
, , Visual Basic .

3.2. Visual Basic


-, - . , , . , , .
Visual Basic, ().
, 3.8.
, Visual Basic , ,
3.4. , . Windows, , , .
Visual Basic, -. Visual Basic - , Microsoft Visual Studio, Visual Basic Visual C++
Visual FoxPro.
, - ( -) Visual Basic Visual Studio. Visual Basic - -. ,
, .
:
1. ( 1 ) CD-ROM.
, .
. . .
, . .
, 4. , .
2. Setup.exe -. Windows CD-ROM.
"".
-.
3. Setup.exe .
4. . . - . Visual Basic Visual Studio
6.0. Visual Basic , .
.

33
5.
6.
7.

8.
9.
10.
11.
12.

13.
14.
15.
16.

. Next.
, Visual Studio. ,
I accept the agreement. Next.
- . . . .
. Next.
Custom.
, . . Next.
Continue.
OK.
Visual Studio . , :

Microsoft Visual Basic

Active X

Data Access

Graphics

Tools
. Continue.
- , , . , .
( Windows Restart). ,
, , .
Visual Studio. . .
-.

3.3. Visual Basic


(1) Visual Basic
(2) ,
.
(3)
(4) ( Start F5).
, 6
(5) ( . 7)
3
(6) .
3
.

3.4. Visual Basic


Visual Basic . ""
. Microsoft Visual Studio
Microsoft Visual Basic.
Visual Basic , Windows - Visual Basic File Exit.

3.5. .
, . Visual Basic . , ,
Visual Basic . Visual Basic "" - Ctrl-Alt-Del. , Visual Basic . ,
() .
File Save. , :

34

Save in , .
, ( VB98).
, Visual Basic.
, , , ,
, , .
, Save in.
, . , ,
Save as type All Files. frm, Form Files (*.frm).
. Save
in, . , .
?
. , Save in,
, . - . , (Desktop), . ,
.
Save in, ,
Windows. .
, Save in, . ,

. .

Windows . , -
, , , ,
. , . . ! . Cut () Delete ().
, Copy ().
, , Save
in, .
Paste (). , , Save in
.
, , , Copy Cut ().
, Rename ().
, , VB98 , , -, , " ". . . File Name
- Form1.frm. - , - . Save. Visual Basic
. Project1.vbp.
.
, .
: File
Save. . Visual Basic, ,
( , ) , , . ( ,
.) .

. , , .

35
, Visual Basic, - File Open. ,
, . : , . ,
. .
, ,
, .
Windows, Visual Basic.

3.6. Visual Basic


Visual Basic 6.0. , ,
. .
. Visual Basic , , Windows:
, , - . , . Windows, 2.
, . 1.3. -:
Object - , Project1 - Form1 (Form). - . , .
Toolbox - .
Code - . Visual Basic . , Command1,
Command1_Click. , . ?
: , Command1 Text1. ,
, , .
(DblClick) Text1. Text1,
, , , Text1. DblClick -
:
Private Sub Text1_DblClick()
End Sub
: ,
( ) - . .
Properties - .
Project Explorer - . , . , .
Project Explorer .
. Project Explorer 19.3.
- , View , , . , , Window , . , Windows.
:
Form Layout - .
Object Browser - . () Visual Basic. - , , TextBox, , , , (. 9.1), . ,
, , , , [run]. , SelText TextBox, , . Object Browser
- , "" .
Object Browser 9.1.
Color Palette - .
, "" "" Visual Basic. , , . , Tools Options Docking .
"" . ,

36
, , Windows,
- Visual Basic. , Windows.

3.7. Visual Basic


. , . , , 19.3.

File
New Project. .
Open Project. , .
Add Project. , ( Existing Recent) , . , ,
New Project Open Project.
Remove Project. , , , ,
Project Explorer.
Save Project. .
Save Project As. .
Print. .
Print Setup. .
Make Project1.exe. (. 2.13).
, .
Exit. Visual Basic.

Edit
Undo. .
Redo. .
Cut, Copy, Paste, Delete. , , . , . , 2. . , , - Toolbox,
, . :

Copy Paste.

Copy
Paste .
Cut ( ) Delete ().
Find, Find Next, Replace. .

View
Code, Object, Object Browser, Project Explorer, PropertiesWindow, Form Layout Window, Toolbox, Color Palette -
Visual Basic, .
.
Immediate, Locals, Watch - , (. 7).

Project
Add Form- . - [run].
, . , [run] . , - , , . .
19.1.
Remove Form - .
Components. Controls, Toolbox . Insertable Objects,
Windows. , Word, Microsoft Word Document
. Toolbox Word. .
Word , Visual Basic, Word , [run]. , .

Format
Align, Make Same Size - , , , .
, , . , Ctrl .
Order. , .
, . - , . , Bring to Front (
) Send to Back ( )
Lock Controls. -

37
. , . . , .

Debug
(. 7).

Run, Query, Diagram


.

Tools
Menu Editor, (. 2.11). ,
Options, Visual Basic: :

Editor - ,
. Require Variable Declaration,
. Tab Width Tab.

Editor Format - , , .

General - , , . Align Controls to Grid , . Show Grid, . , .

Docking - , Visual Basic ,


"" "" Visual Basic.
, .

Environment - When Visual Basic starts , Visual Basic


(Prompt for project) (Create default
project). When a program starts , Visual Basic
(Save Changes), (Prompt To
Save Changes) (Don't Save Changes). . .

Advanced - .

Add-Ins
Visual Data Manager, . - 22.2.

Window
Windows.
.
Split , , , .

Help
Visual Basic, , -, ,
, -, . Visual Basic , , . . - Help -
, . , , .
- , , BackColor,
F1.
Contents .
Index , , (, FileName).
Visual Basic 6.0 MSDN (MSDN Library), - Visual Studio.


. - . - . Left, Top, Width Height .
Visual Basic . : View Toolbars.
, , Form Editor, , Format , . , , Edit
. .

3.8.
, , , , , . - Visual Basic.
( .exe)
. ( , 2.13.) . Visual Basic
. , - ! , - Visual Basic Windows,
Windows -.
- - , .

38
- ( ) ( Microsoft Office). , - ( install - ). , Microsoft Office, Microsoft
Office, , Microsoft Office. ( - Setup.exe) . . . , ,
Microsoft Office. Microsoft Office
. Windows Microsoft Office.
Microsoft Office "" Windows.
, , , ,
, , - , . "". - - ( CD-RW - -) , .

.FileName = "c:\Windows\Media\Canyon.mid"

Form1.Picture = LoadPicture("C:\Program Files\Microsoft Office\Clipart\Popular\Agree.wmf")


, - .
, , -, , , ? . , .
: , , Project1.vbp
Form1.frm. " ". . "c:\\".
:

.FileName = " c:\\\Canyon.mid"


Form1.Picture = LoadPicture("c:\\\Agree.wmf")
. - , .
. Visual Basic . , Canyon.mid
Agree.wmf . :

.FileName = App.Path & "\Canyon.mid"


Form1.Picture = LoadPicture (App.Path & "\Agree.wmf")
App, - - , ,
Path "c:\\".
, , ,
.
, Windows, Icon .
Project1.vbp, , , .vbp.

-
, 2.13. : FileMake Project1.exe

Make Project (.exe) , , .


, ( ) .
, . Make Project Options Compile , Compile to Native Code. Advanced Optimizatons
, .

-
Visual Basic Windows. ( ) Package & Deployment Wizard, Visual Basic. Windows. Visual Basic.
, . , .
Next. Back.
Package & Deployment Wizard. Browse
.vbp Package. Package Type.

39

Package Type. . . . Next. - Package Folder.


Package Folder. , . , Package
. , New Folder. , Next. , Package. Yes. :
Included Files. , . ,
, . Add.
, Files of type All Files.
Open. . .
Next.
Cab Options. CAB-.
, , - (Multiple cabs)
(Single cab). , Multiple cabs . CAB- ,
. CAB-, Single cab. Next.
Installation Title. ,
. Next.
Start Menu Items. Windows -
. . Next.
Install Locations. Next.
Shared Files. Next.
Finished!. Finish.
. , .
. .

Windows, . Package. .
CAB-, , , . CAB- Setup.exe SETUP.LST.
, Support,
Package. Support . ,
Package Support!
.

-
.
. Setup.exe.
, Setup.exe , . OK.
Directory , . , Change Directory
. Directory, .
Windows. Continue.
. .
.
, , , .
, Setup.exe. , , (,
Setup.exe) . , .

40

II. Visual Basic


" !" - ,
. . .

. , . ,
. - .
- ""? , . , , - , , .
- -, . -
? , , . .
- , , , , . ,
- .
, ! , , . , : , , , , ,
" " "".
- , ?! , , , ,
- , , , - , !

41

4.

Visual Basic - , ,
Visual Basic. - .
, . ?

4.1. .
. 130
. : r=130. 160 , r=160. , r .
. 130 160 r.
.
.
. , , - .
, Visual Basic? ,
. , . , , 6, =6.
=6 . , 6.
=6 , .
:

Let a = 6

" a = 6".
I. ,

Form1.BackColor = vbRed
"" "". , ,
, . ,
.

a=2*3+4
b=a
y=a+b+1
, a 10, b 10, y 21. , . , , , . Visual Basic , .
, , . 2*3+4, a, a+b+1. .
. .
- . ,
, . ,

Y = a + b + Form1.Width.
, . ,

Form1.Width = a + b + y
.
:

v = -2+10 : h = 10*v : s = v+h+0.01
t = 0 : n = 2*t+40 : z = -n

6:


v - 8
t - 0

h - 80
n - 40

s - 88.01
z - -40

, t :
k=1+2 : s=2*k : t=6-s ?

, , Visual Basic

42
" ". , , .
? :
t = 0 : n = 2*t+40 : z = -n : Text1.Text=z
z, -40, .
, Debug.Print.

Debug.Print t, n, z
. , Immediate.
. . , . , :
Private Sub Command1_Click()
a=2*3+4
b=a
y=a+b+1
Debug.Print a, b, y, b + y
End Sub
. Command1 - Immediate 4 :
10

10

21

31

Immediate? , - ViewImmediate Window.

?
, . ,
: a=27018, b=3954. (, -
).
. :
Private Sub Command1_Click()
a = 27018
b = 3954
S=a*b
'
p=2*a+2*b
'
Debug.Print S, p
End Sub
Immediate :
106829172

61944

- , - . :
S = 27018 * 3954
'
p = 2 * 27018 + 2 * 3954
'
. , .


, . =34, 34=. z=f-v+990 , f-v+990=z. .
, , , , . , , ,
, . .
. (, d+2d),
. , , ( 3d). , ,
, , , .
( d). , (,
y=a+b+1), , , ( a b). .
: . . . =10 : y=a+b+1 . . . , b . , a+b+1 , b.
-. "" , "" - b - ( , ), Visual Basic , b .
. Visual Basic a = 27018.
, , Visual Basic , :
'a = 27018
:
0

7908

, , a .

43

4.2.
N M, : " M!", ,
, - , . , .
, . . , : ", , - !", !
- . - . - .
. Visual Basic , , , .
. , Visual
Basic:

InputBox
- ? - . ,
- . - InputBox.
- .
a=27018 b=3954 . . , . . .
:
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")
S=a*b
p=2*a+2*b
Debug.Print S, p
End Sub
, : a=27018 b=3954.

a = InputBox(" ")
:

. a , .
, .
Project1 , , :

a = InputBox(" ", " ")


:


, Visual Basic , . :
. .
.
:
:
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")

44
c = InputBox(" ")
p=a+b+c
Debug.Print p
End Sub
, - 2, 3, 4 ? 9 234! ?
, , , Val. ? : Visual Basic InputBox ( , ) , ,
. , a, b, c, , , . - ! : Visual Basic , +
, . ,
, . , , .
, , , .
: ,
,
. - .
? . Visual Basic
, * . ( Visual Basic) - , a, b, c . !
: - Visual Basic .
Visual Basic , . ,
Val? , . ? , ?
, Visual Basic ,
!


, , . :
:
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim p As Integer
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")
c = InputBox(" ")
p=a+b+c
Debug.Print a, b, c, p
End Sub

Dim
a
As
Integer
:

a


Visual Basic a . , " a Integer". b, c, p. .
, , 17.2.
. .

Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim p As Integer
:
Dim a As Integer, b As Integer, c As Integer, p As Integer
:
Dim a, b, c, p As Integer
Visual Basic .


Integer? . - 2,3. - , . . Visual Basic a 2. 2,6. Visual Basic a 3. .
, , .
, . , . ! . :

45
Dim a As Single
Dim b As Single
Dim c As Single
Dim p As Single
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")
c = InputBox(" ")
p=a+b+c
Debug.Print a, b, c, p
End Sub

Dim
a
As
Single
:

a


Visual Basic a .
- , (, 27,3908), .
. , " a Single ".
: Integer, Single " "? : ,
. - 4.5.
Visual Basic , Visual Basic -. . - ! .
- , ,
Visual Basic
. - ToolsOptionsEditorRequire Variable Declaration.
Option Explicit, . , " !" , , " - !"
- Option Explicit.
, , , " "
. !
, Option Explicit. , :
x=2
Debug.Print
, 2, . . "",
"". . ""
( , , ""). Visual Basic .
Option Explicit .
:

Integer, Single
-4.2

Long, Double, Currency


-4.5

String
-4.7

Date
-11.1

Boolean
-11.3

-11.3

- 13

Variant
-14.1

-14.2

-14.3

-14.3, 20


, , .
,
, .
( )? .
- + ,
. . ?
, .
. . . 5 . . 1.
( ). .
"" : ,
- , , , . , , -

46
. ,
, . ,
. .
. , . , . Single ,
Integer. : Integer
2 , Single - 4 . , Single 4
, , .


, , " ", " ". , " ".
:
Dim a As Integer
Dim b As Integer
Dim y As Integer
Private Sub Command1_Click()
a = 10 : b = 6 : y = a + b + 1
Debug.Print y + 200
End Sub
, . . :
(, y=a+b+1), (a+b+1).
( a b ),
( 10 6, =10 b = 6), . (17)
, , (y).
, " , 2", "
, , 2".
, a,b,y . . =10. a 10. b= 6
b . y= a+b+1. , a b, 10 6, a+b+1, 17 y. Debug.Print y + 200. y, 17, 17+200 217 Immediate.
:

a= 10
b= 6
y= a+b+1
Debug.Print y + 200

a
b
y
10
10
10
10

0
6
6
6

0
0
17
17



Immediate

217

Debug.Print :
Debug.Print , Visual Basic , , .
.

7:

, , b= 6 y= a+b+1?

.
. - .
, . , ( ),
. , - , . .
Start, , F8 .
DebugStep Into. . , , Command1.
. , ,
, , Private Sub Command1_Click(), . ,
- , , F8 . "
".

47
, ? , , . , "
".
F8. , . a = 10.
F8. Visual Basic a = 10, . , a, b, y .
F8. Visual Basic b = 6, . , a, b, y .
, F8 Visual Basic
, .
, Visual Basic. : [design]
[run]. Visual Basic [break]. , Visual Basic
. , - . , . , , 7. F8, . .
F8. Visual Basic y= a+b+1, . , a, b, y .
F8. Visual Basic Debug.Print y + 200, . Immediate
217.
F8. , . Command1.
: , Immediate . F8 , ,
. , Immediate ,
, Visual Basic . . Visual Basic .
, , Start, .
F8 Start, Continue, .


, . :
Dim k As Integer
Private Sub Command1_Click()
k = 10: Debug.Print k:
k = 25: Debug.Print k:
k = 4: Debug.Print k
End Sub
k:

k=10
Debug.Print k
k=25
Debug.Print k
k=4
Debug.Print k


k
10
10
25
25
4
4


Immediate
10
25
4

, k . , k=25 10 25. ? , .
:
- , ,
, , - .
10 k 25, Debug.Print k 25. ( "" "Print" , , , . ,
, , .) k=4
25 , Debug.Print k . .
?
Dim f As Integer
Private Sub Command1_Click()
f = 30: f = f + 4: Debug.Print f
End Sub
f=30 f 30. f=f+4 ? ,
- . , , f+4 , f , , 34.

48
34 , , , f.
30 . Debug.Print f 34.
, f=f+4 f , , f 4.
? . .

8:

, :
a=100 : a=10*a+1 : Debug.Print a

a=100 : a= -a : Debug.Print a

a=10 : b=25 : a=b-a : b=a-b : Debug.Print a, b

4.3.
, 2.4.
(a, s, d ... ). , Visual Basic, .
:
a=3;
b=4-a;

Debug.Print a, b+50

Summa=3;
ROBBY=4-Summa;
Debug.Print Summa, ROBBY+50

3 51. , ,
, , Summa , 3.
, , .
. : ,
, , -.
:
a
polnaja_Summmma
tri_plus_dva
s25
a1b88qqQQQQQQQQQQQQ
oshibka
__
:
polnaja summa
- (), ,
- (), ,
2as
-
Domby&Son
- & , ,
Visual Basic . , Summa sUmmA -
. , (
).

4.4. .
, , - .
. - , , , . , .
Visual Basic :

49

+ 3
4 - 1
2 * 3
10 / 2
17 \ 5

(17 5, 3, 2)

17 Mod 5

2
8

2^3


( ) -

ab+cd , : a b c d. Visual Basic


: a*b+c*d. , , ab, , cd. ,
. , a * (b+c).
. , , ,
a 1
b 1
. . Visual Basic : (a+1)/(b+1). , a+1/b+1, ,
, , , 1 b , a 1.
: ? : , . . : Visual Basic :

a
2 ab b
3 a

1
:

(1 + a / (2+a*b)) / (3+a) * b .
. , . . , . " ",
( 3+a 2+a*b).
, 1 + a / (2+a*b) , ..
? , , Visual Basic - (1 + a / (2+a*b)) (3+a) (3+a) b. . :
((1 + a / (2+a*b)) / (3+a)) * b
.
. . , , Visual Basic, . : 62.8 - . , , InputBox Visual Basic , .
? Visual Basic, Windows, . . " " - , Visual Basic
- , .
. Visual Basic , , .
, Visual Basic
- Sqr. , 25 - Sqr(25), a+b - Sqr(a+b).
Sqr - Square root - . , ,
.
Visual Basic:

Sqr (25)
Round (5.82716)
Round (5.82716, 3)
Abs ( -20)
Fix (3.98)
Fix (-3.98)
Int (3.98)
Int (-3.98)
Rnd

5
6
5.827
20
3
-3
3
-4
0.73088




()
( )
,
(0 - 1)

, Sin, Cos, Tan ( ), Atn ( ), Exp, Log .


5.4, 9.9.
:

50

(2+1)^2
1+ (2+8)^3
1+Abs(5-8)
2^4+Sqr(35+1)
Sqr (8+Int(41.5))
21 \ (Round (2.54+1))

9:

9
1001
4
22
7
5

, :

a = (2^2+1) * (20- (2^2)^2) - 11 : b=11 \ (a-4) :

Debug.Print a^2 + b - 1

4.5.
, , .
. , . .

Integer Long -
:
Dim a As Integer
Dim b As Integer
Private Sub Command1_Click()
a = 100
b=1
Debug.Print a, b, a + b
End Sub
. , . b=1
b=40000. Visual Basic "Overflow", " ". ?
, Visual Basic , , Integer,
. Integer . , b . -
, - -32768 32767.
, ,
Integer, Long ( ). Long 4
-2147483648 2147483647.
Integer, Long? , , , .

10:

=9000000 . b=1000 .
. ? .

Single Double -
:
Dim a As Single
Dim b As Single
Private Sub Command1_Click()
a = 100.78656954325 : b = 40000.1234567895 :
Debug.Print a, b, a + b
End Sub
. :
100,7866

40000,13

40100,91

, Visual Basic 7 . , 4 ,
Single, . ,
- Double - .
Double 8 .
Dim a As Double
Dim b As Double
Private Sub Command1_Click()
a = 100.78656954325 : b = 40000.1234567895 : Debug.Print a, b, a + b
End Sub
. :
100,78656954325

40000,1234567895

40100,9100263327

- 15 . b, , b
= 40000.12345678957453457, , Visual Basic , , .

51
Single, Double? .

? Currency
: Integer Long, Single Double ?
. , ,
4, , , 4.00000000000381. .
, ,
. Visual Basic ,
. , .
, , Long
. Currency. 4
, . -900 000 000 000 000 900 000 000 000 000.
: , , ,
- .


"
, "

Visual Basic - ? ,
a a = 123456789012345, a = 123456789012345#.
, , Visual Basic , a
Double.
, ( String ):
Integer
Long
Single
Double
String
Currency

&

. Dim b As Double, , , b
, b# b, , b# = 5 b=5. Visual Basic , .
, .
, . DefInt I - M, , , I, J, K, L, M, N, Integer. :
DefLng, DefSng, DefDbl .


:
Dim a As Double
Dim b As Double
Dim y As Double
Private Sub Command1_Click()
a = 2457642345034.78 : b = 0.00000000037645 : y = a / b : Debug.Print y
End Sub
, . , , - . . :
6,52846950467467E+21
? , Visual Basic, , , , , , , (). . , - 21
10 21- . +21 10 . -, 21 - , 6528469504674670000000. , . , . , , ?
-21
21
+21 -21, 10 , 10 , 21 , .
, ,
, -. Debug.Print y
Format(y, "0.0000"). Debug.Print Format(y, "0.0000"). ,
, 4 , Visual Basic
. Visual Basic , .
:
6528469504674670000000,0000
, -

52
.

.Text = Val(1.Text) / Val(2.Text)


.Text = Format(Val(1.Text) / Val(2.Text), "0.00000000000000000000")


- , 20 , , " ", , , , ,
, .


, , " ". ,
. . , , " " - .
, ,

= 1 + 2

.Text = Val(1.Text) + Val(2.Text)


, - ( ) . ( ),
( , ).
:
Dim 1 As Double
', 1
Dim 2 As Double
', 2
Dim As Double
'-,
_____________________________________________________________________________
Private Sub __Click()
1 = 1.Text
'
2 = 2.Text
= 1 + 2
'
.Text =
'
End Sub
, ( ) , , - -
.

! , ,
:
1. , ,
, ,
. , ,
.
2. , , . , For i=1 To 5, For i=1 To 10.
3. . , ,
. , ,
,
- .
,
.

4.6.
, , , .

:
. , .

:
1. . - . , , .
, :

53
1.
2.
3.
4.
5.

=
=
= +
=
= +

, .
2. . . , , , ,
, , ? ( ) , , Width ( ). ( , ,
, , - ).
:

S_
V

S_
S_

3. , . ,
, - Double. :
' ,
'
'
Dim As Double
'
Dim As Double '
Dim As Double
'
Dim S_ As Double '
Dim V As Double
'
Dim As Double '
Dim S_ As Double
'
Dim S_ As Double
'
4. . ,
- , InputBox (4.2) - -.
InputBox.
:
Private Sub Command1_Click()
'
= InputBox(" ")
= InputBox(" ")
= InputBox(" ")
5. , , .
'
S_ = *
V = S_ *
= 2 * + 2 *
S_ = *
S_ = 2 * S_ + S_
6. . ,
" ". .
, , , . 4.10 , . , Print, ( Debug.Print, Immediate):
'
Print " ="; S_
Print " ="; V
Print " ="; S_
End Sub
, Print - , :
" =" , - S_.
Print. Debug.Print.
4.8.

54
. -
? , . , . - , , , , , - .
. , . , . , AutoRedraw True.

11-13:
:
11) 3 80 / 2 90 /. ( , ). , Debug.Print .
12) . ,
. : , , , , . InputBox,
. .
13) . .
5 Print.

4.7.
. , , . ,
, , ( ).
:
Dim a As Integer
Dim b As String
_____________________________
Private Sub Command1_Click()
a = 98
Debug.Print a
End Sub
_____________________________
Private Sub Command2_Click()
b = " !"
Debug.Print b
End Sub

.
Dim a As Integer , a , a=98 a 98.
Dim b As String , b () ,
, , ,
! 2(*fD6:u .
b =" !" b ! . Debug.Print b,
b, !
, , .

, . ,
a="!" : Debug.Print a : a="!" : a=" !" : Debug.Print a
a
!
!
!
:
!
!
:
a="" : Debug.Print a : a=a+a : Debug.Print a+a+a +" "
+ , a+a "" - a. :

55

a+a a+a+a +" " , , , , .
, InputBox.
. :
Dim a As String
Private Sub Command1_Click()
a = InputBox(" - ")
Debug.Print " "; a
End Sub
Debug.Print. ,
.
, , , , , , Print:

4.8. Print
, :


Print

Print 1
1
Print 1; 66
1 66
Print 1; -2; 3.14
1 -2 3.14
Print 1, -2, 3.14
1
-2
3.14
, , , . , , , , , . :
Print 12345, 4, 67824, 240
12345
4
67824
240
Print 345, -94, 67, 240456
345
-94
67
240456
Print 45, 45678, 67, 0
45
45678
67
0
:
Print 45; 45678, 67; 0
45 45678
67 0
? , . ? . :
Print 1+2
3
a = 88 : Print a
88
a = 88 : Print a+1
89
a = 88 : Print a+1, -1
89
87
- .
. :
Print ""

Print "", ""

, .
Print ""; ""

, , . .
? - "" :
Print ""; " "

"" .
Visual Basic , , .
, , , :
Print "??:?()*):%*%;*_?::"
??:?()*):%*%;*_?::
Print "3+2"
3+2
Print "3+2="; 3+2
3+2=5
:
a = "" : Print a

a = "" : Print a+

, Print , , , . , .

, , - , , , Print 66 Print "". , , -

56
. ,
.

Print . ,
Ves. :
Print " =" ; Ves ; ""
= 35
, .
, Mes. ,
. :
Print " " ; Mes ; " ."
.
? , :
Print "" ; Mes ; " ."
.
, Print . Print , Print , -
. :
Print 1; 66,
Print 2;
1 66
2 3
Print 3
4
Print 4;
, , . .
, , Debug.Print.
, , Print, , ,
( - ):
Form1.CurrentX = 1000
99 1000 3000
Form1.CurrentY = 3000
.
Print 99
Form1.CurrentX = 1000
Print 99
99 44 . Form1.CurrentX = 1000
.
Print 44
Form1.FontSize = 20

Form1.FontName = "Arial"
()
Form1.FontBold = True
(True - , False - )
Form1.FontItalic = True
( )
Form1.ForeColor = vbBlue

Form1.FontUnderline = True

Form1.FontStrikethru = True

FontTransparent False,
.
Print - , , , .

4.9.
, :
:
:
:
:
:

, , ?

, . ?
16
! 16 ! !

InputBox, Print. imya, - vozrast.


:
Dim imya As String
Dim vozrast As Integer
Private Sub Command1_Click()
Print ", , ?"
imya = InputBox(" ")
Print " , "; imya; ". ?"
vozrast = InputBox(" ")
Print "! "; vozrast; "! !"
End Sub
, Print " , "; imya; ". ?" ?
, .

57

, . ,
:
:
:
:
:
:

, , ?
!
, ! . ?
100
! 100 ! !

, . ,
. :
:
:
:
:
:

, , ?
!
, !. ?
-2
! -2 ! !

4.10.
, :


Text1.Text = 2001
2001
Text1.Text = 3+2
5
Text1.Text = ""

a = "" : Text1.Text = a

, ,
Print, - , , , ,
. .
Text1.Text = "" + " "

, ,
4.8? . . +. :
Text1.Text = " " + Mes + " ."
.
. :
Text1.Text = " =" + Ves + ""
"Type mismatch" -
. Visual Basic , " ". ,
, , ( ), . " =" "" , Ves - .
, , . , 2.5 Val ( - )?
( - ). Str:
Text1.Text = " =" + Str(Ves) + " " = 35
11.3 !!!! .

14: : ,
( ) ( ).
: 365 ,
12 . - : Print .
, : , , . 2R, R - .

4.11.
, . -.
- ? , . , , , . -- ?
, : - , .
- , .

58

5.

() Visual Basic :

If

If

Select Case
Visual Basic .

5.1. ()
: , ,
, ? , , . .
. , . , 3000 3200 . ,
3000, , 3200 - . , , .
, () , . :
1.
2.
3.
4.

.
< 3000, .
> 3200, .
.

2,3 - . , ,
- . : , , - , ,
, - .. - < 3000 > 3200.
,
:
1. ", - , ?"
2. .
3. "" "", "
!", " !"
4. " - ?"
5. .
6. . . . . . . . . . . . . . .
.............
( ,
, ).
. , .
? .
, ( , )
().

5.2. If

, Visual Basic.
:
If
""
""
Then
""
""
Else
""
""
:

59

If

a=28

Then

Print f

Else

k=44

a=28

f
k 44.
, , , a=28 , , Print f , k=44 . , , , , ( ).
, If ,
- . , If. If,
.
1. - 167 121. 2000,
, .
.
:
Dim a As Integer
Dim b As Integer
Dim y As Integer
Private Sub Form_Load()
a = 167
b = 121
y=a*b
If y > 20000 Then Debug.Print " " _
Else Debug.Print " "
Debug.Print y
End Sub
: 5 , Debug.Print y. 5 ,
.
. , If y > 20000 Then Debug.Print " " , Debug.Print y.
a = 167 a = 1 . ,
If y > 20000 Then Debug.Print " " , Debug.Print
y.
2. - .
- .
a1 - , a2 - , bol - , V - .
:
1

Dim a1 As Double
Dim a2 As Double
Private Sub Command1_Click()
a1 = InputBox(" ")
a2 = InputBox(" ")
If a1 > a2 Then Debug.Print a1 * a1 * a1 Else Debug.Print a2 * a2 * a2
End Sub
Dim a1 As Double
Dim a2 As Double
Dim V As Double
Private Sub Command1_Click()
a1 = InputBox(" ")
a2 = InputBox(" ")
If a1 > a2 Then V = a1 * a1 * a1 Else V = a2 * a2 * a2
Debug.Print V
End Sub
Dim a1 As Double
Dim a2 As Double
Dim bol As Double
Private Sub Command1_Click()
a1 = InputBox(" ")
a2 = InputBox(" ")
If a1 > a2 Then bol = a1 Else bol = a2
Debug.Print bol * bol * bol
End Sub

. ,
. -
. , .

60
, , if , - , .
If Else. , If s<t Then w=a+1. , s<t, w=a+1, , .
: . .
, "", "".
-"":
Dim Slovo As String
Private Sub Command1_Click()
Slovo = InputBox(" ")
If Slovo = "" Then Slovo = ""
Debug.Print Slovo
End Sub
Then Else . ?
: a 4, b=3 Print b, - b=0, a=b+5 =0.
, :
If a <> 4 Then b=3 : Print b Else b=0 : a=b+5 : =0
, Then Else , .

5.3. If
Visual Basic , Visual
Basic . , ,
, . , . . . ,
, , .
, , , , , , , , , , . Visual Basic
.
Visual Basic If: .
If . :
If

Then

Else

? , , , ,
. , , . , , , . , .

Visual Basic ,

>
>=
=
<
<=
<>
:

Print b
a=b+5
5*a+4 <= a*b
5*a+4
a*b
<=

If 5*a+4 <= a*b Then Print b Else a=b+5


- ,
- ,
- ,
- ,
- ,
- .

5.2 , If .
:
If

Then

, , . . . :
If:

61

If

Then

[ Else ]

, , .
: , If, Visual Basic . , - b=6 : If b+1>0 Then s=20 - b 6,
7. Print. : b=6 : Print b+1 . b 6, 7. , .

If:

a=10
If a>2 Then Print "!!!" Else Print "!"
a=4
If a>5 Then a=a+10 Else a=a-1
Print a
s=6
If s-8<>0 Then s=s+10
Print s
s=6
If s<0 Then s=s+10
s=s+1
Print s

!!!
3

16

15-17:
, :
15. k=20: k=k+10: If k+10<>30 Then k=8 Else k=k-1
Print k
16. k=20: k=k+10: If k+10 = 30 Then k=8 Else k=k-1
Print k
17. p=1: If p>0 Then p=p+5
If p>6 Then p=p+1
Print p

18-20:
18. . , , - .
.
19. . , ,
, .
: . : , . 26 5.7.
20. , , 100 - .
, N ?
, If, ,
. , , , . :
Private Sub Command1_Click()
If Form1.BackColor = vbRed Then MsgBox ("") Else MsgBox ("")
End Sub

21:

, 200 .

5.4.
, , . .
:
Private Sub Command1_Click()
p = Rnd
Debug.Print p
End Sub
: 0,7055475. 0 1. Rnd.

62
. :
0,7055475
0,533424
0,5795186
0,2895625
0,301948
. :
0,7055475
0,533424
0,5795186
0,2895625
0,301948
, , . -, , . ? Randomize:
Private Sub Command1_Click()
Randomize
p = Rnd
Debug.Print p
End Sub
.
0 20? - p = 20 * Rnd. 6 7? - p = 6 + Rnd.
200 210? - p = 200 + 10 * Rnd.
200 210? - p = Int(200 + 11 * Rnd). ,
11, 10. , :
Private Sub Command1_Click()
t = 200 + 11 * Rnd
p = Int(t)
Debug.Print t, p
End Sub
, t p, , , .

22: " ".


. .
, . , 1 . (
, . ,
. k=k+1.) :
, - Left Top.
, "" . : , , - Form1.Width * Rnd. ,
. .
23: " ". . - 0 1. - . - "" " ". , 100 80.
? ! !
: 0 1. ,
200 210.

5.5. If
: a 4, b=3 Print b, - b=0,
a=b+5 =0. If, :
If a <> 4 Then b=3 : Print b Else b=0 : a=b+5 : =0
, Then Else ,
. , .
( ) If. :
If a <> 4 Then
b=3
Print b
Else
b=0
a=b+5

=0
End If
End If , If .
Else . ,

63
If a <> 4 Then
b=3
Print b
End If
If , .
.
: a.

a<0, " ".

a=0, " ".

a>100, " ".

, .
" ".
:
Private Sub Command1_Click()
a = InputBox(" ")
If a < 0 Then
MsgBox (" ")
ElseIf a = 0 Then
MsgBox (" ")
ElseIf a > 100 Then
MsgBox (" ")
Else
Print a ^ 2
End If
MsgBox (" !")
End Sub
ElseIf - " ". : a < 0, . a = 0, a > 100,

If : (a < 0). , Visual Basic (a = 0) . , , Visual Basic , Then , , . , Visual Basic , Else.
If:

If Then

.
[ ElseIf Then

. ]
..
[ Else

. ]
End If

ElseIf . Else, , .
, , , If,
, :

If Then ElseIf
( ) Then, ElseIf , , :

If
Then
ElseIf

24: , , :
- "", - "", - "Hi", - "". , , .
25: , 4.9. , , . 17, : "
?" , " ". 17, -

64
- " ?" " ". , , : " !".

5.6.
- - , .
, . - , , .
Private Sub Command1_Click()
a = InputBox(" ")
If a > 4 Then
b=3
Print b
Else
b=0
a=b+5

=0
End If
b=5
MsgBox (" !")
End Sub
. , : =, If,
b= MsgBox. , , .
, ( - If),
. , b=0, a=b+5 =0 If , , If.
, , , , , , . , , , , . , ,
. , , , .
, . , , :
a=0: b=0: c=0: f=4
.

5.7. If.

. . .

If
If, Then Else Visual Basic, If.
: ( - ).
28 30, , - .
: . 28, , . ? : 30, , .
:
Private Sub Command1_Click()
a = InputBox(" ")
If a < 28 Then
MsgBox (" ")
Else
If a < 30 Then MsgBox ("") Else MsgBox (" ")
End If
End Sub
If a < 30 If a < 28. , .
If:
Private Sub Command1_Click()
a = InputBox(" ")
If a < 28 Then
MsgBox (" ")
ElseIf a < 30 Then
MsgBox ("")

65
Else
MsgBox (" ")
End If
End Sub

26: 19 5.3: .
, , .
: .


If , . Visual Basic
, If If.
. , .
" ". - . . , , , , 140
. .
:
Dim Tsvet As String
'
Dim Rost As Integer:
'
Private Sub Command1_Click()
Tsvet = InputBox(" ?")
Rost = InputBox(" ")
If Tsvet = "" And Rost < 140 Then Print " " Else Print " "
End Sub
, If , , ,
, And ( ""). If -
140 , , .
And, , ,
.
If , , . . , And - .
- :
Private Sub Command1_Click()
a = InputBox(" ")
If a > 28 And a < 30 Then MsgBox ("") Else MsgBox (" ")
End Sub
" ". .
:
If Tsvet ="" Or Rost<140
' <140
Or "".
, Or , ,
.
If . .
And Or . :
If a>2 Or x=b Or c<>1 Then k=99 Else k=33
k=99, , , k=33.
And Or Not ( "").

a>b Then... - , a b, .... :


a=2: b=3: If Not a>b Then k=1 Else k=0
k=1, , 2>3.

a>b

If Not

66

a > 28 And a < 30


Tsvet ="" Or Rost<140
a>2 Or x=b Or c<>1
, , .
. , , True (). , , False (). If.
- And, Or, Not. , :
a>2 And Not b>3 Or s>8
, . , . Not, And, Or.
:
(a>2 And (Not b>3)) Or s>8
.
:
a>2 And Not (b>3 Or s>8)
:

a=8:
a=8:
a=8:
a=8:

27:
If

b=6:
b=6:
b=6:
b=6:

If a>b And b>7


If a>b Or b>7
If a<b Or b>7
If
Not a=8

Then k=1
Then k=1
Then k=1
Then k=1

Else k=0
Else k=0
Else k=0
Else k=0

k=0
k=1
k=0
k=0

" ". , , :

Tsvet ="" And (Rost<180 Or Rost>184) Then Print " " Else Print " "

28: - : .
28 30, , 30 - ,
0 28, , - .
29:
, - . . :

5.8. Select Case


, . " " , , . , ,
: , , . , If:
Dim Otmetka As Integer
Private Sub Command1_Click()
Otmetka = InputBox(" ?")
If Otmetka = 1 Or Otmetka = 2 Then
Print "!"
ElseIf Otmetka = 3 Then
Print ""
ElseIf Otmetka = 4 Then
Print ""
ElseIf Otmetka = 5 Then
Print "!"
Else
Print " "
End If

67
End Sub
Otmetka, ,
. , , (-):

1, 2
"!"
3
""
4
""
5
"!"

" "

Select Case, . -:
Dim Otmetka As Integer
Private Sub Command1_Click()
Otmetka = InputBox(" ?")
Select Case Otmetka
Case 1, 2
Print "!"
Case 3
Print ""
Case 4
Print ""
Case 5
Print "!"
Case Else
Print " "
End Select
End Sub
Select Case , If. Otmetka , . , , . Select Case .
, , Else (
, 6).
Select Case , . :
Private Sub Command1_Click()
a=3
Select Case a * a + 1
Case 8, 4 * a, 26
k=0
Print k
Print a
Case 7, 10, 84 To 90
k=1
Print k
Case Is < 0, 2, 4, 12 To 18 + a, 44, 68, Is > 100 + a
k=3
End Select
End Sub
1. :
-, Select Case , ,
10, 3*3+1. , , , - 4 * a.
-, , .
- - 84 To 90. , 84,85,86,87,88,89,90, .
- - Is < 0. Is a*a+1 . , Select Case , .
-, Else. , a=3 a=0, Select Case, , , Else,
, .
Select Case If? If , Select Case? - If , Select Case a*a+1.

68
Select Case:

Select Case
[Case ,
[

...]]
[Case ,
[

...]]
..
[Case Else
[

...]]
End Select

- :
-
- To
- Is
, . :
Private Sub Command1_Click()
a = ""
Select Case a
Case ""
k=3
Print a
Case ""
k=0
Print k
End Select
End Sub
0.

30: . ,
- , , - ( ).
31: ,
4.9. .
Select Case
. , , .

5.9. .
.
, .


, 4.5
Dim 1 As Double
', 1
Dim 2 As Double
', 2
Dim As Double
'-,
_____________________________________________________________________________
Private Sub __Click()
1 = 1.Text
'
2 = 2.Text
= 1 + 2
'
.Text =
'
End Sub
..

69
- , , -. . Visual Basic "Type mismatch" - 1 . .
- , Visual Basic
? , -
, . , ,
, , , ? , ? , , ? , . , , ? " !" - .
, , . , Visual Basic , ,
, -, .
Visual Basic . . ? , , , , . IsNumeric. , . , , , ( ), True,
"", - False, "". :
Debug.Print IsNumeric("-") False.
Debug.Print IsNumeric("-67,3") True.
, IsNumeric If.
,

If IsNumeric("-67,3") Then MsgBox (" ") Else MsgBox (" ")


: " -67,3 - , " If IsNumeric("-67,3") = True Then .
: 1 2 , , , " ".
:
Private Sub __Click()
If IsNumeric(1) And IsNumeric(2) Then
1 = 1.Text
2 = 2.Text
.Text = 1 + 2
Else
MsgBox (" ")
End If
End Sub
. , .
.


, Visual Basic, . ,
,

.Text = 1 / 2
:

If 2 <> 0 Then .Text = 1 / 2 Else MsgBox (" ")


:
Private Sub __Click()
If IsNumeric(1) And IsNumeric(2) Then
1 = 1.Text
2 = 2.Text
If 2 <> 0 Then .Text = 1 / 2 Else MsgBox (" ")
Else
MsgBox (" ")
End If
End Sub
, If .


. .
.
- , ,
. , .
,
Form_Load, . ,
, "".
Dim Parol As String
'-

70
Private Sub Form_Load()
Parol = InputBox(" ")
If Parol <> "" Then MsgBox (" !"): End
End Sub
End - .
, .
, :
Private Sub Form_Load()
If InputBox(" ") <> "" Then MsgBox (" !"): End
End Sub
, , - : -, - - .. , , .
: . . , , 2.13.
, , .
- .

Text1.PasswordChar = "*"

5.10. MsgBox
2.10 , MsgBox.
MsgBox. , ,
, . , :

y = MsgBox("!")
,

MsgBox("!")

, , , y . , .
: Visual Basic , . , , :

Yes , No .
:
Private Sub Command1_Click()
Text1.Text = 2 * 2
y = MsgBox (" ?", vbQuestion + vbYesNo, " ")
If y = vbYes Then Text1.FontSize = 20
End Sub
: . vbQuestion , - . vbYesNo Yes No. , , , , . Yes MsgBox vbYes. No MsgBox vbNo.

If y = vbYes
: " Yes "
: VbCritical, vbQuestion, vbExclamation, vbInformation.
: VbOKOnly, vbOKCancel, vbAbortRetryIgnore, vbYesNoCancel,
vbYesNo, vbRetryCancel.
MsgBox : vbOK, vbCancel, vbAbort, vbRetry,

71
vbIgnore, vbYes, vbNo.
. - , .
, ,
. , , :
OK - , Cancel - , Abort -
(, "
"), Retry - , Ignore - , , Yes-No - , .

72

6.

. .
. , , . - ?
, . , , , , , -,
- , .
, . . :
1.
2.
3.
4.
5.

.
.
.
.
2.

. ,
, . , 2, 3, , 2. , ,
, 5. -
: 1-2-3-4-5-2-3-4-5-2-3-.
, 2-3-4-5. . , - .
2 3 , , .
, , , .
, . .

6.1. GoTo. .
, Visual Basic. , , :
Debug.Print " ";
Debug.Print " ";
Debug.Print "";
Debug.Print "
";
Immediate :

. . . .

Visual Basic -, :
m1:
Debug.Print " " ;
Debug.Print " " ;
Debug.Print "" ;
Debug.Print "
";
, m1
"" , Debug.Print " " , Debug.Print " " ,
m1.
Visual Basic:
Private Sub Command1_Click()
m1: Debug.Print " ";
Debug.Print " ";
Debug.Print "";
Debug.Print "
";
GoTo m1
End Sub
GoTo - , " ",
m1 - .
- . GoTo

73
,
. , , , - . (, -
).
. , Immediate. , F8 .
. ( ),
? , , , , . ,
, . , , . ,
. ,
,
, .
, ,
Ctrl-Break. , , Ctrl,
Break. , . Visual Basic
. , ,
. , . , . , .
, , . , De-

bug.Print " " GoTo m1.


:
k=6
a = 100
GoTo 8
a=a+k
k=2*k
Print a
8: a = a + 1
k = k + 10
Print k, a
16

101. :

k=6
a=100
GoTo 8
a=a+1
k=k+10
Print k, a
a=a+k, k=2*k, Print a , , . .

32:

, :

n = 10
k=0
Debug.Print " "
met5: Debug.Print n;
n=n+k
GoTo m1
n=n+1
m1:
Debug.Print ""
k=k+1
GoTo met5
Debug.Print " "
- .
:
:
Private Sub Command1_Click()
n = 200
m1:
Debug.Print n
n=n+5
GoTo m1
End Sub

200 205 210 215 220 225

74

33-35:
:
33. : .....
34. 10000 9999 9998 9997 9996 ......
35. 100 50 25 12.5.... 8 .


. .
Image (). . ( Picture). , , , c:\Program Files\, Visual
Basic\Graphics\Icons.
, :
Dim x As Double
Private Sub Command1_Click()
x = Image1.Left
' ,
m1:
x=x+1
' 1
Image1.Left = x
' , .
GoTo m1
End Sub
, - x = x + 2. , - x =
x + 0.3.
, . , Visual Basic. ,
.

36:

, , .

. .
? ? - 6.2 11.4.

6.2. If
, ? GoTo If.
: :
3 5 7 9 11 13 15 .. 329 331 333
- :
3 5 7 9
, ,
, .
4 . , . 4
, , - . ,
.
4 4 (
, ):
1

(Do . Loop While)

Private Sub Command1_Click()


Debug.Print " ";
f=3
m: Debug.Print f;
f=f+2
If f <= 9 Then GoTo m
Debug.Print " "
End Sub

(Do . Loop Until)

Private Sub Command2_Click()


Debug.Print " ";
f=3
m1: Debug.Print f;
f=f+2
If f > 9 Then GoTo m2 Else GoTo m1
m2: Debug.Print " "
End Sub

:
Debug.Print " "
f=3
Debug.Print f { 3}
f=f+2 {f 5}
If f<=9 Then GoTo
m
Debug.Print f {. 5}
f=f+2 {f = 7}
If f<=9 Then GoTo m
Debug.Print f {. 7}
f=f+2 {f = 9}
If f<=9 Then
GoTo m
Debug.Print f {. 9}
f=f+2 {f = 11}
If f<=9 Then GoTo m
Debug.Print " "
GoTo m . f<=9 -

75
GoTo m, If Debug.Print " ", .
3

(Do While . Loop)

Private Sub Command3_Click()


Debug.Print " ";
f=3
m1: If f <= 9 Then GoTo m3 Else GoTo m2
m3: Debug.Print f;
f=f+2
GoTo m1
m2: Debug.Print " "
End Sub
: - 1 1001
:
Private Sub Command1_Click()
f=1
m: s = f + 1000
Debug.Print f; s
f=f+1
If f <= 100 Then GoTo m
End Sub

(Do Until . Loop)

Private Sub Command4_Click()


Debug.Print " ";
f=3
m1: If f > 9 Then GoTo m2 Else GoTo m3
m3: Debug.Print f;
f=f+2
GoTo m1
m2: Debug.Print " "
End Sub
2 1002

3 1003

..

100 1100.

37-41:
37. . 1 2 3 4 . . . 99 100
. 100 99 . . . 3 2 1.
. 1 2 3 4 . . . 99 100 99 . . . 3 2 1.
38. " " " " ( , , , , ).
6 0.000 0.001 0.002 0.003 . . . 0.999 1.000.
39. =2700, 900, 300, 100 . . . .. y=x/4 + 20 z=2y+0.23 , yz
1/.
40. , 6.1, .
41. , , , ,

6.3. Do
, -
, GoTo. , , , . GoTo
" ", , . , GoTo , .
Visual Basic 2 : Do For. Do 5 :
0
1
2
3
4
Do . Loop

Do . Loop While

Do . Loop Until

Do While . Loop

Do Until . Loop

For 2 . - .

Do . Loop
0 Do 3 5 7 9
. , Do,
1 .
, .
1
Private Sub Command1_Click()
Debug.Print " ";
f=3
m:

0 Do
Private Sub Command0_Click()
Debug.Print " ";
f=3
Do

76
Debug.Print f;
f=f+2
GoTo m

Debug.Print f;
f=f+2
Loop

End Sub

End Sub

Do , "", .
Loop , "" " ", : " Do ".
, Do m, Loop
GoTo m. 3 5 7 9 11 .. . 0 Do ().
Do . Loop:

Do

.
Loop

Do Loop .

Do . Loop While
4 Do 1 - 4, . , 4 . , 4 , . , .
1 Do 3 5 7 9
. , Do, 1
. ,
.
1

1 Do

Private Sub Command1_Click()


Debug.Print " ";
f=3
m:
Debug.Print f;
f=f+2
If f <= 9 Then GoTo m
Debug.Print " "
End Sub

Private Sub Command5_Click()


Debug.Print " ";
f=3
Do
Debug.Print f;
f=f+2
Loop While f <= 9
Debug.Print " "
End Sub

While "".
, Loop While f <= 9 : " Do, f <= 9".
, Do m,

Loop While f <= 9 If f <= 9 Then GoTo m.


Do . Loop While:

Do

.
Loop While

Do . Loop Until
2
Private Sub Command2_Click()
Debug.Print " ";
f=3
m1:
Debug.Print f;
f=f+2

2 Do
Private Sub Command6_Click()
Debug.Print " ";
f=3
Do
Debug.Print f;
f=f+2

77
If f > 9 Then GoTo m2 Else GoTo m1
m2: Debug.Print " "
End Sub

Loop Until f > 9


Debug.Print " "
End Sub

Until " , ".


, Loop Until f > 9 : " Do , f > 9".
Do . Loop Until:

Do

.
Loop Until

Do While . Loop
3

3 Do

Private Sub Command3_Click()


Debug.Print " ";
f=3
m1: If f <= 9 Then GoTo m3 Else GoTo m2
m3: Debug.Print f;
f=f+2
GoTo m1
m2: Debug.Print " "
End Sub

Private Sub Command7_Click()


Debug.Print " ";
f=3
Do While f <= 9
Debug.Print f;
f=f+2
Loop
Debug.Print " "
End Sub

Do While f <= 9 : " f <= 9 Loop".


Do While . Loop:

Do While

.
Loop

Do Until . Loop
4
Private Sub Command4_Click()
Debug.Print " ";
f=3
m1: If f > 9 Then GoTo m2 Else GoTo m3
m3: Debug.Print f;
f=f+2
GoTo m1
m2: Debug.Print " "
End Sub

4 Do
Private Sub Command8_Click()
Debug.Print " ";
f=3
Do Until f > 9
Debug.Print f;
f=f+2
Loop
Debug.Print " "
End Sub

Do Until f > 9 : " Loop, , f > 9".


Do Until . Loop:

Do Until

.
Loop

78

. ,
While f<=9 While f<9 , , , , .
. While f<9
.
: , ,
. , "". , " " .
, . Slovo. Do, 2-, :
Dim Slovo As String
Private Sub Command1_Click()
Do
Slovo = InputBox(" ")
Debug.Print Slovo; "!"
Loop Until Slovo = ""
Debug.Print " "
End Sub

42: . .
43-44: Do 38 41 .
45: 100- v=20/,
s s=vt, t . h
h=100 9.81t2/2. t, s h t = 0, 0.2, 0.4, 0.6 ,
.

Do
:

While Until. . , , (f <= 9) (f > 9)?

, - Do Loop. ,
. ,
f=3
Do Until f > 0
Debug.Print f;
f=f+2
Loop
, , , .
, .

Exit Do
Exit Do , , , .
:
Private Sub Command2_Click()
Debug.Print " ";
f=3
Do
Debug.Print f;
Exit Do
f=f+2
Loop While f <= 9
Debug.Print " "
End Sub
:
3
Exit Do , :
Private Sub Command1_Click()
Debug.Print " ";
f=3
Do
Debug.Print f;
If f >= 9 Then Exit Do
f=f+2

79
Loop
Debug.Print " "
End Sub
:
3 5 7 9


While Wend, . , - , :
While

.
Wend
- , Do While . Loop

6.4. For
6.3, For. .
14.3.
, 3 5 7 9, Do 4 . , Do, , . , , .
For.
: 200 .
GoTo. :
metka: Print ""
GoTo metka
, 200 . , GoTo If. , . - , i. :
Private Sub Command1_Click()
i=1
metka: Debug.Print ""
i=i+1
' i 1
If i <= 200 Then GoTo metka
End Sub
i 1, 1.
If, 2<=200 , GoTo metka. 3<=200 .. 199- 200<=200 , GoTo metka. 200- 201<=200 , .
"" - Print "" .
, "" 200 . i, , . .
, For, .
Private Sub Command1_Click()
i=1
m1: Debug.Print ""
i = i + 1:
If i <= 200 Then GoTo m1
End Sub

Private Sub Command2_Click()


For i = 1 To 200
Debug.Print ""
Next i
' i 1
End Sub

, 200 5 i.
For "". To "". For i=1 To 200 : i, 1 200, , Next. Next , i 1 . i 1, - 2, .
- 200. i ,
i ,

For i = 501 To 700

80
: - 101 1000
102 990
. :
Private Sub Command1_Click()
For a = 101 To 110
Debug.Print a;
Debug.Print 1000 - 10 * (a - 101)
Next a
End Sub

103 980

104 970 .

109 920

110 910

1. For Do - . , , (
38 - , 0 1 0.001):
Private Sub Command1_Click()
For a = 0 To 1.00001 Step 0.001
Debug.Print Format(a, "0.000"), Format(a * a, "0.000000")
Next a
End Sub
Step 0.001 " 0.001". . 1
1.00001, 38.
- 1 0,
:

For a = 1 To 0 Step

-0.001

For:

For = 1

..
Next [ ]

To 2

[ Step 3 ]

. Next , , For Next,


, , For Next.
: For j=a+b To 2*s Step k*10
, 1, 1.
1, Step -1.
For ( ) :
1, ( i) . 2 i. i > 2, For , . , For Next. i 3 ( 1) 2. i > 2, For , , i
..

For :
1, ( i) . 2 i. i < 2, For , . , For Next. i 3 2.
i < 2, For , , i
..

Exit For
Exit For - For. Exit Do, 6.3, .

81

46:

For:

: -5 -4 -3 -2 -1 0 1 2 3 4 5 : 5 4 3 2 1 0 -1 -2 -3 -4 -5

6.5.
, :

Do . Loop

For

Goto
, :

(. 11.2)

(. 17.5)

82

7.

, , . .

7.1. . .
, , 1.3.
, Visual Basic , ,
, , .
. , Do Until a>0 Do Antil a>0
, Visual Basic

Expected While or Until or end of statement


While Until
Visual Basic , , , .
Visual Basic , Sqr(-25), -25. :

. , , (-25). , Visual Basic , Debug. Visual Basic .


, Visual Basic , . , , a
1, a=a+1 a=a+2, .

7.2. . . .
4.2 . .
, . ,
. Locals, Watches, Quick Watch, Call Stack Immediate.
Command1_Click :

83

, Immediate :

20
3
18
4
16
5
14
6
12
7
10
8

, , ,

20
3
18
4

, .
Locals. ViewLocals Window ViewImmediate Window Locals Immediate. Locals
. F8 , 4.2. F8 Locals Immediate , . Value "". ,
Locals a b, . Locals . .
Me. .
, , , Locals . , F8,
Shift-F8. .
(Breakpoints). , F8 .
- . , -

84
. Visual Basic - (Breakpoints). , . ( ).

. ( Start F5).
, . F5. . , - .
- Run To Cursor. .
Ctrl-F8. , .
Ctrl-F8. , , , . .

. , , F8, Shift-F8, Ctrl-F8,
F5. Visual Basic .
Debug ().
Watches. , Locals . ,
b=5. , F8.
[run], , b 5, , , . , - ,
. Watches. : DebugAdd Watch. Add Watch, b=5, False,
- True. , Visual Basic
. Watch Type .
, .
.

. b > a. Watches .
. Command1
, b 5, Visual Basic .
. .
Quick Watch. - Quick Watch. . ,
, a - 2. Watches, :
, , DebugQuick Watch. .

85

Call Stack. , . Call Stack,


. : ViewCall Stack.
Immediate , .
:

?a

?backcolor

?text1.Text

a=44
.
, . , ,
, - .
form1.BackColor =255
. , .
Command1_Click

for i=1 to 10 : ?i : next
. 1 10.

86

8.

, , , , . ,
, . , ,
, , .

8.1.
: 40 . , .
.
:
Dlina = InputBox (" ")
'
Shirina = InputBox (" ")
Visota = InputBox (" ")
S = Dlina * Shirina
'
V = S * Visota
'
Debug.Print " ="; S, " ="; V '
40 , For:
Private Sub Command1_Click()
For i = 1 To 40
Dlina = InputBox(" ")
'
Shirina = InputBox(" ")
Visota = InputBox(" ")
S = Dlina * Shirina
'
V = S * Visota
'
Debug.Print " ="; S, " ="; V '
Next i
End Sub
.
,

For i = 1 To 40

N = InputBox(" ?")
For i = 1 To N

47:

N . .

8.2.
20*15*4, 30*20*5 10*5*3. , , N=3 For .
, . ,
V=S*visota V=S+visota, :
=300 =304
=600 =605
=50 =53
For i=1 To N

For i=2 To N :

=300 =1200
=600 =3000
. , 1
2 , 2 3? , , ,
, .

48-49:
, ,
48) For i=1 To N , -

S = Dlina * Shirina

87
49) Debug.Print

Next

, .

8.3.
- , - . ?
, .
1: . ,
.
, :
c=0
'
m: a = InputBox(" ")
If a>0 Then c=c+1
Debug.Print " -" , c
GoTo m
: 6.4 i, .
c. . - c=c+1.
1. If a>0 Then . , c
, . 1 ,
.
.
, ,
. , ?
. .
2: 200 . ,
.
:
Private Sub Command2_Click()
c=0
'
For i = 1 To 200
a = InputBox(" ")
If a > 0 Then c = c + 1
Next i
Debug.Print " -"; c
End Sub
: , . For
200 , . Debug.Print
, ..

50:
1)
2)
3)
4)
5)

,
c=0 c=10.
c=c+1 c=c+2.
Next Debug.Print .
c=0 For .
For InputBox .

. .
3: 200 . ,
.
:
Private Sub Command3_Click()
c_ = 0
'
c_ = 0
'
For i = 1 To 200
a = InputBox(" ")
If a > 0 Then c_ = c_ + 1
If a = 0 Then c_ = c_ + 1
Next i
Debug.Print " -"; c_, " -"; c_
End Sub
, ""? ,
, .
4: . "/". , -

88
"W" ":" .
: W - W, Dv - , i , "/".
:
Private Sub Command4_Click()
Dim i As Integer, cW As Integer, cDv As Integer
Dim procent_W As Integer, procent_Dv As Integer
Dim simvol As String
i = 0: cW = 0: cDv = 0
'
Do
simvol = InputBox(" ")
If simvol <> "/" Then i = i + 1
' /, ""
Select Case simvol
Case "W"
' W,
cW = cW + 1
' W
Case ":"
' : ,
cDv = cDv + 1
' :
Case "/"
' /,
Exit Do
'
End Select
Loop
procent_W = Round(100 * cW / i)
' W
procent_Dv = Round(100 * cDv / i)
' :
Debug.Print procent_W, procent_Dv
End Sub

51: N . , ,
10.
52: . , , 13.
.

8.4.
- , -. ?
, , .
, . ,
:
s=0
' . ,
m: a = InputBox(" ")
s=s+a
'
Debug.Print "="; s
GoTo m
s a, . , 1 c=c+1, - s=s+a.
: N . .
:
Private Sub Command2_Click()
N = InputBox(" ?")
s=0
For i = 1 To N
a = InputBox(" ")
s=s+a
Next i
Debug.Print " "; s
End Sub

53:
1)
2)
3)
4)
5)

N=2, a=5 3. Visual Basic 8. , :


s=0 s=10.
s=s+a s=s+a+1.
Next Debug.Print .
s=0 For .
For InputBox .

89
6)
7)

s=s+a Next .
For i=1 To N For i=2 To N.

54-56: :
54) 40 . . .
55) .
56) N . : , - ,
(?), .

8.5.
Visual Basic , . 6.3, .
, .
, :
Private Sub Command1_Click()
For i = 1 To 5
a=9
If i * i = a Then
For k = 5 To 8
Debug.Print k;
Next k
Else
Debug.Print 1997
End If
Next i
End Sub
For i = 1 To 5 If i * i = a , For k = 5 To 8.
:
1997
1997
5 6 7 8 1997
1997

8.6.
- .
- . :
1*1= 1 1*2=
2*1= 2 2*2=
3*1= 3 3*2=
4*1= 4 4*2=
5*1= 5 5*2=
6*1= 6 6*2=
7*1= 7 7*2=
8*1= 8 8*2=
9*1= 9 9*2=
10*1= 10 10*2=

2
4
6
8
10
12
14
16
18
20

1*3=
2*3=
3*3=
4*3=
5*3=
6*3=
7*3=
8*3=
9*3=
10*3=

3
6
9
12
15
18
21
24
27
30

1*4=
2*4=
3*4=
4*4=
5*4=
6*4=
7*4=
8*4=
9*4=
10*4=

4
8
12
16
20
24
28
32
36
40

1*5=
2*5=
3*5=
4*5=
5*5=
6*5=
7*5=
8*5=
9*5=
10*5=

5 1*6=
10 2*6=
15 3*6=
20 4*6=
25 5*6=
30 6*6=
35 7*6=
40 8*6=
45 9*6=
50 10*6=

-
1*1=1

:
1
a=1
b=1
proizv = a * b
Print a, "*" ,b, "=" ,proizv
Print 5 :
*
a,
*
"*",
*
b,
*
"=",
*
proizv

6
12
18
24
30
36
42
48
54
60

1*7=
2*7=
3*7=
4*7=
5*7=
6*7=
7*7=
8*7=
9*7=
10*7=

7
14
21
28
35
42
49
56
63
70

1*8=
2*8=
3*8=
4*8=
5*8=
6*8=
7*8=
8*8=
9*8=
10*8=

8 1*9=
16 2*9=
24 3*9=
32 4*9=
40 5*9=
48 6*9=
56 7*9=
64 8*9=
72 9*9=
80 10*9=

9 1*10= 10
18 2*10= 20
27 3*10= 30
36 4*10= 40
45 5*10= 50
54 6*10= 60
63 7*10= 70
72 8*10= 80
81 9*10= 90
90 10*10= 100

90

. :
1*1=

1 1*2=

2 1*3=

3 1*4=

4 1*5=

5 1*6=

6 1*7=

7 1*8=

8 1*9=

1*10= 10

, 9 ,
1. . ,
9 1, b=1 . For:
2
a=1
For b = 1 To 10
proizv = a * b
Print a; "*"; b; "="; proizv;
Next b
.
- - , . 2
9 , - a. , 2 For
, 1.
3
For a = 1 To 10
For b = 1 To 10
proizv = a * b
Print a; "*"; b; "="; proizv;
Next b
Next a
, 9 4.
, , . Print, :
4
For a = 1 To 10
For b = 1 To 10
proizv = a * b
Print a; "*"; b; "="; proizv;
Next b
Print
Next a
. , Print ,
.
4 . . . Print , . 14 . ( Font) Courier,
.
, , , , . 10 , - 100 ,
10 .

57:
1)

- 3 8, - 0
7. , 36, 44, 80.

2)

, 1,2,3. ,
2123, 3312, 1111.
.

3)
4)

, , - 1123, 1223, 2222 .., 3322. .

8.7.
: .
: .
: . . , . , , ,
, .

91
: , ,
max. . ( chislo)
max. , max .
10 :
Private Sub Command1_Click()
Max = InputBox(" ")
' -
For i = 2 To 10
' :
chislo = InputBox(" ") '
If chislo > Max Then Max = chislo
' , ,
Next i
Debug.Print Max
'
End Sub

58: N . ? : .
59: . , , 40 .?

92

9.
, .
Visual Basic. , , , , , , , , , - .. .. , ( ) , Visual Basic .
, .

9.1. . , ,
, , . , Form1 BackColor ( ), Label8 Caption (). Command2 Caption, .
- Label8.Caption, Command2.Caption, Text1.Width.
? .
.
, - , . , , ,
, . . , . Command1_Click, , Form_Load Form_Terminate. ,
, - , . ,
.
Visual Basic . ,
- , Object Browser (" " - View):

Object Browser ,
Toolbox. ( CommandButton) - , . , - - ( Caption). ,
, - .
( Click) - Object Browser .
, Object Browser , , , .
?
, .
. - - ,
. 1.2. : , , ..
: , , - ,
- , , ,
. : , ..
Visual Basic SetFocus. , , -

93
. . . , ,
, . , , , , , , "" . ,
. , , - ,
. , . ,
.
, , : GotFocus,
, LostFocus, .
:
Private Sub Text1_GotFocus()
Debug.Print "Text1 "
End Sub
Private Sub Text2_GotFocus()
Debug.Print "Text2 "
End Sub
Private Sub Text1_LostFocus()
Debug.Print "Text1 "
End Sub
Private Sub Text2_LostFocus()
Debug.Print "Text2 "
End Sub
. , Immediate .
. :
Private Sub Command1_Click()
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Text2.SetFocus
End Sub
. Command1. , , Command1,
Text1. Text1.SetFocus, - "
Text1". Command2. Text2. SetFocus
. - .
SetFocus. , . , .
- Print. , ,
. PictureBox ( Picture1) Picture1.Print
"Hello!". , .
, Print, , . . , Width = 5000 , - .
, Object Browser? , , . , ,
. , ,
, .

9.2.
Visual Basic :

Visual Basic, - , ,
. , Visual Basic,
, 2

Toolbox : Line (), ,


, Shape (), , , . , , , ", , , ".

, PictureBox ,
, , , , , ,
, , , . . , , .
, .

94
, , , ,
. .

9.3. - Visual Basic

Visual Basic.
, Picture:

- ,

- LoadPicture. ,

Form1.Picture = LoadPicture("C:\TEMP\Rockies.bmp")
. 2
, Picture, ""
:

Image4.Picture = Form1.Picture
:

Picture .

Form1.Picture = LoadPicture("")


Visual Basic 6.0 ( ) :


.BMP,
.DIB
.
.ICO
(, ) -
.CUR
-
.WMF, .EMF
Windows -
.GIF
,
.JPG, .JPEG
( , ),
? Graphics, , Visual Basic. - Clipart Microsoft Office. Windows .bmp. JPG C:\Program Files\Plus!\Themes. Windows , , - . , , , . .
3-4 , JPG - 30-40. ,
.


, .
. . ,
- , , - .
. , .
PictureBox. .
, , . ? . , , AutoSize, , True, PictureBox . ( , , ?) :

Picture1.AutoSize=False

Picture2.AutoSize=True

95

PictureBox ( , !) .
Image. . ,
Strech False, , Image . ? . Strech
True, Image, . , . :

Image2.Strech=True

Image1.Strech=False

, Strech - , "" - Image Image.


- CommandButton.
Style Graphical, . Picture , , - DownPicture. , , , .

60: . , , - , - . : " , ". , .


: CommandButton, - , , .
. Image! Image Click! Image . Image
Image .
, : ,
. , : ,
( , , ). , ( ), , - ,
, . , .
, , .
, . , 2.6.
:

Image, , .

Image . - , . . - ,
.

, "". ( , .)

Image , "" .

, , ,
. ,
Image, , Image ,
Image.

, , , .
.
, - ,
. , Visible Image. .

96


, Visual Basic , . ,
. ,
.
PictureBox , (, - ).

9.4. - Line Shape


Visual Basic.
Toolbox Line () . .
.
:

BorderWidth

BorderColor

BorderStyle
(, ..). = 1.
X1, Y1, X2, Y2

Toolbox Shape () . .
, (), , ,
Shape (-, ). :

BorderWidth

BorderColor

BorderStyle
(, ..). = 1.
. , - .
, , , .
. , -
. - , .
BackStyle, - BackColor. .
FillStyle, - FillColor. .
, , BackStyle Transparent.

9.5. . ZOrder
, . , , Image ( ), PictureBox ( ), , , .
? , ?
.

97


.
- ,
.
Line, Shape, Image, .
PictureBox.
:

- FormatOrder
: Bring to Front ( ) Send to Back ( ).

- ZOrder. , , :

Text1.ZOrder (0)
:

Text1.ZOrder (1)

9.6. Visual Basic


- Visual Basic:

. Palette .

Form1.BackColor = vbRed. 8 , :
vbBlack

vbRed

vbGreen

vbYellow

vbBlue

vbMagenta
( )
vbCyan
( )
vbWhite

Visual Basic 16 ( - 16777216)! .


. , 0 16777215. ,

Form1.BackColor = 12456743
- , .
: , ,
(Red), (Green) (Blue) . Visual Basic 0 255 . RGB ( - ). ,
100 , 200 50 .
:

Form1.BackColor = RGB(100, 200, 50)


, , - :
RGB(70, 90, 88)
( )
RGB(210, 250, 202)
( )
RGB(0, 0, 0)

98
RGB(255, 255, 255)

, :
RGB(90, 90, 90)
-
RGB(220, 220, 220)
-
RGB(255, 255, 0)

RGB , . , . -,
, Visual Basic , .


. . ? ,
- , :
&H0080C0FF&
, , 16 .
, :
&H00
80
C0
FF
&
- -
-




. ,
- , .
, 10 (0, 1, 2, , 9), 16
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). , ,
.
, 16- , , 7 , ,
, , 7. , A , , , ,
10. , F , , 15.
47, , 4
7.
16- 16- 29, , 2 9. 41. , 16- 29 10- 41.
16- 16- AE, , A ( 10 ) ( 14). 174. , 16- AE 10- 174.
16- - FF. , 255 10- . ,
Visual Basic 16- .
.
16- .
, , , 0
16777215. , 10- 16-,
16- , , . , :

Form1.BackColor = B * 256 * 256 + G * 256 + R


B, G, R - , , RGB. , , ,
, 256- ?

9.7. 3 -
Visual Basic.
: PictureBox. , ,
Print, .
, , , ,
:

99

1000

2000

3000

4000

5000

6000

1000

2000

3000

4000

:
Private Sub Command1_Click()
PSet (1000, 2000)
Line (2000, 1000)-(5000, 3000)
Line (3000, 3000)-(1000, 4000) , , B
Circle (4000, 2000) , 1000
End Sub

'
'
'
'

: ( ).
, , . , . Picture1.Line, PictureBox.
PSet. - , - , - .
, , .
Line. , ,
. - . - (
), - .
, , . Line B .
, . Circle,
- , - .
.
Print, Visual Basic ( , ,
):

PSet

Line

Circle
, , ,
Cls

Point
,
PaintPicture


, , . . , .
, :

. .

( , ).

( ).
.

,
( , ):

DrawWidth

100
ForeColor
DrawStyle
FillStyle
FillColor
AutoRedraw
DrawMode


(, ..). = 1.
() .

, , , .
. = 13 (Copy Pen),
. .

:
PSet (1000, 2000)
Circle (4000, 2000), 1000

' - ,
' - ,

DrawWidth = 20
ForeColor = RGB(230, 250, 100)

'
'

PSet (1000, 5000)


Circle (4000, 5000), 1000

' - ,
' - ,

61:

Times:

Pset
, . ,
.

PSet (1000, 2000)

=1000, =2000. ForeColor


PSet (1000, 2000), vbRed

, :

PSet (x+200 , y) ,

RGB(5+a, 90, 80) + 100

, , ,
, , , , .
PSet:

PSet ( x , y ) ,

, - .
, , . - .
Step.

Line
:

Line (2000, 1000)-(5000, 3000)

(2000, 1000) -

101
(5000, 3000).


,
. ForeColor,
, ,
F B BF.
:

F, , .

F, FillStyle FillColor.
. Visual Basic -
- , , , .
Line (2000, 1000)-(5000, 3000) , vbRed
Line (2000, 1000)-(5000, 3000) , vbRed , B
Line (2000, 1000)-(5000, 3000) , vbRed , BF
Line (2000, 1000)-(5000, 3000) , , B

Line:

Line ( x1, 1 ) - ( x2, y2 ) , ,

B | BF

, - .
| "". , B BF.

Circle
:

Circle (4000, 2000) , 1000


Circle (4000, 2000) , 1000 , vbRed
Circle (4000, 2000) , 1000 , , 1 , 3
Circle (4000, 2000) , 1000 , , -1 , -3
Circle (4000, 2000) , 1000 , , , , 2
Circle (4000, 2000) , 1000 , , , , 1/3
Circle (4000, 2000) , 1000 , , 1 , 3 , 2
Circle (4000, 2000) , 1000 , , -1 , -3 , 2

(4000, 2000) 1000



*
, 1 3 .
, 1 3 .

( - ) (4000, 2000). 1000 2
(4000, 2000). 1000 3

Circle:

Circle ( x_ , y_ ) , , , _ , _ ,

, - .

CurrentX, CurrentY, Step


Visual Basic CurrentX, CurrentY, . Line , ,
Circle - . PSet .
Print , , .
Debug.Print CurrentX, CurrentY.
Step.
: : (500, 1000), .
179 40 .
, :
PSet (500, 1000)
PSet (679, 960)
PSet (858, 920)
. , :
PSet
(500, 1000)
PSet Step(179, -40)
PSet Step(179, -40)
*

, , , 180/ , =3.14

102
Step.
, , CurrentX, CurrentY. - , - .
, :
Circle (2000, 2000), 1000
Line Step(900, 0)-Step(-900, -900)

Cls
. :
Circle (2000, 2000), 1000
Print 12345
Cls
Line Step(900, 0)-Step(-900, -900)

Point
: , .
: - . , ,
. ( , , ,
). Circle (1000, 9000), 100 . :
Private Sub Command1_Click()
Debug.Print Point (1000, 9000)
End Sub
, , 12089756. -, 0 16777215. . , , , , , 9.6.

62:

, .

, .

, .

, . , , . , ,
, ?
, . .
- -
, , .

PaintPicture
: Picture1 Picture2 . Picture2 , , Picture1.

103

Picture1

Picture2

: :

Picture1 . PaintPicture Picture2.Picture, 500, 100, 600, 800, 4500, 1000, 900, 1200
: Picture1 Picture2.Picture, (4500, 1000), - 900, - 1200. (500, 100), - 600, - 800.
PictureBox.

9.8.
, , ,
, - .
Visual Basic , ? :
,
.
: 100 1000 500, 800, 1100, 1400, , 2900.
, 300. , :
Private Sub Command1_Click()
Circle (500, 1000), 100
Circle (800, 1000), 100
Circle (1100, 1000), 100
Circle (1400, 1000), 100
Circle (1700, 1000), 100
Circle (2000, 1000), 100
Circle (2300, 1000), 100
Circle (2600, 1000), 100
Circle (2900, 1000), 100
End Sub

. , 2.
, Visual Basic 9 ,
300.
, , . :
Private Sub Command2_Click()
x = 500
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300
Circle (x, 1000), 100: x = x + 300

104
Circle (x, 1000), 100: x = x + 300
End Sub
x = x + 300 , , .
, , , .
? , . :
Dim x As Long
Private Sub Command3_Click()
x = 500
Do Until x > 2900
Circle (x, 1000), 100
x = x + 300
Loop
End Sub
, , .
x, . 300 ,
2900, , , 2900.0000067 ( 6.4). ,
. -: Do Until x > 2900 Do Until x > 2901.

63: . , ,
, , , .
64: . .
65: . .
. , , . -
- x.
Private Sub Command4_Click()
x = 500
y = 200
Do Until x > 2900
Circle (x, y), 100
x = x + 300
y = y + 200
Loop
End Sub
, R.

66:

" ". -

67: . , , .
68: - " ".
500, - , 10-30 , -. (Yellow). ,
. "" , , ,
. " ".
69:
70:
71:
72:
73:
74:

x, y R, " ".
, , .
.
.
.
.

, Visual Basic: ,
.., :

75: . : . [. ] , , ,
: , - , - .

105

76: "". 62 . .
: . , , , .
77:
78:

.
.

9.9.
Rnd 5.4. .
(, 1000). PSet. ? Rnd.
WidthHeight, 16777216,
:

PSet (Width * Rnd, Height * Rnd), 16777216 * Rnd


1000 :
For i = 1 To 1000
PSet (Width * Rnd, Height * Rnd), 16777216 * Rnd
Next
, (1 2).
, , . , (
), Rnd Randomize.

79:
80:
81:
82:

. .
. 200 .
. .

. , .
, , .

83: . , , - .
- 6000 6000. RGB .
84: .
. : ,
, . ,
. , , ,
, . " ":
For j = 1 To 1000000 : Next
, .

85: " ". ,


, - 68,
, . : Rnd , .

106

10.
, .
1.1, " , ". , , 1.1, - "".
. .

10.1.
: , , .
PictureBox. PictureBox, .
, 9.3. 4 :
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
Picture1.Print , "21.07.2001"
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
Picture1.Print , "28.07.2001"
End Sub
Private Sub Command3_Click()
Picture1.Picture = LoadPicture("c:\temp\Balloons.bmp")
Picture1.Print , "12.08.2001"
End Sub
Private Sub Command4_Click()
Picture1.Picture = LoadPicture("c:\temp\Guitar.bmp")
Picture1.Print , "20.07.2001"
End Sub
, , , ,
, .
: , - . ,
, . :

.
. :
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
' , :
Picture1.Line (100, 100)-(300, 300), vbBlue, B
Picture1.Line (100, 100)-(300, 300), vbBlue
Picture1.Line (100, 300)-(300, 100), vbBlue
Picture1.Print , "21.07.2001"
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
' , :
Picture1.Line (100, 100)-(300, 300), vbBlue, B
Picture1.Line (100, 100)-(300, 300), vbBlue
Picture1.Line (100, 300)-(300, 100), vbBlue
Picture1.Print , "28.07.2001"
End Sub
Private Sub Command3_Click()
Picture1.Picture = LoadPicture("c:\temp\Balloons.bmp")

107
' , :
Picture1.Circle (200, 200), 20
Picture1.Circle (200, 200), 70
Picture1.Circle (200, 200), 120
Picture1.Circle (200, 200), 170
Picture1.Print , "12.08.2001"
End Sub
Private Sub Command4_Click()
Picture1.Picture = LoadPicture("c:\temp\Guitar.bmp")
' , :
Picture1.Circle (200, 200), 20
Picture1.Circle (200, 200), 70
Picture1.Circle (200, 200), 120
Picture1.Circle (200, 200), 170
Picture1.Print , "20.07.2001"
End Sub
, - .
, . ,
.
' , :
Picture1.Line (100, 100)-(300, 300), vbBlue, B
Picture1.Line (100, 100)-(300, 300), vbBlue
Picture1.Line (100, 300)-(300, 100), vbBlue

' , :
Picture1.Circle (200, 200), 20
Picture1.Circle (200, 200), 70
Picture1.Circle (200, 200), 120
Picture1.Circle (200, 200), 170
, , .
. , ,

__

__
- ,
. , :
Private Sub __()
'
Picture1.Line (100, 100)-(300, 300), vbBlue, B
Picture1.Line (100, 100)-(300, 300), vbBlue
Picture1.Line (100, 300)-(300, 100), vbBlue
End Sub
Private Sub __()
Picture1.Circle (200, 200), 20
Picture1.Circle (200, 200), 70
Picture1.Circle (200, 200), 120
Picture1.Circle (200, 200), 170
End Sub

'

' :
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
__
Picture1.Print , "21.07.2001"
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
__
Picture1.Print , "28.07.2001"
End Sub
Private Sub Command3_Click()
Picture1.Picture = LoadPicture("c:\temp\Balloons.bmp")
__
Picture1.Print , "12.08.2001"
End Sub
Private Sub Command4_Click()
Picture1.Picture = LoadPicture("c:\temp\Guitar.bmp")
__

108
Picture1.Print , "20.07.2001"
End Sub
: . , . (Private
Sub ), - (End Sub). , ,
, . , "", __ __. __ __
, , , . , Visual Basic __, __ , .
.
! ,
(__) (Command1_Click) , __ ( Print).
, . , - , . " """.
, .
.

__

Call __
. . "Call" "".


- . . :
, :
Private Sub Command1_Click()
Print 1; : A : Print 2; : B : Print 3;
End Sub
Private Sub A()
Print 4;
End Sub
Private Sub B()
Print 5; : C : Print 6;
End Sub
Private Sub C()
Print 7;
End Sub
Command1. .
- . -. F8 , ! - .
:
1 4 2 5 7 6 3
, . " ,
!" - - " ". , . . , : ", ?!"
: .
, , -
. .

86: ,
, , "c:\Windows\Media\Chimes.wav".

10.2. Stop, End Exit Sub


, End

109

Sub, . , Exit Do Exit For , ? .


End Visual Basic , , End
Sub. :
Private Sub Command1_Click()
Print 1;: Print 2;: End: Print 3;
End Sub
1 2. , , End
.
: " , , , ". , Stop. ,
, Start. , .
, :
Private Sub Command1_Click()
Print 1;: Print 2;: Stop: End: Print 3;
End Sub
:
Private Sub Command1_Click()
Print 2;: A: Print 3;: End: Print 4;
End Sub
Private Sub A()
Print 6;: End:
End Sub
2 6.

Print 7;

Exit Sub , End. Visual Basic ,


, . , Visual Basic , . , Visual Basic .
: End Exit Sub:
Private Sub Command1_Click()
Print 2;: A: Print 3;: Exit Sub: Print 4;
End Sub
Private Sub A()
Print 6;: Exit Sub: Print 7;
End Sub
2 6 3.

87: . , , , .
Private Sub Command1_Click()
Print ", , - ? - ?"
ATOS
Print " , , ?"
PORTOS
Print " , ?"
DARTANIAN
Print "! - !!!"
Exit Sub
Print " , !"
End Sub
Private Sub ATOS()
Print " - "
End Sub
Private Sub ARAMIS()
Print " , , -!"
End Sub
Private Sub PORTOS()
Print " ! , ?"
ARAMIS
Print " , ! , ."
End Sub
Private Sub DARTANIAN()
Print " , - ?"
Exit Sub

110
Print ", ?"
PORTOS
End Sub
. , .
, . , .

88:

60 9.3 .
.

89:

5.9

10.3.
- . - .
10.1 . , . :
Private Sub __()
Picture1.Line (100, 100)-(300, 300), vbBlue, B
Picture1.Line (100, 100)-(300, 300), vbBlue
Picture1.Line (100, 300)-(300, 100), vbBlue
End Sub
100 , . , , , 50. 6 100 50. - , 6, . . , ,
, , ,
.
, . Otstup.
, :
Dim Otstup As Integer
Private Sub __()
Otstup = 100
Picture1.Line (Otstup, Otstup)-(300, 300), vbBlue, B
Picture1.Line (Otstup, Otstup)-(300, 300), vbBlue
Picture1.Line (Otstup, 300)-(300, Otstup), vbBlue
End Sub
, , .
, , , , , .
. , -
, =
300 . , .
, Line.
Razmer :
Dim Otstup As Integer
Dim Razmer As Integer
Private Sub __()
Otstup = 100
Razmer = 200
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), vbBlue, B
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), vbBlue
Picture1.Line (Otstup, Otstup + Razmer)-(Otstup + Razmer, Otstup), vbBlue
End Sub
, , . :
Dim Otstup As Integer
Dim Razmer As Integer
Dim Tsvet As Long
Private Sub __()
Otstup = 100
Razmer = 200
Tsvet = vbBlue
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet, B
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet
Picture1.Line (Otstup, Otstup + Razmer)-(Otstup + Razmer, Otstup), Tsvet

111
End Sub
, Tsvet , Long, 16 Integer .

90:

, .

10.4.
, . ,
a = 1 + 0.25
b = ""
Debug.Print "", 10
Form1.BackColor = 15767511
If a > 3 Then Cls

1
0.25
""
""
10 15767511 3.
- , , ,
.
. Otstup
100 .

Dim Otstup As Integer


:

Const Otstup = 100


:
Const Otstup = 100
Private Sub __()
Picture1.Line (Otstup, Otstup)-(300, 300), vbBlue, B
Picture1.Line (Otstup, Otstup)-(300, 300), vbBlue
Picture1.Line (Otstup, 300)-(300, Otstup), vbBlue
End Sub
? Otstup - . Otstup
, , 100, . Visual Basic . , :
Const a = 5
Private Sub Command3_Click()
a=a+2
End Sub
? , , ,
. ,
Const = 3.14
Private Sub Command4_Click()
r = 50
_ = 2 * * r
_ = * r ^ 2
End Sub
- = 2.87, Visual Basic
, , 3.14, .
, .
, "" : 100,
"" .., Otstup, .., . ,
- .
Visual Basic.
, , . ,
- vbRed, vbBlack .. (, vbRed=255),
, . , Object Browser.

10.5.
- .
, , , . :

Otstup = 100
Razmer = 200
Tsvet = vbBlue

Otstup = 200
Razmer = 400
Tsvet = RGB(100,250,150)
? __ , , , . , , . ?

112
. , __.
, :
Dim Otstup As Integer
Dim Razmer As Integer
Dim Tsvet As Long
Private Sub __()
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet, B
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet
Picture1.Line (Otstup, Otstup + Razmer)-(Otstup + Razmer, Otstup), Tsvet
End Sub
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
'
Otstup = 100
Razmer = 200
Tsvet = vbBlue
__
Picture1.Print , "21.07.2001"
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
'
Otstup = 200
Razmer = 400
Tsvet = RGB(100, 250, 150)
__
Picture1.Print , "28.07.2001"
End Sub
, __ , , , . , .
- , -
. .
.
Otstup = 100
Razmer = 200
Tsvet = vbBlue
__

__ 100, 200, vbBlue


. , , . , , , Otstup = 100 Razmer = 200, - Otstup = 200 Razmer = 100?
__, -:

Private Sub __ (Otstup As Integer, Razmer As Integer, Tsvet As Long)


, .
. , :
Private Sub __ (Otstup As Integer, Razmer As Integer, Tsvet As Long)
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet, B
Picture1.Line (Otstup, Otstup)-(Otstup + Razmer, Otstup + Razmer), Tsvet
Picture1.Line (Otstup, Otstup + Razmer)-(Otstup + Razmer, Otstup), Tsvet
End Sub
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
__ 100, 200, vbBlue
Picture1.Print , "21.07.2001"
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
__ 200, 400, RGB(100, 250, 150)
Picture1.Print , "28.07.2001"
End Sub
, :
Dim Otstup As Integer
Dim Razmer As Integer

113
Dim Tsvet As Long
.
(__ 100, 200, vbBlue), Visual
Basic , (Otstup, Razmer, Tsvet), , .
, , . ,

__ 100, 200, vbBlue


a=100
__ a, 2 * a, vbBlue


, . :
Private Sub _3_(_ As String)
Print _
Print _
Print _
End Sub
Private Sub Command1_Click()
_3_ " ? - !"
_3_ " "
End Sub
_3_ - _.
Command1 :
? - !
? - !
? - !



. , , (, Round
(5.82716, 3) LoadPicture("c:\temp\Rockies.bmp") ), , .
LoadPicture , . , Command1 :
Private Sub __ (_1 As String, _2 As String)
Picture1.Picture = LoadPicture (_1)
Picture2.Picture = LoadPicture (_2)
End Sub
Private Sub Command1_Click()
__ "c:\temp\Rockies.bmp" , "c:\temp\Porthole.bmp"
End Sub
, (). , .
17.

91: 86 10.1 , . . .
92: 90 , .
, : , .
93: Visual Basic "" "".
, : _, _, .
94: , 16777216 - Visual Basic. - 256
, - 256 . . . . , 0 255 , , - . ,
- . , , ,
, , 256*256 . .
( ) ( 0 255).
. . , ,
.

114
: : ( ) .
, , ,
.

115

11.
, ,

. , , . , . - "-".

11.1. Date
Windows. , . - , - , -, . - - Date. .
Date , , , , , . , , 0:40 0:40, 1:20.
, , , . Visual Basic , , , .
Visual Basic , , , , .
Visual Basic , , #, . , : #2/16/2002#. 16 2002 . , :
Dim D As Date
Dim T As Date
Dim DT As Date
Private Sub Command1_Click()
Debug.Print #6/25/2001#
'25 2001
Debug.Print #2:22:57 PM#
'2 22 57 (PM)
Debug.Print #2/28/1998 10:45:00 PM# '10 45 28 1998
D = #12/25/2044#
T = #2:00:32 AM#
'2 00 32 (AM)
DT = #1/15/2156 11:59:42 PM#
Debug.Print D, T, DT
End Sub
:
25.06.01
14:22:57
28.02.98 22:45:00
25.12.2044 2:00:32

15.01.2156 23:59:42

: , -,
, .
-, , , Windows ( ). , :

D = InputBox(" ")
- # .
, . , Date , . ,
D = 26.5
Debug.Print D
:
25.01.1900 12:00:00
: 26.5 ( ), 30
1899 .
, . , , .

116

(, Windows)

Debug.Print Date
Debug.Print Time
Debug.Print Now

D = # 2/14/2009 4:45:07 PM # ( ), :
2
( )
1
( )
7
( )
7
( , -,
- , 7- - )
6
( (vbMonDebug.Print DatePart("w", D,
day) - 6- - )
vbMonday))

Debug.Print
Debug.Print
Debug.Print
Debug.Print

DatePart("m", D)
DatePart("q", D)
DatePart("s", D)
DatePart("w", D)

DatePart Integer, .
.

Debug.Print DateAdd("s", 10, D)


Debug.Print DateAdd("m", -1, D)

14.02.09 16:45:17
14.01.09 16:45:07

( 10 )
( 1 )

D1 = #2/14/2009 4:45:07 PM# , D2 = #2/16/2009 11:32:43 AM#


, :
43
( , D1 D2)

Debug.Print DateDiff("h", D1, D2)


Debug.Print Timer
Debug.Print MonthName (5)
Debug.Print WeekdayName (4)

53861,97
( , . Timer
Timer. , ,
, , )

( , -, )

Date = #05/22/2004#

Time = #10:44:00 AM#

Date, , ,
Date, Windows ,
. , , ,
, , , , .
.
- , .

yyyy

q

m

y

d

w
(1 - )
ww

h

n

s

- , .

95:
96:

, , , , 52 .

- , , ,
, ,

97: , , ,
, , .
98: , . , -
, - - . .
Visual Basic ?

117

11.2.
. . Interval 10000.
. :
Private Sub Timer1_Timer()
Debug.Print " "
End Sub
. . 10 Immediate " ". 10 , 10 , .
Interval 5000, 5 , 500, - 0.5 .
: Timer1 - , , Interval (), Timer1_Timer.
.
, .


Timer1_Timer , . :
Dim i As Long
Private Sub Timer1_Timer()
Debug.Print " ", i
i=i+1
End Sub
Interval 1000. . :




..

0
1
2
3

: i , Visual Basic Debug.Print 0. Timer1_Timer i 1,


- 2. .
, , , ! ,
.
Enabled ( - " ") False. . . , Enabled True.
. :
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
. , ,
.
, Timer1_Timer , ? . Interval 100, 10 .
Timer1_Timer, :
Private Sub Timer1_Timer()
Debug.Print " "
For i = 1 To 20000000 : Next
Debug.Print " "
End Sub
For i = 1 To 20000000 : Next. , ( ), , 20 . , , , -. , , 20
. - . , , End Sub. , , . ,
, - .
, 1 . , 10, 100 . , 18 .

99:

100 110 1 .

118

11.3. "-"
Visual Basic , . "" 200, ,
, . , , . !
-, , - ,
, : ", - ?" ,
, - . ! ! ! 200 , ? ? !
? 8? 40! . 1000 ,
!
? . . , . , . .
, "" . "", ,
, : - . . 80
, 15 . ,
" ", 1.3. , .
.


- :

, ( !). , , , :

- ( Windows) ,

- (02.08.00 2 2000 )

" " " ",


" "

- ,
" "

119

0.1 . .
, 1 15.4 , ,
. , .
"" . - 0:00:00.0.


.
. , . , , , -
, , .
. . , ,
, , , " ".
- . ,

( )

! ? ,
. . , . , - , ? , ,
, , .
, . , ,
.
, :

? . , .
- ? - ,
- .
, :
1.
2.
3.
. . - ( ), ? , , . . , , .
, :
1. ( )
2.
3.
4.
5.
(): , , , , . ! ( ) .
, " , , , !", .


. Shape . - , ,
, , !. . . . .
Shape1 , .
, - "" .
, .
BorderStyle , Alignment , .
, , .
_. : _. , .
. , , .
, Time, .

_.Text = Time
. . , ? ,
. , ? , , - . . , , . . , , -
. , . - ?
. , .

120

_. = 2500. :
Private Sub __Timer()
_.Text = Time
End Sub
. , , - . = 100. 10 . .
, ! .


. _. ,

_.Text = Date
, . . 24
10 Windows, , ,
- . : ,
, (), , . : FormLoad, - . . :
Private Sub Form_Load()
_.Text = Date
'
End Sub
Private Sub __Timer()
_.Text = Time
If Time = 0 Then _.Text = Date
'
End Sub
, , Windows " ".
.
, ,
:
. . .
, , _.Text Time.
__, , Date .
. , , . ( _.Text = Date).
, ____.
. , Option Explicit ,
- .
:
Option Explicit
Dim __ As Date
Private Sub Form_Load()
____
End Sub
Private Sub __Timer()
__ = Time
_.Text = __
If __ = 0 Then ____
End Sub
Private Sub ____()
_.Text = Date
End Sub
: " ?
!" .


. , ,
. , , . , Windows.
-, . , ,
Copy, Paste Edit. Visual Basic , , . No.
__. ,

121

__.Text = WeekdayName(DatePart("w", Date, vbMonday))


. , :
WeekdayName DatePart 11.1.
. , ? , :

= DatePart("w", Date, vbMonday)


__.Text = WeekdayName()
( 1 7). WeekdayName .
____, ,
. :
Private Sub ____()
_.Text = Date
__.Text = WeekdayName(DatePart("w", Date, vbMonday))
End Sub
. , .
. , Locked.
, .

Boolean
, - Boolean.
. 5.7 . ,
- True False ( ). . :

Dim As Boolean
, .


, . :

___

__
12:00:00. , " ".
, ,
.
, "". Microsoft Multimedia Control 6.0
"". 5 :
.DeviceType = "Sequencer"
.FileName = "c:\Windows\Media\Canyon.mid"
.
.Command = "Open"
.Command = "Play"
, . :
.Command = "Close"
, .
, , , . : ( ) , - , .
- .
( , ):
Private Sub Form_Load()
.DeviceType = "Sequencer"
.FileName = "c:\Windows\Media\Canyon.mid"
____
End Sub
Private Sub __Timer()
__ = Time
_.Text = __
If __ = 0 Then ____
If __ = _.Text Then __
End Sub

122

Private Sub __()


.Command = "Open"
.Command = "Play"
End Sub
.
. , .
. - . , . , .
. .
: .
, , - . ,
- , ,
. __, .
_. ? ,
? - "" "". String,
Boolean. , .
, :

, : " :"

, : " "
:
Private Sub _()
_ = True
_.Caption = " :"
___.Caption = " "
End Sub
, :

, : " "

, : " "
:
Private Sub _()
_ = False
_.Caption = " "
___.Caption = " "
End Sub
- :
Private Sub ____Click()
If _ Then _ Else _
End Sub
,
, .
_ True False,
IsNumeric 5.9 If. If _
= True Then .
:
Private Sub ___Click()
.Command = "Close"
End Sub
. , ,
, , :

If _ And __ = _.Text

Then __

. , , ,
, :
Option Explicit
Private Enum __

_
End Enum
Dim __ As __

123
Dim __ As Date
Dim _ As Boolean
Dim __ As Single
Dim __ As Single
Dim ___ As Single
Dim _ As Long
'
Private Sub Form_Load()
.DeviceType = "Sequencer"
.FileName = "c:\Windows\Media\Canyon.mid"
____
_
_
End Sub
'
Private Sub __Timer()
__ = Time
_.Text = __
If __ = 0 Then ____
If _ And __ = _.Text Then __
End Sub
Private Sub ____()
_.Text = Date
__.Text = WeekdayName(DatePart("w", Date, vbMonday))
End Sub
'
Private Sub ____Click()
If _ Then _ Else _
End Sub
Private Sub _()
_ = True
_.Caption = " :"
___.Caption = " "
End Sub
Private Sub _()
_ = False
_.Caption = " "
___.Caption = " "
End Sub
Private Sub __()
.Command = "Open"
.Command = "Play"
End Sub
Private Sub ___Click()
.Command = "Close"
End Sub
Private Sub Form_Terminate()
___Click
End Sub
'
Private Sub __Timer()
__ = Timer - __ + ___
_ = Int(10 * (__ - Int(__)))
_.Text = DateAdd("s", __, #12:00:00 AM#) & "." & _
End Sub

124
Private Sub ____Click()
If __ <> Then _ Else _
End Sub
Private Sub ___Click()
_
End Sub
Private Sub _()
__ = Timer
__ =
_.Enabled = True
___.Caption = ""
End Sub
Private Sub _()
___ = __
__ =
_.Enabled = False
___.Caption = ""
End Sub
Private Sub _()
___ = 0
__ = _
_.Enabled = False
___.Caption = ""
_.Text = "0:00:00.0"
End Sub
, Form_Load ,
Form_Terminate , .
___Click, . .
, Form_Terminate , ,
Close ( ), End .


, . .
( ), - : , , . __. Boolean , Boolean , . String,
.
Visual Basic , , Visual Basic, ,
. - ,
: , , - __.
:
Private Enum __

_
End Enum
, . Enum , - . ,
, . (Integer, String, ), (__) .
, , , :
Dim __ As __
: , , , . , . , , ( ?!). ,
cmd___

str___. , ,
, ( !) , ( ( cmd),
( str) - ). , .

125

___

__
.
:
Dim __ As __
Dim __ As Single
Dim __ As Single
Dim ___ As Single
Dim _ As Long
, , , Date. , .
. , , -
, , . , , 10 5 - . ,
:

_.Enabled = True
,

_.Enabled = False
Timer (
Timer), (
). , , , , , - ,
, .
Timer

__ = Timer
(Timer - __)
, . ___ ( , ),

__ = (Timer - __) + ___


, __. .
. __ - - .
, - 67,2. - 00:01:07.2. -
. :

_.Text = DateAdd ( "s", __, #12:00:00 AM# )


#12:00:00 AM# , , -. .
DateAdd . __.
Int:

= Int (__)
= __ -
_ = Int (10 * )
:

_ = Int(10 * (__ - Int(__)))


:

_.Text = DateAdd ("s", __, #12:00:00 AM#) & "." & _


& + .
, .
. , & : DateAdd, "."
_.
, , . , ,
.
, - ,
_. , .
. , , , . __.


, , , .
, , . , ,
, :

, , " ", -

126

, . _Done,
. , , , .
, , , .
__GotFocus.
, - - ,
, (If _ And __ =
_.Text Then __) ,
_.Text. , . - IsDate, IsNumeric 5.9 ,
. , .
, , ,
. .
, .
.


. - :
Private Sub __Timer()
__ = Time
_.Text = __
If __ = 0 Then ____
If _ And __ = _.Text Then __
End Sub
, , ,
, . , , ,
. ? , , , ____ __. , : ; , ; ,
. . , .
: , , ,
. . , ""
. . , , , , . ,
, . , , ,
. .
: , , .
, . , . - , .

99-1:

- . , " " (.
). .
. .
.
Time Zone. Select Case. ,
.

99-2: " ". .


. , , 40 , , 2 . , , 41 , 4 . - . , , . - ,
. 2 .
. , , ,
. , , . , , , . ,
, . . ,
, . . , - .
.

127

11.4.
. - .


6 . . , , .
. , , . , , , . , ..
, 11.3, . . . . < 50,
- 18. :
Dim x As Integer
'
Dim y As Integer
Dim R As Integer
Dim _ As Long
Dim _ As Long
Private Sub Form_Load()
x = 1000
y = 1500
R = 200
DrawWidth = 5
_ = vbBlack
_ = BackColor
End Sub

'

Private Sub Timer1_Timer()


Circle (x, y), R, _
'
For i = 1 To 500000: Next
'
Circle (x, y), R, _
'
x = x + 30
'
End Sub
: ,
- . - . , . . , ,
. .

100:

"" - .


, .
Shape . . :
Private Sub Timer1_Timer()
Shape1.Top = Shape1.Top - 20
End Sub
, , .

101:
102:
103:

. - .
, .

, " ": . , .
. ( ). , "" .
- , :
Dim As Integer
Dim x As Integer
Private Sub Form_Load()
x = Shape1.Left
= 50
End Sub
Private Sub Timer1_Timer()

128
x = x +
Shape1.Left = x
If x > Width Then = -50
End Sub

' ,

104: . , .
105: . . .
, . ( ), . Image ( Visual Basic).

105-1(): . . , :
, , . , .

106: , , 45 6.3. . 100- v=20/. (s) s=v*t, t . h h=100


2
9.81*t /2. , . Image . .
, ,
45. . , .
: , . , , , , . 100 , 20 , .
1 , , 40 . 4000 , : s =
40*v*t h=40*(100 9.81*t2/2).
107 ():

: .
? .
. .

v . . : s=v*t*cos
2

h=v*t*sin 9.81*t /2 (. ). , , , . : . , , .
, . - , .

""
: , , " !"
. . Caption
. "Times" - , . :
Private Sub Timer1_Timer()
Label1.FontSize = Label1.FontSize + 1
End Sub

108:

, , . Image.
True Strech, , :
Private Sub Timer1_Timer()
Image1.Width = Image1.Width + 10
Image1.Height = Image1.Height + 7
End Sub
, , .

, . , , -
- .
,

129

. .
.
Paint .
, . ,
. 1. , ,
2 ( Save, Save as). 3.
Visual Basic. . - Image. . Image4. -
Image4 Image. , Image4 . : 1-2-3-2-1-2-3-2-1-2-3-2-1-2-. Image4 , . -
: 1-2-3-2----1-2-3-2-----1-2-3-2-----1-2-. 4.
100 (, , ). - , . N 0-1-2-3-----0-1-2-3-----0-1-2-. , = 4. Image , . :
Dim N As Integer
Private Sub Form_Load()
N=0
End Sub

' 0

Private Sub Timer1_Timer()


Select Case N
Case 0:
Image4.Picture = Image1.Picture
Case 1:
Image4.Picture = Image2.Picture
Case 2:
Image4.Picture = Image3.Picture
Case 3:
Image4.Picture = Image2.Picture
End Select
N=N+1
' N 1
If N = 4 Then N = 0
' 3 0, 4
Image4.Left = Image4.Left - 60
'
End Sub

N=N+1
If N = 4 Then N = 0
N = (N + 1) Mod 4
, , .

109: "". , . ,
. . Paint, FotoShop - ,
. ,
, .


, , , ( ). : , .
( ) .
.

130

12.

, ,
- . , Visual Basic
, , Windows.
, .

12.1.
:
. , . , .
, . " " - Object Browser. ,
Object Browser Form. , . :
Click (), DblClick ( ), MouseDown ( ), MouseUp ( ), MouseMove ( ).
Click DblClick , . MouseDown , . MouseDown MouseUp ,
, .

MouseDown MouseUp
Form MouseDown ( , 3.6).
:
Private Sub Form_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
4 - 4 , :

Button -

Shift -

X , Y -
, , ( ) ( )
:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
', :
Select Case Button
Case 1: Debug.Print " "
Case 2: Debug.Print " "
Case 4: Debug.Print " "
End Select
', (Shift, Ctrl, Alt) :
Select Case Shift
Case 0: Debug.Print " Shift, Ctrl, Alt"
Case 1: Debug.Print " Shift"
Case 2: Debug.Print " Ctrl"
Case 3: Debug.Print " Shift, Ctrl"
Case 4: Debug.Print " Alt"
Case 5: Debug.Print " Shift, Alt"
Case 6: Debug.Print " Ctrl, Alt"
Case 7: Debug.Print " Shift, Ctrl, Alt"
End Select
' :
Debug.Print "X="; X, "Y="; Y
End Sub
Shift . , "" Shift, Ctrl, Alt . 1, 2

131
*

4. , "" . .
. , .
, MouseDown.
MouseUp .


:
Dim X_ As Integer
Dim Y_ As Integer
Dim __ As Double
Private Sub Form_Load()
Randomize
End Sub
' :
Private Sub Command1_Click()
X_ = 4000 * Rnd
' ( )
Y_ = 4000 * Rnd
ForeColor = vbBlack
'
Circle (X_, Y_), 50
For i = 1 To 3000000: Next
',
ForeColor = BackColor
'
Circle (X_, Y_), 50
End Sub
' :
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
__ = Sqr((X - X_) ^ 2 + (Y - Y_) ^ 2)
MsgBox (" " & Int(__) & " .")
End Sub
, ( , ): . , . , X - X_, Y Y_ ( ). . , . , (
).

MouseMove
, ,
. MouseDown, . :
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
', :
Select Case Button
Case 0: Debug.Print " "
Case 1: Debug.Print " "
Case 2: Debug.Print " "
Case 3: Debug.Print " , "
Case 4: Debug.Print " "
Case 5: Debug.Print " , "
Case 6: Debug.Print " , "
Case 7: Debug.Print " , , "
End Select
', (Shift, Ctrl, Alt) :
Select Case Shift
Case 0: Debug.Print " Shift, Ctrl, Alt"
Case 1: Debug.Print " Shift"
Case 2: Debug.Print " Ctrl"
Case 3: Debug.Print " Shift, Ctrl"
Case 4: Debug.Print " Alt"
Case 5: Debug.Print " Shift, Alt"
Case 6: Debug.Print " Ctrl, Alt"
Case 7: Debug.Print " Shift, Ctrl, Alt"
End Select
', :
*

, , Alt , .

132
Debug.Print "X="; X, "Y="; Y
End Sub
MouseDown - , MouseMove
. MouseDown - , MouseMove ( ).


, :
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
PSet (X, Y)
End Sub
. .

110: , , ,
.
111:

, 1.

12.2.
,
. , . : KeyDown
( ), KeyUp ( ) KeyPress.( ). .

KeyDown KeyUp
, . Form

KeyDown. :
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
', :
Select Case KeyCode
Case vbKeyUp:
Debug.Print " "
Case vbKeyDown:
Debug.Print " "
Case vbKeyLeft:
Debug.Print " "
Case vbKeyRight:
Debug.Print " "
Case vbKeyW:
Debug.Print " W"
Case vbKey7:
Debug.Print " 7"
Case vbKeySpace:
Debug.Print " "
Case vbKeyDelete:
Debug.Print " Delete"
Case vbKeyF4:
Debug.Print " F4"
Case vbKeyAdd:
Debug.Print " +"
Case vbKeyEscape:
Debug.Print " Esc"
End Select
', (Shift, Ctrl, Alt) :
Select Case Shift
Case 0: Debug.Print " Shift, Ctrl, Alt"
Case 1: Debug.Print " Shift"
Case 2: Debug.Print " Ctrl"
Case 3: Debug.Print " Shift, Ctrl"
Case 4: Debug.Print " Alt"
Case 5: Debug.Print " Shift, Alt"
Case 6: Debug.Print " Ctrl, Alt"
Case 7: Debug.Print " Shift, Ctrl, Alt"
End Select
End Sub
- , :

KeyCode - . - . - , , . , . , . , (KeyCode).
, , , .
Object Browser ( KeyCodeConstants).

Shift - (Shift, Ctrl, Alt) .


Shift , MouseDown. Shift, Ctrl, Alt "" (1, 2 4).
, . , -

133
( ) . , Shift, Ctrl Alt . , .
, , . , ,
. , Private Sub Form_KeyDown , :

Private Sub Command1_KeyDown


Private Sub Command2_KeyDown
Private Sub Text1_KeyDown
- . ? ,
. : ,
, Private Sub Command2_KeyDown, , Command2, Command2 .
Private Sub Form_KeyDown, . . - -
, Private Sub Form_KeyDown . Visual
Basic - KeyPreview True.
, .
Private Sub Form_KeyDown KeyCode=0. ( ).
" "? - Enter, Esc, Tab .
KeyUp .

112 : : . R
, G - , Y - . .
113 : .
. .

12.3. - ()
: "" "". "" ,
Visual Basic. , "" - , -
. , , . , , . ( 180).
.


( , ):

134

. .
. . . . , ( 15).
. , .
() - . - B (). ,
( , , ).
- . , - . . . ,
, . , 10 . .
, , . (
), (. , 9 ).
, . ,
, .
. , ,
. , - .


. , , .
, . . .
, :
1. , , , -
, , , . .
2. . . , , 11.3. .


, , , , , , :
1.
2.

(),

135
3.
4.
5.

, . , .
, .
F8.
. , , .
? . , , , , Form_Load.
,
, . -
. - :
WindowState - , . , , , , (Form1.WindowState).
ScaleLeft ScaleTop. . , , . ScaleLeft , ScaleTop -
. :

ScaleLeft = 1000
1000
ScaleLeft = -500
500
ScaleTop = 800
800
ScaleTop = -500
500
, , ,
, , .
, , ,
. , .
Form_Load , , .
, , . ___Click.
, . _. , . , ,
, , . X_ Y_ , , .
___ , .
.SetFocus, .
" ". ,
,
. .SetFocus .
, , , . , ,
___ , , ,
. .


, . , , . ,
, . . ,
. (
). , , " " (, , )
.
, :

, (, , , ) .

.
, , ,
.
Image. Image_.
, BorderStyle. :
Dim x As Integer
'
Dim y As Integer
'
Private Sub Form_Load()
x = Image_.Left
y = Image_.Top

136
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyRight:
x = x + 100
Case vbKeyLeft:
x = x - 100
Case vbKeyDown:
y = y + 100
Case vbKeyUp:
y = y - 100
End Select
Image_.Left = x
Image_.Top = y
End Sub
, . -, , ,
. -, , , . .
, (. ).
- , . (. ). , , .
Form_KeyDown. , , . , ,
___. , . _ = True ,

If _ Then = + 1
_).
, . .
, , , , . 4 , 4 . 4 . ? ,
. 4 . , Visual Basic, , 4 , . .
4 Image, Image_, Image_, Image_, Image_ . , .
, ,

Image_.Picture = Image_.Picture
-

Image_.Picture = Image_.Picture
.
.
, . Timer1_Timer .
_____. . . - 4 4 .
: . - _.
, . , ___. _. . , 5. - 10 ( ). ,
. , . , . - , KeyDown . - ,
, - .
_ , , txt
txt . ,
, . , , = + . , , .
__. - : ,
. , , , - Point.
9.7. (vbMagenta), - , - , Point
. Select . ,
= 15,
, , (. ) , , , , , .
___ .

137
, , .


Dim x As Integer
'
Dim y As Integer
'
Dim X_ As Integer
'
Dim Y_ As Integer
Dim X_ As Integer
Dim Y_ As Integer
Dim _ As Integer
' - ,
Dim _ As Integer
' - ,
Dim _ As Integer
' -
Dim __ As Integer
Dim _ As Integer
' - ,
Dim ____ As Integer
'
Dim As Long
' ( )
Dim As Integer
'
Dim As Integer
' - , .
Dim _ As Integer
',
Dim __ As Long
' , - , ,
Private Enum

End Enum
Dim As
Private Enum

___
End Enum
Dim As
Dim As Boolean
Dim _ As Boolean

' = True,
' , ,

Private Sub Form_Load()


Timer1.Enabled = False
'
Randomize
'
WindowState = 2
'
BackColor = vbWhite
'
' ( ):
____ = 500
ScaleLeft = -____
'
ScaleTop = -____
_ = Screen.Height - 2 * ____
'
_ = 600
_ = 600
X_ = _ - _
'
X_ = 0
'
Y_ = _ / 2
'
Y_ = _ / 2
'
_ = 30
__ = _ / 6
_ = 200
End Sub
Private Sub ___Click()
_ = False
'
Timer1.Enabled = False
'
' :
Cls
' , ,
__
_
_
_
' :
___
= False

138
Timer1.Enabled = True
.SetFocus
End Sub

' ,
' , ,

Private Sub __()


DrawWidth = 10
Line (0, 0)-(_, _), vbRed, B
DrawWidth = 1
'
End Sub
Private Sub _()
Line (X_, Y_)-(X_ + _, Y_ + _), vbGreen, BF
End Sub
Private Sub _()
Line (X_, Y_)-(X_ + _, Y_ + _), vbBlue, BF
End Sub
Private Sub _()
' -
Dim i As Integer
Dim X_ As Integer
'
Dim Y_ As Integer
'
For i = 1 To _
' :
X_ = 2 * _ + _ * Rnd * 2 / 3
Y_ = _ + (_ - _ - __) * Rnd
Line (X_, Y_)-(X_ + __ * Rnd, Y_ + __ * Rnd), vbMagenta, BF
Next
End Sub
Private Sub ___()
x = X_:
y = Y_
= 0: = 0: = 0
=
_
= ___
Image_.Visible = True
_
End Sub

'
' , ,
' , , =0
' ,
' ,

Private Sub Timer1_Timer()


__
If Then Exit Sub
_
_____
_
_
End Sub
Private Sub __()
__ = Point(x, y)
Select Case __
Case vbMagenta: = 15
Case vbBlue:
.Text = "!":
Case vbRed:
.Text = " !":
End Select
End Sub

'
Timer1.Enabled = False: = True
Timer1.Enabled = False: = True

Private Sub _()


Select Case
Case
= + 5
Case
If > 0 Then = - 10 ',
If < 0 Then = 0
' ,
End Select
= ___
'
End Sub
Private Sub _____()
Select Case
Case :
_
Case :
_
Case :
_
Case :
_

139
End Select
End Sub
Private Sub _()
Image_.Picture = Image_.Picture
y = y -
End Sub
Private Sub _()
Image_.Picture = Image_.Picture
y = y +
End Sub
Private Sub _()
Image_.Picture = Image_.Picture
x = x -
End Sub
Private Sub _()
Image_.Picture = Image_.Picture
x = x +
End Sub
Private Sub _()
Image_.Left = x
Image_.Top = y
End Sub
Private Sub _()
.Text =
= +
txt.Text =
If _ Then = + 1
txt.Text =
End Sub

' ,
' ,

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)


_ = True
Select Case KeyCode
Case vbKeyUp:
If < _ Then = '
Case vbKeyLeft:
If < _ Then =
Case vbKeyDown:
If < _ Then =
Case vbKeyRight:
If < _ Then =
Case vbKeySpace:
=
Case vbKeyB:
=
End Select
KeyCode = 0
'
End Sub

(,) , . - _. . , .
.
, . , . . , , .
. ,
, - , - .
MouseDown, , KeyDown. , , .


, . ,
, . .
, . ,
- 1 2. , -

140
. KeyDown .
, . , ,
. 10 ? .
Visual Basic . , , - . , ,
. "" - CommandButton
- . Visual
Basic . ,

Command1.Visible = True
, . , , - , .
, ""
. , . . , 20.

12.4.
114: . .
, . ,
, . . (
). . . - , . , , , , - , 1.
, - . 1
. . . (, 10), . , !, 10, !, 8 . , .
: , ? ,
, , , , .
. , , . . , (,
0 10 ), (, 4 8 ).
. , ,
. .
. ,
, .
_______________

_________________

Visual Basic. , , , ,
, , . - - III !

141

III. Visual Basic


, , . ,
, . , . . ,
, - .
, - .
, . , , .

, - .
, .
Visual Basic , , , ,
, .

142

13.
- .
, , .
, . ,
.
.

13.1.
. :

x1

x2

b8

yi

yi-6 zij

zi+1j

: , , , , , ,
. . Visual Basic
, Visual Basic :

X(1)

X(2)

B(8)

Y(i) Y(i-6)

Z(i,j) Z(i+1,j)

?
. , .
.
, , : 1 1 2 3 5 8 13 21 34..... , . , : , ,
. .
:
: f(1),
: f(2)
..
,
,

f(1)=1

f(2)=1

f(3)=2 f(4)=3 f(5)=5 f(6)=8 ......


f(3)=f(1)+f(2),
f(4)=f(2)+f(3),
f(5)=f(3)+f(4) ..
, ? :
f(i)=f(i-2)+f(i-1).
i , , 6. :
f(6)=f(6-2)+f(6-1)
f(6)=f(4)+f(5), .

115:
1)
2)
3)

, :
14 18 22 26 .....
6 12 24 48 ....
3 5 9 17 33 65 ....

, .
. t(1) , t(2) ,....., t(365) - . 35 . h(1) ,
, h(2) - ..

13.2.
. , , . - , , , , ..
, (. 8). , , , ,
. 365 . 365 . ,
, . ,
, (16.2).
, ? ListBox, 15.5. .
, Visual Basic . , .
(500, 400 600). , ?

143
- dlina(1), - dlina(2), - dlina(3). Visual Basic :

Dim dlina (1 To 3) As Integer


1 - , 3 - . To . : dlina Integer, 1 3.
:
Dim dlina(1 To 3) As Integer
Dim summa
As Integer
Private Sub Command1_Click()
dlina(1) = 500
dlina(2) = 400
dlina(3) = 600
'
'
summa = dlina(1) + dlina(2) + dlina(3)
Debug.Print summa
End Sub
,
dlina(1), dlina(2), dlina(3), summa.
, InputBox:
Dim dlina(1 To 3) As Integer
Private Sub Command1_Click()
dlina(1) = InputBox(" 1- ")
dlina(2) = InputBox(" 2- ")
dlina(3) = InputBox(" 3- ")
Debug.Print dlina(1) + dlina(2) + dlina(3)
End Sub
: :
i = 2: a(3) = 10: a(i) = 100: a(i + 6) = a(i) + a(5 - i): i = 0: Debug.Print a(i + 3) + a(2) + a(i + 8)
: 220
: i = 2 ; a(3) = 10 ; a(2) = 100 ; a(2 + 6) = a(2) + a(5 - 2) ; i = 0 ; Debug.Print a(0 + 3) + a(2) + a(0 + 8)
, , :
Dim dlina(1 To 1000)
As Integer
Dim summa
As Integer
Private Sub Command1_Click()
' , :
For i = 1 To 1000
dlina(i) = InputBox(" " & i & "- ")
Next
' i=1 dlina(1),
' - i=2 dlina(2) ..
' :
summa = 0
For i = 1 To 1000
summa = summa + dlina(i)
Next
Debug.Print summa
End Sub
, , , 1000 3.

. 10 : a(1), a(2), ... , a(10).


: a(1)+a(2)+a(3), a(2)+a(3)+a(4),
a(3)+a(4)+a(5), ...... , a(8)+a(9)+a(10).
Dim a(1 To 10) As Integer
Private Sub Command1_Click()
a(1) = 23: a(2) = 28: a(3) = 4: a(4) = 0: a(5) = 12
a(6) = 10: a(7) = 23: a(8) = 2: a(9) = 9: a(10) = 1
For i = 1 To 8
Debug.Print a(i) + a(i + 1) + a(i + 2)
Next
End Sub

116: . (
).
117: . (

20 .).

144

118: . ?
119: . 70 .

13.3.
. , , . . .
1
2
3

1-
-8
25
11

2-
-14
28
18

3-
-19
26
20

4-
-18
20
25

( ):
2- 4- 3- 1- .
2-


, 24-26
:
t(1,1)
t(1,2)
t(1,3)
t(1,4)
t(2,1)
t(2,2)
t(2,3)
t(2,4)
t(3,1)
t(3,2)
t(3,3)
t(3,4)
, (), - ()
. .
3*4=12 Integer t.
:
1)
2)
3)
4)
5)

Dim t (1 To 3, 1 To 4) As Integer
:
Dim t(1 To 3, 1 To 4) As Integer
Private Sub Command1_Click()
' :
t(1, 1) = -8: t(1, 2) = -14:
t(1, 3) = -19:
t(1, 4) = -18
t(2, 1) = 25: t(2, 2) = 28:
t(2, 3) = 26:
t(2, 4) = 20
t(3, 1) = 11: t(3, 2) = 18:
t(3, 3) = 20:
t(3, 4) = 25
' 1 :
Debug.Print t(2, 4), t(3, 1)
' (2 ):
For i = 1 To 3:
Debug.Print t(i, 2):
Next
' (3 ):
i=3
s=0
For j = 1 To 4:
s = s + t(i, j):
Next
Debug.Print s / 4
' (4 ):
For i = 1 To 3
For j = 1 To 4
Debug.Print t(i, j),
Next j
Debug.Print
Next i
' 24-26 (5 ):
For i = 1 To 3
For j = 1 To 4
If t(i, j) >= 24 And t(i, j) <= 26 Then Debug.Print ""; i; ""; j
Next j
Next i
End Sub

120:

145

13.4.
, Date . . :

Dim s(1 To 50) As String


, 50 , . :
Dim s(1 To 50) As String
Private Sub Command1_Click()
s(21) = "":
Debug.Print s(21)
End Sub
:
Dim b(1 To 30, 1 To 6) As Boolean
Dim DT(1 To 10) As Date
Private Sub Command1_Click()
b(2, 3) = False:
Debug.Print b(2, 3)
DT(2) = #1/15/2156 11:59:42 PM#: Debug.Print DT(2)
End Sub
:
Private Enum

End Enum
Dim (1 To 300) As
Private Sub Command1_Click()
(200) = :
Debug.Print (200)
(220) = :
Debug.Print (220)
End Sub
3 1, 0.
, :

Dim a(20 To 60) As Integer


41 . :

Dim b(0 To 9, -20 To 30) As Integer


10*51=510 .
, . , a(15) = 0.
,

Dim f(0 To 9) As Integer

Dim f(9) As Integer


Visual Basic 0. ,
0, 1,

Option base 1
, , , ..:
-
Dim a (1 To 10) As Integer
-
Dim a (1 To 10, 1 To 5) As Integer
-
Dim a (1 To 10, 1 To 5, 1 To 2) As Integer
-
Dim a (1 To 10, 1 To 5, 1 To 2, 1 To 3) As Integer

10
50
100
300

13.5.
?
. - 3 3. , () ( ) . . , ,
. . Dim a (1 To 3, 1 To 3) As Integer
, , . 0 1 . if a(1,1)=0
And a(1,2)=0 Then a(1,3)=1. - .
( ).

146
: 2 2:

. ,
(, ).
( , ). - ,
- , - .
.
:

- ( )
. .
:
Dim a(1 To 2, 1 To 2) As String * 1
'
Dim i As Integer
Dim j As Integer
Dim As Integer
______________________________________________________________________
Private Sub Command1_Click()
'
a(1, 1) = "": a(2, 1) = ""
'
a(1, 2) = "": a(2, 2) = ""
_ 1
_ 2
= 0
1
2

'

' :
For i = 1 To 2
For j = 1 To 2
Debug.Print a(i, j);
Next j
Debug.Print
Next i
Debug.Print
'
End Sub
______________________________________________________________________
Private Sub _(_ As Integer)
i = InputBox(" , " & _)
j = InputBox(" , " & _)
a(i, j) = ""
End Sub
______________________________________________________________________
Private Sub (_ As Integer)
i = InputBox(" , " & _)
j = InputBox(" , " & _)
If a(i, j) = "" Then
' ,
a(i, j) = ""
'
= + 1
'
ElseIf a(i, j) = "" Then
' ,
a(i, j) = ""
'
End If
End Sub
Dim a(1 To 2, 1 To 2) As String * 1 :
String * 1 a 1 . String, - , . a 1 , .
.
, , .
, Cls , a. , 4 : , , ,

147
- . ,
For i = 1 To 2
For j = 1 To 2
Debug.Print a(i, j);
Next j
Debug.Print
Next i
Debug.Print a(i, j) :

If a(i, j) = "" Then _ i j


If a(i, j) = "" Then _ i j
If a(i, j) = "" Then _ i j
i j, . .
- . ,
, , .
-, .

13.6.
: 20 , :

, :

( ).
: 20 Image , . . Visual Basic
.
: Image img. .
Index. . ,
. : Properties - img. Index -
, 1. : Properties - img(1). ,
. - img(1).
? , , 11.3, - Yes. Visual Basic 0 .
. ,

Load img(4)
() img 4. , ,
. . :
Dim i As Integer
Dim N As Integer
'
______________________________________________________________________
Private Sub Form_Load()
N = 20
' , ( ):
For i = 2 To N

148
Load img(i)
img(i).Visible = True
Next
' :
For i = 1 To N
img(i).Top = Height - 1000
img(i).Left = 300 * i
Next
End Sub
______________________________________________________________________
Private Sub Command1_Click()
' :
For i = 1 To N
img(i).Top = img(i).Top - 50 * (i - 1)
Next
End Sub
: , Form_Load, .
Command1_Click .
"" , :
Dim i As Integer
Dim N As Integer
______________________________________________________________________
Private Sub Form_Load()
N = 20
' , ( ):
For i = 2 To N
Load img(i)
img(i).Visible = True
Next
' :
For i = 1 To N
___ i
Next
End Sub
______________________________________________________________________
Private Sub Command1_Click()
' :
For i = 1 To N
_ i
Next
End Sub
______________________________________________________________________
', _:
Private Sub ___(_ As Integer)
img(_).Top = Height - 1000
img(_).Left = 300 * _
End Sub
______________________________________________________________________
' _:
Private Sub _ _ (_ As Integer)
img(_).Top = img(_).Top - 50 * (_ - 1)
End Sub
_ . :

If _ = 8 Then img(_).Top = 1000


If _ = 14 Then img(_).Visible = False
() 4- , Unload img(4).
, , ,
, Index, ,
, . . ,
Private Sub img_Click(Index As Integer)
If Index = 2 Then img(Index).Top = img(Index).Top + 200 Else img(Index).Visible = False
End Sub
, 2- .

149

14.

- , . . - , , , , .

14.1. Variant
- . , . , ,

Dim a(1 To 10) As Integer


. .
, , . , :
Dim a(1 To 3)
Private Sub Command1_Click()
a(1) = 32
a(2) = ""
a(3) = #8:56:00 AM#
End Sub
Visual Basic , Variant. -.
, . , .
Dim a(1 To 3) Dim a(1 To 3) As Variant.
Variant ( , ):
Dim b As Variant
' Dim b
Private Sub Command1_Click()
b = 77
b = ""
End Sub
, , Visual Basic Variant. ? , , Type mismatch ( ). , , Visual Basic
. , . , , - Variant .
, .
.
Variant. .

14.2.
, - . :
, - , , , .
:

( )

( )
. , :

,
: .

150
(.11.3). -
() :

Private Type
As String
As Integer
_ As Boolean
End Type
. ( Private ). Visual Basic , . :

Dim 1 As
Dim 2 As
:
' :
Private Type
As String
As Integer
_ As Boolean
End Type
' :
Dim 1 As
Dim 2 As
____________________________________________________________________
Private Sub Form_Load()
' :
1. = "StarC":
2. = "Heroes III"
1. = 90:
2. = 200
1._ = False:
2._ = True
' 1 :
Debug.Print 1.
' 2 :
Debug.Print 1. + 2.
' 3 :
If 2._ Then Debug.Print " " Else Debug.Print " "
End Sub
, , .
- .
( ) . ,
, , . Form_Load.
, . ( 20).
:

Private Type
As String
As Integer
_ As Boolean
(1 To 20) As String
End Type
:

2.(4) = ""
1.(12) = "Fenix"
Debug.Print 1.(10)
: 30 .

Dim 1 As
Dim 2 As
:

Dim (1 To 30) As
:

(16). = "StarCraft"
' 16-
(8).(12) = ""
'
Debug.Print (16)., (8).(12)
: , . , ( ), .
. :
' ,
' :
Private Type

151
As String
As Integer
As String
End Type
' :
Private Type
As String
As Integer
_ As Boolean
(1 To 20) As
' 20
End Type
' :
Dim (1 To 30) As
Private Sub Form_Load()
(8).(12). = ""
(8).(12). = 140
Debug.Print (8).(12).,
End Sub

(8).(12).

, . . , , .
.

121:

. :


. :

, .

122:

. :


, 10 . :

( ).
, Visual Basic . 22.

14.3.

, . - .
- . Visual Basic
. .
. 20 .
Visual Basic , . - Object.
Dim A As Object, A . , . , ,
, : Set A = Label1.
.
Private Sub Command1_Click()
Dim A As Object
Set A = Label1
A.FontSize = 20
A.Caption = "!"
'
Set A = Form1
A.Caption = " !" '
End Sub

152
, A Label1, Label1.FontSize = 20 A.FontSize = 20.
Control - . Dim A As Control, A , .
? ,
. ,
, 17.7.

, . - , , .
( ? - ). ,
Integer. , .
: , , , , - , , , , .. , - - , (, , )
. , , , . - - , , ,
. .
: . : Label1, Text1, Command1, Label2, Text2, Command2. "" Label2, Text2, Command2. . _ :

Dim _ As New Collection


Collection . New , ( - ).
, . ,
13.6 . . :
Dim _ As New Collection
'
Private Sub Command1_Click()
_.Add Label2
_.Add Text2, ""
_.Add Command2, ""

' 1-
' 2-
' 3-

Debug.Print _.Count
Debug.Print _ (1).Caption
_ (3).Height = 800
_ ("").BackColor = vbYellow

' 3 -
' "Label2"
' Command2
' Text2

For Each _ In _
_.FontSize = 18
Next

'
'

For Each _ In _
'
If TypeName(_) = "CommandButton" Then
' - CommandButton,
_.Enabled = False
'
End If
Next
_.Remove 2
'
_.Remove ""
'
End Sub
: , (Add, Remove, Count) :
Add . .
- , ,
. , ,
, .
Count :
, , , ,
.
( ), Remove
.
- For Each. , . _.
, _ "" 1- , - 2- .., . For Each ,
For. _, - Dim _ As Control.
TypeName, .

153
, . , ,
? , .
, 20, , .
, For Each .

14.4. (Frame)
. .
, .
Frame, . Toolbox , Frame.
. , . Top Left . , .
, . , "". , . ,
. , (Cut) (Paste) . ,
.
. :

Top, Left. , , . Visible, Enabled.


, . , . , . .
, , .
, , PictureBox. - . . , , .
.

154

15.

, :

, , - 1 2.

Microsoft Multimedia Control - 2.8

Animation - 2.12

Image, Picture - 9.3

Line, Shape - 9.4

- 11.2

(Frame) - 14.4
, :

Common Dialog - 18.2

ImageList - 18.3

Web- - 21.5

Data DBGrid - 22.3


, , .
, . .
. , . , .
Toolbox. , Project Components Microsoft Windows Common Controls 6.0 Microsoft Windows Common Controls 6.0-2.

15.1. (CheckBox)
(CheckBox). . . ( ) , "", ( ), "".
: . , : , . ,
( ).
: :

- Check1 Check2.
:
Private Sub Command1_Click()
Cls
If Check1.Value = vbChecked Then DrawWidth = 3 Else DrawWidth = 1
' 1 , ,
If Check2.Value = vbChecked Then ForeColor = vbBlue Else ForeColor = vbBlack ' 2 , ,
Circle (500, 500), 300
End Sub
: Value (), . Value 3 : vbChecked (, ), vbUnchecked ( ,
), vbGrayed ( - , , Microsoft Office).
. , , , . : , ,
, , .

155
, . - (

Style) .

15.2. (OptionButton)
OptionButton. . . ,
, . , . ,
, :

, , , ? , , :

.
, - . . , , .
, , Value. -
, True. , Option1,
:

If Option1.Value = True Then ..


, , :

If Option1.Value Then ..
. Visual Basic (
Value) - Option1.Value - Option1. :

If Option1 Then ..
, , ( : Option1, Option2, ):
If Option1 Then
Debug.Print " "
ElseIf Option2 Then
Debug.Print " "

End If
, , ,
Click, , :
Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0
Debug.Print " "
Case 1
Debug.Print " "
.

156
End Select
End Sub
, . , ,
( Style) - .

15.3. (HScrollBar VScrollBar)


(HScrollBar). (VScrollBar).
. . . , ,
Windows. ,
- .
: W 20 50.
2,
5. 27.
: . HScroll1.
:

Min
20

Max
50

SmallChange
2

LargeChange
5

Value
27
, :
Private Sub HScroll1_Change()
W = HScroll1.Value
Debug.Print W
End Sub
HScroll1_Change .

123:

, - , - . :
.

15.4. Slider, ProgressBar


Slider . (Min, Max, SmallChange, LargeChange, Value) HScrollBar.

ProgressBar . . ?
, (, 400 ). , .
, " . .", ,
. , , , . ProgressBar, 1/400 ProgressBar. ,
, . , ! -

157
, .
ProgressBar - Min, Max - . Scrolling.
. , .
Max 50, - 100. :
Private Sub Command1_Click()
For a = 0 To 40 Step 0.01
ProgressBar1 = a
Next
End Sub
Private Sub Command2_Click()
For a = 0 To 80 Step 0.1
ProgressBar2 = a
Next
End Sub
Private Sub Command3_Click()
For a = 0 To 30 Step 0.001
Slider1 = a
Next
End Sub
. , . , .
400 , , - .

15.5. (ListBox) (ComboBox)


(ListBox)
. - List1. . List "" - , Ctrl-Enter. "" - , Ctrl-Enter. . . .

, . "" :
: " ". , . , ( ), .
:
Private Sub Command1_Click()
Debug.Print " "; List1.Text
End Sub
Text List1 - List1. , "". , :
.

ComboBox ( " ")


ComboBox - ListBox. . .
ComboBox. - Combo1. ComboBox Style.
Dropdown List - " ". ComboBox , ListBox. . :

158

.
, ListBox. ComboBox
ListBox.
Private Sub Command2_Click()
Debug.Print " "; Combo1.Text
End Sub
, .

ComboBox ( " Combo")


ComboBox ( - ). Style Simple Combo - " Combo". ComboBox , ListBox. . Combo :

ComboBox ListBox , . ,
, ListBox. -.
? , , , .
" " , .

ComboBox ( " Combo")


Combo ComboBox: , , , Combo.

, ListBox ComboBox.
, ListBox, ComboBox.
.

List1.AddItem ""
List1 AddItem
List1.AddItem "", 3 AddItem 3 List1.
List1.RemoveItem 4
RemoveItem 4 List1.
List1.Clear
List1
Debug.Print List1.Text
List1
Debug.Print Combo1.Text
ComboBox
Debug.Print List1.List (5)
5 List1
List1.List(0) = ""
0 List1
Debug.Print List1.ListIndex List1. , -1.
Debug.Print List1.ListCount List1
, , True
Sorted. . , AddItem
. , - , , 28 , 5.
ListBox ComboBox: . .
, , Click DblClick.
: Combo 5 . :

"" Combo

""

"" ( )

159
"" ( )

"" ( )
, .
. , :
Dim As String '

Private Sub _Click()


Debug.Print Combo1.Text
End Sub
Private Sub _Click()
Combo1.RemoveItem Combo1.ListIndex
End Sub
Private Sub _Click()
Combo1.AddItem Combo1.Text
End Sub
Private Sub _Click()
Combo1.AddItem Combo1.Text
Combo1.RemoveItem Combo1.ListIndex
End Sub
Private Sub _Click()
Combo1.List() = Combo1.Text
End Sub
Private Sub Combo1_Click()
= Combo1.ListIndex
End Sub
Private Sub Combo1_DblClick()
_Click
End Sub

123-1: "- ". . .


. .

15.6.
, , , Visual Basic.

MonthView DTPicker
, DTPicker.

Private Sub DTPicker1_Change()
If DTPicker1 = #4/24/2001# Then MsgBox " "
End Sub
24 2001 .

160

.
, DTPicker1.
Today. . .
DTPicker1 1601 9999 .
.

UpDown
UpDown. . , . Text1.
: UpDown 0 100 5 .
UpDown: Min - 0, Max - 100, Increment - 5, BuddyControl - Text1, BuddyProperty - Default. .

DriveListBox, DirListBox, FileListBox


- .

, . . , . DriveListBox , DirListBox
, FileListBox . , Visual Basic
"" . ,
. , DriveListBox, DirListBox,
DirListBox, FileListBox. , , Windows. , ,
.
, ,
- CommonDialog (. 18.2).

161

RichTextBox
Microsoft Word. , ,
.
. RichTextBox -,
, , .. RTF, Word. , , .
Project Components Microsoft RichTextBox Control 6.0.

ListView TreeView
ListView TreeView, Windows (. 0). TreeView, - ListView. TreeView ,
. , . ListView , (, ) .
, .

(TabStrip) (StatusBar)
, : File Add Project. : New, Existing, Recent.
1.3.
Windows. Microsoft Word:

,
.

MSChart
, MSChart . Project Components Microsoft Chart Control 6.0.
. :

chartType, . ,
.

PictureClip
. ,
. . 11.4 . PictureClip .
Project Components Microsoft PictureClip Control 6.0.

ImageCombo
ComboBox, .

MSComm
.

162

16. , ,

, ,
.

16.1.
String 4.7. ? . (, ) ,
, , . . .
" ", . Visual
Basic . :

. Visual Basic

"" + ""

& .

"" & "" & ""


+,
,
Len (" ")
9
4, 3-
Mid ("" , 3, 4)

5-
Mid (" ", 5, 1)

Mid .
"":

s = ""
For i = 1 To Len(s)
Debug.Print Mid(s, i, 1)
Next

' i-

:
( ), "" "3
"
"" ""
InStr ("", "") 0
2
Left ("", 2)

3
Right ("", 3)


Ucase ("")


Lcase ("")

InStr ("", "")

2.5 () Val, , 4.10 () - Str, . :


, ,
Val ("20 8 ")
20


Val (" - 1
0")
-10
"2" & "0" "20", Val ( "20" ) 20
3 * Val ( "2" & "0" )
60
25 "25". , , Visual Basic Str (5 * 5)
25
, , .
, , , ,
, , . , . ? ,
. "" " " . , , . . :

"" & LTrim(" ") & "" LTrim


"" & RTrim(" ") & "" RTrim
"" & Trim (" ") & ""
Trim

163

ASCII
, , ASCII. . Asc. Chr - :

ASCII 219
Asc ("")
219
219 ASCII
Chr (219)

ASCII 256 , 0 255. , , 32-:


For i = 32 To 255
Debug.Print Chr(i);
Next
:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz
{|}~ -

124:
125:

, Debug.Print Chr(Asc("") + 1) ?

" ". , - , , .
. , 6 ,
. , .

126: . . , . .
, ( ASCII).
. , , . ,
, . .
: , ,
1, , , . : Dim s(20) As String * 1. .
. , "". , .

16.2.
, . , ?
, , .
, ? ?
- ( 1). , , .
, , . ,
, . , .
, . .
. , . , , , , ,
.
, 2. ,
, - , , .
Visual Basic . - .
, , . , - , , , - .
, , , ,
, , . ,
"" , . , ,
.
, .
.
1: "" 1998 c: Filimon.txt,
VB.
: , .
. Filimon.txt , .
1.

164
, . . , :
:
:

Open

"C:\VB\Filimon.txt"
"C:\VB\Filimon.txt"

For

Output

As

#1
1

, . , . , , - , . :
Private Sub Command1_Click()
Open "C:\VB\Filimon.txt" For Output As #1 ' Filimon.txt VB C 1
Write #1, ""
' 1 ""
Write #1, 1998
' 1 1998
Close #1
' 1
End Sub
, Write. Close.
, . Visual Basic Windows,
, Filimon.txt. , , Notepad , :
""
1998
Write :

Write #1, "", 1998


:
"",1998
, - , Output
Open Append.
, , ,
. - , . Open . Visual Basic .
Open , . :

Open App.Path & "\Filimon.txt" For


App.Path - , .
, . -
, , . , .
2: Filantrop.txt :
1999
""
"", 2000
.
.
:
Private Sub Command3_Click()
Dim a1 As Integer
Dim a2 As String
Dim a3 As String
Dim a4 As Integer
Open App.Path & "\Filantrop.txt" For Input As #1
Input #1, a1
' 1-
Input #1, a2
' 2-
Input #1, a3, a4
' 3-
Close #1
Debug.Print a3, a4
End Sub
Immediate:

' ,
'
'
'
' 1 Filantrop.txt

' 1

2000

, Input. Close. , , , "" .


3: ,
Filantrop.txt. , , . , , ,
. , , . , , , String.

165
, Filantrop.txt:
Private Sub Command4_Click()
Dim s1 As String
' ,
Dim s2 As String
'
Dim s3 As String
'
Open App.Path & "\Filantrop.txt" For Input As #1
' 1 Filantrop.txt
Line Input #1, s1
'
Debug.Print s1
Line Input #1, s2
'
Debug.Print s2
Line Input #1, s3
'
Debug.Print s3
Close #1
' 1
End Sub
String Line Input. Immediate:
1999
""
"", 2000
, , 2. , Line Input
, . .
, , s3 "", 2000, .
- ,
, , , , , .
4: f 10 . .
:
Dim s(1 To 10) As String
Private Sub Command1_Click()
' :
Open App.Path & "\f.txt" For Input As #1
' 1 f.txt
For i = 1 To 10
Line Input #1, s(i)
'
Next
Close #1
' 1
' :
For i = 1 To 10
s(i) = s(i) & "!"
'
Next
' :
Open App.Path & "\f.txt" For Output As #1 ' 1 f.txt
For i = 1 To 10
Print #1, s(i)
'
Next
Close #1
' 1
End Sub
, Print, Write.
, 2.
, Print , .
5: , .
: For , .
: ", ". . EOF
(End of File), "", , , True, - False.
:
Do While Not EOF(1) ', 1
Line Input #1, s(i)
i=i+1
Loop
, ,
:
6: .txt 10. , , . . , . ,
10, , .
:
1. , .
2. ,
. .
. 1 .

166
:
Dim As Integer
Private Sub Form_Load()
Open App.Path & "\.txt" For Input As #1
Input #1,
Close #1
End Sub
Private Sub Timer1_Timer()
Debug.Print
= + 1
End Sub

' 1 .txt
' ,
' 1
' ,
'
'

Private Sub Form_Unload(Cancel As Integer)


Open App.Path & "\.txt" For Output As #1
' 1 .txt
Write #1,
' ,
Close #1
' 1
End Sub
Form_Unload. , Form_Terminate,
. .
.
, .
.

127: " ". 1 .


. . , ,
, - "" "".
,
. ,
. , , - , , .


Visual Basic , Windows,
: , , .
c temp 222, 333, 666, 999 1.txt.
:

FileCopy "c:\temp\1.txt", "c:\temp\2.txt"


FileCopy . : - , - , .
1.txt 2.txt
FileCopy "c:\temp\1.txt", "c:\temp\222\4.txt"
1.txt c:\temp\222 4.txt
Name "c:\temp\222\4.txt" As "c:\temp\222\5.txt" Name As . , FileCopy. 4.txt
5.txt .
Name "c:\temp\222\5.txt" As "c:\temp\5.txt"
5.txt temp.
Kill "c:\temp\5.txt"
Kill .
:
Name "c:\temp\333" As "c:\temp\444"
333 444.
Name "c:\temp\666" As "c:\temp\222\666"
666 222.
MkDir "c:\temp\888"
888.
RmDir "c:\temp\888"
888.
.
. , ,
. , c:\temp\999, ,

FileCopy "c:\temp\999\22.txt", "c:\temp\999\44.txt"


, :

ChDir "c:\temp\999"
:

FileCopy "22.txt", "44.txt"


CurDir , . Debug.Print CurDir.

167

16.3. Shell
Shell , , Windows. ,

y = Shell ("C:\WINDOWS\Notepad.exe")
Windows - (Notepad).
. :

y = Shell ("C:\WINDOWS\Notepad.exe C:\Untitled.txt")


C:\Untitled.txt.
, :

y = Shell ("C:\WINDOWS\Notepad.exe C:\Untitled.txt", vbMaximizedFocus)


. : vbHide, vbNormalFocus, vbMinimizedFocus,
vbNormalNoFocus, vbMinimizedNoFocus.

16.4. . On Error
, Visual Basic, . , :
Private Sub Command1_Click()
Open "a:\.txt" For Input As #1
Input #1, a
Close #1
Debug.Print a
End Sub
. Open , Visual Basic
. , , . , , , , , . , ,
, , . ,
, .
- 5.9,
.
:
Private Sub Command1_Click()
On Error GoTo m1
Open "a:\.txt" For Input As #1
Input #1, a
Close #1
Debug.Print a
Exit Sub
m1: MsgBox (" . , .")
End Sub
: . On Error GoTo m1 : " m1". On Error
, . Visual
Basic , , . On Error , , ( Open Input). , , , - .
, MsgBox, .
Command1. .
Exit Sub. , MsgBox , .
. -, , - Open Input.
-, : , .. On Error GoTo m1 Open, Input, On Error GoTo m2. Input , m2., Open , m1.
Err, Number . , , :
If Err.Number = 71 Then
MsgBox (" .")
ElseIf
: HelpContents MSDN Library ( ) Visual

168
Studio documentation Visual Basic documentationReferenceTrappable Errors.

169

17. .

- .

17.1. .
. , 10+Abs(-20) 30,
Abs(-20) -20. - ,
, , , -
, . 11.1, 16.1
.
, :
: , .
perimetr(10,4), 10 4. ,
, :
Private Function perimetr(dlina As Integer, shirina As Integer) As Long
perimetr = 2 * (dlina + shirina)
End Function
Private Sub Command1_Click()
Debug.Print perimetr(10, 4) + perimetr(20, 30) + perimetr(3, 8)
End Sub
Command1 : 10*4, 20*30 3*8.
, , perimetr, , .
, . :

( Long).

- ,
, ( perimetr=2*(dlina+shirina)).
. - (Portos, Aramis 10.2, __ 100, 200, vbBlue 10.5), -
(10+Abs(-20) , Debug.Print perimetr(10,4) + perimetr(20, 30)).
:
: , " ?"
, " ".
:
Dim q As String
Private Function ( As String) As String
If = " ?" Then = Date Else = " "
End Function
Private Sub Command1_Click()
q = InputBox(" ")
Debug.Print (q)
End Sub
Command1 InputBox . q. (Debug.Print (q)) .
, , q,
. : , ,
,
. , , , .

170

128: , . , fib(8) - 8- .
: , , , , f.

17.2.
, .
Visual Basic . , . .
, .
, , . , . .
,
. , .
. (19.4).
:
Dim a As Integer
'a -
Private Sub 1()
a=1
End Sub
Private Sub 2()
Dim b As Integer
b=2
End Sub
Private Sub 3(c As Integer)
Debug.Print c
End Sub

'b -

'c -

Private Sub Command1_Click()


1
Debug.Print a
End Sub
a - , b c - . , a . . Command1. 1. . 2
3 . .
b 2. :
Private Sub Command2_Click()
2
Debug.Print b
' . b 2
End Sub
Command2. 2 . c.
? ? .

. , , - . , , . , , .
, . ,
, .
. "" , . y
x:
Dim x As Integer
'x -
Dim y As Integer
'y -
Private Sub B()
y = 10 * 10
Debug.Print " ";
End Sub
Private Sub Command1_Click()
x=5
B
Debug.Print x
End Sub
, , , :

171
5
. , -
, , . , , 10*10
y, x. :
x = 10 * 10
,
100
, . . ,
, . ,
10*10 , , ,
, , , :
Dim x As Integer
'x -
Private Sub B()
Dim x As Integer
'x -
x = 10 * 10
Debug.Print " ";
End Sub
Private Sub Command1_Click()
x=5
B
Debug.Print x
End Sub

5
: , , Visual Basic , . ,
, , , ,
. . , x x.
, , . . , , .
, ,
. , x, , , , x, .
:
Dim x As Integer
'x -
Dim z As Integer
'z -
Private Sub B()
Dim x As Integer
Dim y As Integer
x = 20: y = 30: z = 40
End Sub

'x -
'y -

Private Sub Command1_Click()


x = 1: z = 2
'x z -
B
Debug.Print x, z
'x z -
End Sub

1

40

: Debug.Print x, z , =20,
, . =1, . z , , z=40
2 40.
:
Visual Basic Z .
Command1_Click = 1 Z = 2. , ? X Z Command1_Click , .
. .

172
= 20, = 30 Z = 40.
. = 20 = 30.
= 1 Z = 40.

, , - .
, , .


. ,
, . ,
:
Private Sub Command1_Click()
Dim As Integer
Dim As Integer
= Text1.Text
= +
End Sub
, :
Private Sub Command1_Click()
Dim As Integer
Static As Integer
= Text1.Text
= +
End Sub
.

17.3.
. ,
y = perimetr (10 , 4)

a = 4 : y = perimetr (10 , a)

a = 3 : y = perimetr (10 , a+1).


, , ,
. , ,
Variant. .
: , . . sum, .
:
Dim a(1 To 2) As Integer
Dim b(1 To 2) As Integer
Private Function sum(c As Variant) As Integer
sum = c(1) + c(2)
End Function
Private Sub Command1_Click()
a(1) = 10: a(2) = 20
b(1) = 40: b(2) = 50
Debug.Print sum(a), sum(b)
End Sub
sum(a), Visual Basic a, ,
c. sum(b), Visual Basic b.

129. . - 5 . . , ( , ,
).
: (c), (c) (c).

173

17.4.
- . .
, :
Dim A As Integer
'
Dim P As Integer
'
Dim S As Integer
'
Private Sub ( As Integer, As Integer, As Integer)
= 4 *
= ^ 2
End Sub
Private Sub Command1_Click()
A = 10
A, P, S
Debug.Print "="; A; "="; P; "="; S
End Sub
:
= 10 = 40 = 100
10. , , P S, , . , . ,
, :

Private Sub ( As Integer, ByRef As Integer, ByRef As Integer)


.
A, P S
, . , . . , , - , - , , , =1. , :
Private Sub ( As Integer, As Integer, As Integer)
= 4 *
= ^ 2
= 1
End Sub
:
= 1 = 40 = 100
, , - , . :

Private Sub (ByVal As Integer, As Integer, As Integer)


, , A . ,
. .
. ,

Private Sub (ByVal As Integer, ByVal As Integer, ByVal As Integer)


:
= 10 = 0 = 0

130: (A B) .
365. , : A
2 , B - 3 .
, . -
, - .

17.5. .
- , .
. N 1 N. , 1*2*3*4*5, 120.
1.
. , , , .
. :
" 1. N, , N,
N-1."
, - . . -

174
N, , 100. : 100 100,
99.
? , - , , ? :
: 3 . ,
. .
: 2 .
, . .
: 1. , - -
. .
. 2 1, 2. .
. 3 2, 6.
!

, . .
:
? ,
, - Visual Basic. ,
.
N, Factorial(N), :
" N=1, Factorial(N) = 1.
N>1, Factorial(N) N Factorial(N-1)."
Visual Basic Factorial :
Private Function Factorial(ByVal N As Integer) As Long
If N = 1 Then Factorial = 1
If N > 1 Then Factorial = N * Factorial(N - 1)
End Function
Private Sub Command1_Click()
Debug.Print Factorial(3)
End Sub
- ! , .
, Factorial - Factorial(N-1).
:
?
:
, Visual Basic Debug.Print Factorial(3). Factorial. , , N. 3 N,
N 3. . 3>1, Visual Basic
3* Factorial(3-1)
Factorial(2), , ,
Factorial(3), , .
. N. N,
! N 2. . , Visual Basic , .
2>1, Visual Basic 2* Factorial(2-1) Factorial(1), .
. N.
N 1. . 1=1, Visual Basic Factorial=1. . Visual Basic if N>1 then Factorial =
N* Factorial(N-1). , 1>1,
. .
. Visual Basic (, N=2) - Factorial =2*1=2.
. Visual Basic (, N=3)
- Factorial =3*2=6. .

, .
? , , . :
- .
? ,
, .

175

131:

fib .

17.6.
Visual Basic. .
: 8 2 5 4. (2 4 5 8) (8 5 4 2). ( ).
- , - .
: 100 . .
: , ,
, . 100 ?
100 . ,
, ( 0).
,
- 0. .
10 :
Const N = 10
'N -
Dim massiv_ishodn(1 To N) As Integer
'
Dim massiv_rezult(1 To N) As Integer
'
' m(1 To N).
' (maximum) (Nomer_max):
Private Function maximum(m, N As Integer, Nomer_max As Integer) As Integer
Dim i As Integer, max As Integer
max = m(1): Nomer_max = 1
'max - ""
For i = 2 To N
If max < m(i) Then
max = m(i)
Nomer_max = i
End If
maximum = max
Next
End Function
' mass_ish N - mass_rez:
Private Sub sortirovka(mass_ish, N As Integer, mass_rez)
Dim Nom_max As Integer
For i = 1 To N
mass_rez(N + 1 - i) = maximum(mass_ish, N, Nom_max)
' " "
mass_ish(Nom_max) = 0
' -
Next
End Sub
Private Sub Command1_Click()
massiv_ishodn(1) = 41
massiv_ishodn(2) = 8
massiv_ishodn(3) = 17
massiv_ishodn(4) = 82
massiv_ishodn(5) = 20
massiv_ishodn(6) = 2
massiv_ishodn(7) = 30
massiv_ishodn(8) = 12
massiv_ishodn(9) = 6
massiv_ishodn(10) = 9
sortirovka massiv_ishodn, N, massiv_rezult
For i = 1 To N
Debug.Print massiv_rezult(i);
Next
End Sub

'

'
'

maximum, , ,
- Nomer_max. .
. - . ,

176
, 100 100*100=10000
.
. - . . . .
. . .
, , , .
: , , ,
, . .
- , , , .
. - ,
, , .
, , 100 , 99 . . .
, .
:
Const N = 10
'N -
Dim massiv(1 To N) As Integer
'
' mass Razmer:
Private Sub puziryok(mass, Razmer As Integer)
Dim i As Integer
For m = Razmer To 2 Step -1
' - 9
For i = 1 To m - 1
'i -
If mass(i) > mass(i + 1) Then
'
c = mass(i)
'
mass(i) = mass(i + 1)
' c
mass(i + 1) = c
End If
Next i
Next m
End Sub
Private Sub Command1_Click()
massiv(1) = 41
massiv(2) = 8
massiv(3) = 17
massiv(4) = 82
massiv(5) = 20
massiv(6) = 2
massiv(7) = 30
massiv(8) = 12
massiv(9) = 6
massiv(10) = 9
puziryok massiv, N

'

'

For i = 1 To N
Debug.Print massiv(i);
'
Next
End Sub
, , .

132:

. - , :
(1,1) <= a(1,2) <= ... <= a(1,N) <=
<= a(2,1) <= a(2,2) <= ... <= a(2,N) <=
<= a(3,1) <= a(3,2) <= ...

17.7. ,
. . Times
20, - , . :
Private Sub __ (_ As Control)
_.Font = "Times"
_.FontSize = 20
_.FontItalic = True
_.ForeColor = vbBlue
End Sub
Control - .

177
:
Private Sub Command1_Click()
__ Label1
__ Text1
End Sub

178

18. ,

"" . , ,
Windows, Microsoft Word, Visual Basic .
, , .
CommonDialog, Toolbar, ImageList. . , , ,
, , .

18.1. "" Windows


, " " Windows. ,
, , - . Microsoft Word , Paint Visual Basic . , . ,
Visual Basic , .
Windows
Visual Basic
?

MDI Form

Menu Editor

HScrollBar, VScrollBar

,
Toolbar, CoolBar, ImageList

,
CommonDialog

,
CommonDialog

,
CommonDialog

CommonDialog

CommonDialog
Help

CommonDialog
, CommonDialog. Visual
Basic - , Windows.

18.2. CommonDialog
, , .. , Windows? , . , , . Windows.

, , , , . Save As. , , , ( -

179
, 19.1).
. , , .
Visual Basic CommonDialog, . . , - .
Common Dialog - .
, . , , , :
Common Dialog Toolbox ProjectsComponents. Microsoft Common Dialog Control 6.0. . - Common Dialog1.
:

, Common Dialog1

CommonDialog1.ShowOpen

CommonDialog1.ShowSave

CommonDialog1.ShowColor

CommonDialog1.ShowFont

CommonDialog1.ShowPrinter
Help
CommonDialog1.ShowHelp

Common
Dialog
Common Dialog, . : Command1
, , ,
Command2 ( ), Command3 , . :
Dim s As String
'
Private Sub Command1_Click()
CommonDialog1.ShowOpen
= CommonDialog1.FileName
Open For Input As #1
Line Input #1, s
Debug.Print s
Close #1
End Sub
Private Sub Command2_Click()
s = s & "!"
End Sub

'
'
'
'

' -

Private Sub Command3_Click()


CommonDialog1.ShowSave
'
= CommonDialog1.FileName '
Open For Output As #1
'
Print #1, s
'
Debug.Print s
Close #1
End Sub
: CommonDialog1.ShowOpen ( , ), ,
- . ,
FileName CommonDialog, Open.
.
Windows, Word Paint, , . , . .
.
.
. , ,
. , ,
. , Cancel .
, Open , . .
"" , :
Dim s As String
'
Private Sub Command1_Click()
CommonDialog1.ShowOpen

'

180
= CommonDialog1.FileName ' -

End Sub
Private Sub ()
Open For Input As #1
Line Input #1, s
Debug.Print s
Close #1
End Sub
Private Sub Command2_Click()
s = s & "!"
End Sub

'

' -

Private Sub Command3_Click()


CommonDialog1.ShowSave
'
= CommonDialog1.FileName ' -
, s
' s
End Sub
Private Sub (, s As String)
Open For Output As #1
Print #1, s
'
Debug.Print s
Close #1
End Sub

18.3. Toolbar
. Windows.
Visual Basic 1.3. , , , ,
.. .
, Microsoft Word 97:

tbrDefault

tbrPlaceholder -
, ,

tbrCheck -,

tbrButtonGroup -


: . Visual Basic , , Debug.Print " "). Visual Basic


- , , Debug.Print " "). .
:
1. Toolbox Microsoft Windows Common Controls 6.0.
ProjectsComponents. : Toolbar ImageList.
2. Toolbar ImageList . Toolbar "" ,
- . , 6 . ImageList
. - ,
.
3. ImageList , Visual Basic Graphics. ImageList Properties (Property Pages) . Images, Insert Picture,
Open. ,
Images, Index 1. Insert Picture .
- 2. . , OK.

181

4.

5.

Toolbar , ImageList.
Toolbar Properties (Property Pages) .
General ImageList , ImageList . Buttons, Insert
Button, , Index 1. (Style)
- Image Key (). Image ImageList, . Key , , , .
ToolTipText, . , Insert Button . . , OK.

. .
, Select Case :
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case " "
Debug.Print " "
Case " "
Debug.Print " "
End Select
End Sub
6. ( , ).
. Align,
.

182
Toolbar , Coolbar,
.
, , , , Windows, Microsoft Word.

18.4. - " "


CommonDialog . :

, .

BMP.

BMP.
:

,
. .
(, !):
Dim As Long
'
Private Sub Form_Load()
AutoRedraw = True
BackColor = vbWhite
= vbBlack
DrawWidth = 3
End Sub

' :
' -
' -
'

Private Sub Command1_Click()


'
CommonDialog1.ShowOpen
Form1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Command2_Click()
'
CommonDialog1.ShowSave
SavePicture Image, CommonDialog1.FileName

183
End Sub
Private Sub Command3_Click()
CommonDialog1.ShowColor
= CommonDialog1.Color
End Sub

'

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)


PSet (X, Y),
'
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case " "
' ,
DrawWidth = 3
'
Case " "
' ,
DrawWidth = 20
'
End Select
End Sub
:

CommonDialog1.ShowOpen
= CommonDialog1.FileName
Form1.Picture = LoadPicture()

CommonDialog1.ShowOpen
Form1.Picture = LoadPicture(CommonDialog1.FileName)

SavePicture Image, CommonDialog1.FileName


, , , CommonDialog1.FileName. Image .
.
" ", - " ".
Form_MouseMove :

, , , , . , MouseMove , ,
, .

, , ,
.
:
Dim __ As Boolean
'
' ( ) MouseMove:
Dim X_ As Long
Dim Y_ As Long
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If __ Then
' :
Line (X, Y)-(X_, Y_),
' MouseMove, :
X_ = X
Y_ = Y
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
__ = True
' :
X_ = X
Y_ = Y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
__ = False
End Sub
:
, , - MouseDown MouseUp
MouseDown.
, . ,
, .

184


, :

, Paint. - ,
.

, , , ().

(). .

, ,
, .

: , , .. .

185

19.

- , "".
.

19.1.
, , . , . , , . ,
. , , . ,
, .
, . , .
, .
. , , Form1. ,
ProjectAdd FormNewFormOpen. Form2, . ,
, Visual Basic
, . , ,
. , .

. , , Form1, Form2 . ,
Form2.Show. Command1 - Form2 .
Command2 . Command2_Click
. , , - . ,
, , , - - ,
, - . Visual Basic -

186
, , ,
, - . , . , BackColor =
vbBlue Form1.BackColor = vbBlue - Me.BackColor = vbBlue. Me
.
Command3 . Command3_Click
. , Text2 , - Text1 . ,
, , , , , .
3- cls Print -
(11 , 22 ). Me , Visual Basic cls: . 4-
- (21 , 12 ).
, , , , , . :
, , - .

19.2.
: , . . , ,
. , -
. , .
( ):
ProjectAdd ModuleNewModuleOpen. , Module1. . , , ,
. - , - . , , - .
, ,
Main, . :

: Project Project1 Properties General Startup Object Visual Basic


, - Form1, Form2 Main.
, , Sub MainOK.
, , InputBox 1 2. 1, Form1, 2 - Form2.
, , . , .
, . 20.

19.3. . Project Explorer.



, Project Explorer.

187



, . ,
, Project1 : Form1, Form2 Module1.
.
. . Project Explorer
, ,
.
, Project Explorer , Remove. , ,
, . InputBox, - MsgBox, - .


Visual Basic , Visual Basic . , -
.
. , , ,
File Open Project ( ), . File Add
Project ( ). , ,
( New) ( Existing). Open. .
, , . , , , , .
Project Explorer Visual Basic :

, Start ? , Project Explorer ,


Set as Start Up. ( ),
Remove Project.

19.4.

Visual Basic - , Visual Basic. 17.2 , , , , . . , .
? . Visual Basic 3 :

188
1

,
,
.

Dim
Dim Private
,

3 ( Public
)
,
, - , - . :
Public a As Integer
'
Private b As Integer
'
Private Sub Command1_Click()
Private c As Integer '
.......
End Sub
. .
, . : Form1
Form2. 1:
Public a As Integer
Private Sub Command1_Click()
Form2.Show
a = 10
End Sub
Public a ( ), .
1, a 10.
2:
Private Sub Command1_Click()
Debug.Print Form1.a
End Sub
2, 10 - a.
, , , , . Visual Basic , , ,
"". Debug.Print Form1.a Debug.Print a. , Visual Basic , a "", 2. ( , , Visual Basic .) "" a , .
, 1 a 10, 2 a Empty (a=Empty).
"", .
, , , Public. . , ( ), Dim. Dim Private. , Private ( , ) , .



Visual Basic 2 :
1
,
.
2 ()

2.
1:
Private Sub Command1_Click()
Form2.2
End Sub
2:
Public Sub 2()
Debug.Print " 2"
End Sub
1 " 2".

Private
Public


Visual Basic , , 3 :
1 - , - Const

189
2
3 ()

,
.

Const
,
Public Const ( ).

, . Private Public
. , 1 :
Public Enum tip
a
b
End Enum
2 :
Dim s As tip
, Public. Visual Basic
.
. Private Public
. .

19.5.
. , Visual Basic
, ? : ,
, . , , ,
, - . . , , , - . , , , -
.
: . 1:
Public a As Integer
Private Sub Command1_Click()
Form2.Show
a=1
End Sub
2:
Public a As Integer
Private b As Integer
Private Sub Command1_Click()
a=2
Debug.Print Form1.a
' 1
Debug.Print a
' 2
b=3
Debug.Print b
' 3
End Sub
Private Sub Command2_Click()
Dim a As Integer
Dim b As Integer
a=4
Debug.Print a
' 4
b=5
Debug.Print b
' 5
End Sub
, , , , , Visual Basic. , ,
: .
, .
. , "". ,
, , , ,
, "". ,
.

190

19.6.
, .
, , : . ,
. , , - . , . cmd, - txt,
Double - dbl.
Microsoft :
Check box
Combo box, drop-down list box
Command button
Common dialog
Directory list box
Drive list box
File list box
Form
Frame
Horizontal scroll bar
Image
ImageList
Label
Line

chk
cbo
cmd
dlg
dir
drv
fil
frm
fra
hsb
img
ils
lbl
lin

List box
Menu
Picture box
ProgressBar
RichTextBox
Shape
Slider
Text box
Timer
Toolbar
TreeView
UpDown
Vertical scroll bar

lst
mnu
pic
prg
rtf
shp
sld
txt
tmr
tlb
tre
upd
vsb

bln
byt
col
cur
dtm
dbl
err
int

Long
Object
Single
String
User-defined type
Variant

lng
obj
sng
str
udt
vnt

- :
Boolean
Byte
Collection object
Currency
Date (Time)
Double
Error
Integer

, , :
, . , , ,
, .
. , , , . " " , . ,

int_ = int_ + 1
y(int_) = 2 * a(int_)

i =i +1

y(i) = 2 * a(i)

19.7. ?
: , , ? , ,
, , ? .
.
, .
, , , . ,
, , , , , . , , , .
, , "" , " ", "" .

191
, . , , ? ,
.
, . , - ,
. . ,
.
: ? , ? - ,
. , . , ,
. , . .
- . ,
.
: 3. 2 .
intA. :
Private intA As Integer
Private Sub Command1_Click()
intA = 3
intA = intA + 2
Debug.Print intA
End Sub
. .
, " ",
, . ,
, , .. ,
" ".
, " ". 1 2,
2, .
Private intA As Integer
Private Sub Command1_Click()
intA = 3
1
2
End Sub
Private Sub 1()
intA = intA + 2
End Sub
Private Sub 2()
Debug.Print intA
End Sub
. . . :
Private intA As Integer
Private Sub Command1_Click()
intA = 3
1 intA
2 intA
End Sub
Private Sub 1(intAA As Integer)
intAA = intAA + 2
End Sub
Private Sub 2(intAAA As Integer)
Debug.Print intAAA
End Sub
, ? ,
. , .
, . .
- ,
. , , intA intB.
( intA intB). . , . , . , , intA. ,
, . - , ,
, . , intA
, , , . , -
. " "? , -

192
- , . .

193

20.

. .
,
.
. ( ) ,
.
. , ,
( , , )
( ,
).
Visual Basic - . - , - .
Windows Windows . Windows . , ,
, , () ,
( ).

20.1. - " "


, , . , , , . , :

( ). - , .

( ). - , .
. :

-
.
. :


.
, , . , :

,
, , , (
)

, ( )
. , ( 4), ,
( 3). , , .
, ( 2 ), ,
(). , , .
. :

, (, , , . ,
). -.

, (, ). .
, , -

194
. :

. , , .
. , , .

- . , :
, -. , , , , , . , , ,
, .
, , . .
-, . ,
. , , -
: - , - .
, -, .
, :
, , "". , - .
. " ", " ".
. .
. (),
.
:

, , .
- , . .
, - .
.
. , , .
. . .

20.2. "".
:

, 10 . . , . : - 4 : , , .

195
- . , . .
( "", ). . 4 : , , , , , ( Ctrl). , , ( ). - 10 . ( )
, . " " . .
? , , . , .

20.3.
. , , "" "". , 11.3 12.3. , , (). , "" ,
, ,
, "" .
. , ( , "" ).
, . 11 : 10 . 1 .
18 . .
1- . 1- , " , ", ,
, . ,
. , "" "" 2- , ,
(), "" .. 10- , , , , , . . . 2- . 2-
. 1- , ( ) , 2-
.
, , . . , ,
: , .
, , , ,
. .
.

20.4.
. . . f.
Shape - . , , . cmd__

txt_
- . - .
. .

20.5.
Visual Basic :
1. . : - . , -. .
2. ("") , , .
. . ( , 10 -).
, cls cls. cls
, cls (1 To 10).

196

20.6.
. , .
, . .
cls. . - , - , , "",
.
, . : Project Add Class Module New Class Module Open.
. , .
, .
.
- cls. . , Visual Basic . .cls. . . .
, , . :
. :

, , , , , ( Ctrl).

, , , .
. " " .
. , , ? - "", "". . ,
"". , , , . - .
, , , .
, , , _.

-
. ,
: , . , , , , .
. ,
- , , ,
, . ?
, - .
Image, img, - img (
img img(1 To 10)). - ,
. . ,
. , . .
, . ,
. . = 10. -
. , .
, .
, :

(1), (2), (10) ,


() .

img(1), img(2), img(10) ,


(1), (2), (10).

, () .

img , .

1 ( ) .
, " ":

0 - . , - 10.

_, .


cls. , -

197
a, Integer. , , ""
:

Public As cls
Public? ( , ), ( , ).
, .
("" ):

Set = New cls


New , cls.
. , . , Form_Load
.


, . , . cls , , , .

Public Const _ = 500
Public As cls

Private Sub Form_Load()
img.Height = _
img.Width = _
Set = New cls
_
KeyPreview = True
txt_.Locked = True
End Sub

' cls

'

'
'
'

Private Sub cmd___Click() '


_
txt_.SetFocus
' ,
End Sub
Private Sub _()
txt_.Text = 0
._
End Sub

'
'

Private Sub Timer1_Timer()


'_ ,
.
' ,
img.Left = .x
'
img.Top = .y
txt_.Text = txt_.Text + 1 ' , 1
End Sub
' - :
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp:
. =
Case vbKeyLeft:
. =
Case vbKeyDown:
. =
Case vbKeyRight:
. =
Case vbKeyControl:
. =
End Select
End Sub
cls
Public x As Long
Public y As Long
Private dx As Long
Private dy As Long
Public Enum

'
'
'

198

End Enum
Public As
Private Sub Class_Initialize()
dx = 100
dy = 100
End Sub

',

Public Sub _()


'
=
' :
x = f.shp.Left + f.shp.Width * 1 / 4 '
y = f.shp.Top + f.shp.Height / 2 '
End Sub
Public Sub ()
' ,
_____
'
If ____ Or __ Then =
'
End Sub
Private Sub _____()
Select Case
Case :
y = y - dy
Case :
y = y + dy
Case :
x = x - dx
Case :
x = x + dx
Case :
' ,
End Select
End Sub
Private Function ____() As Boolean
' , :
If y < f.shp.Top Or y + _ > f.shp.Top + f.shp.Height Then
____ = True
Else
____ = False
End If
End Function
Private Function __() As Boolean
' , :
If x < f.shp.Left Or x + _ > f.shp.Left + f.shp.Width Then
__ = True
Else
__ = False
End If
End Function
. , . . , .
, . , _.
, , Private, , Public,
.
. , , . .
Form_Load. ,
img (. ) _. .
- - Class_Initialize
. .
Form_Load, _, ,
, " ".
, . ,
0, _ _ .
. . ,
, . . , f.shp.Left shp f. ,
.
_ _
f. , Visual Basic Form_Load KeyPreview = True.

199
Form_Load .
, . .
, . ,
, , , , , x y.
. - ? . _ img. , 1/18
Timer1_Timer. - . , .
. Timer1_Timer ..
, , , .
. 0 1. Timer1_Timer . , 1/18
.
, . . Timer1_Timer .. , . ,
. _____.
, Select Case
x y.
. . ____. , , False. , False
__. . , .
Visual Basic Timer1_Timer. x y ,
.
. , . Form_KeyDown .
. Timer1_Timer ., - _____. , x, dx . Timer1_Timer, Visual Basic x img
.
. .
. ,
Private. . 4 1 .
. . . - _ .
Public, . , ,
, . Private, .
. , img, ,

img.Left = .x
img.Top = .y
, . , , ,
, , .
. , dx dy, Private, . , .
x y Public, . .
? ? img.
, x y . . . , ,
, . 20.8.
.

20.7. .
cls . , : cls,
( ) .

Public Const _ = 10
Public Const _ = 200
Public Const _ = 500
Public Const = 200
' ,
Public As cls
' cls
Public (1 To _) As cls ' cls

Public int__ As Integer

200
Private Sub Form_Load()
'
Dim i As Integer
Randomize
'
' :
img(1).Height = _
img(1).Width = _
img.Height = _
img.Width = _
' :
For i = 2 To _
Load img(i)
img(i).Visible = True
Next i
' -:
Set = New cls
For i = 1 To _
Set (i) = New cls
Next i
_
KeyPreview = True
txt_.Locked = True
End Sub

'
'

Private Sub cmd___Click()


_
txt_.SetFocus
End Sub

'

Private Sub _()


Dim i As Integer
txt_.Text = 0
int__ = 0

'

._
For i = 1 To _
(i)._
Next i
End Sub

'
'

' ,

'
'

Private Sub Timer1_Timer()


'_ ,
Dim i As Integer
' :
For i = 1 To _
(i).
' ,
img(i).Left = (i).x
'
img(i).Top = (i).y
Next i
' :
.
' ,
img.Left = .x
'
img.Top = .y
' , 1:
If int__ <> _ Then txt_.Text = txt_.Text + 1
End Sub
' - :
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyUp
. =
Case vbKeyLeft
. =
Case vbKeyDown . =
Case vbKeyRight: . =
Case vbKeyControl: . =
End Select
End Sub
cls
Public x As Long
Public y As Long
Private dx As Long
Private dy As Long
Private _ As Long

'
'
'

201
Private Sub Class_Initialize()
_ = 100
End Sub

',

Public Sub _()


' :
x = f.shp.Left + f.shp.Width * 3 / 4
y = f.shp.Top + f.shp.Height / 2
' :
dx = _ * (1 - 2 * Rnd)
dy = _ * (1 - 2 * Rnd)
End Sub

'

Public Sub ()
If Then ___
__

End Sub

'_ ,
' , ,
', , ,
'

Private Sub __()


If ____ Then
dy = -dy
ElseIf __ Then
dx = -dx
End If
End Sub

'

'
'
' _
' _

'
'

Private Sub ()
x = x + dx
y = y + dy
End Sub
Private Function ____() As Boolean
If y < f.shp.Top Or y + _ > f.shp.Top + f.shp.Height Then
____ = True
Else
____ = False
End If
End Function
Private Function __() As Boolean
If x < f.shp.Left Or x + _ > f.shp.Left + f.shp.Width Then
__ = True
Else
__ = False
End If
End Function
Private Function () As Boolean
'
' ,
If Abs(x - .x - ((_ - _) / 2)) < _
And Abs(y - .y - ((_ - _) / 2)) < _
Then
= True
Else
= False
End If
End Function
Private Sub ___()
x = -10000: y = -10000: dx = 0: dy = 0
'
f.int__ = f.int__ + 1
End Sub
. , . , , , .
. , .
, .
.
. , .
. - _ .
, , . , ,
. .

202
dx dy, - - x y. ,
.
, " ".
cmd___Click Visual Basic _ . dx dy. Rnd
0 1, , dx, dy -100 100.
, .
. , , , , dy = -dy,
. " !" , dx = -dx
. , _=1000 _=1. dx dy, x y.


. :

, , , . . x=x+dx, x < f.shp.Left dx = -dx.


( ): : dx = (dx+0.001).

, , . , .
.

. .
.

20.8.
, - - , , . . - , . .
, . .
, , .
. ? , , .
.


, . .
, . . , , Private.
, "" , "" . . Command1 :
Private Sub Command1_Click()
Dim f1 As New f ' f1 f
f1.Show
' f1
End Sub
Command1. , ,
. , . , .


, , , . x . . x, Private.
, .
x "", - X. "" ,
cls X, X=x:
Public Function X() As Long
X = x
End Function
.x .X. , , X, . , . " "? .
, .
. , . Visual Basic

203
, , : ToolsAdd Procedure Property (
) Public, - X OK. :
Public Property Get X() As Variant
End Property
Public Property Let X(ByVal vNewValue As Variant)
End Property
Property Get " () ", Property Let " ". , , X .
, Variant Long:
Public Property Get X() As Long
X = x
End Property
, , :
Public Property Get X() As Long
X = x + 1000
If x > 5000 Then MsgBox (" ")
End Property

,
: .
, - , , . .
, , , 4 . . , , : , . , , , 4 , , , , - .
3 ? , cls, , cls. , . "" -
. , . () - . , . , . .
, - (),
. , ,
, , . .
- . , _ -. , - . , ,
.
, Visual Basic 6.0 . Visual Basic.NET.

204

21. Visual Basic

, Visual Basic Web- , . , , .


Web-, . , , - . ,
, .

21.1. , Web- HTML


- ,
. . .
( ) , -
. Web-. - " "
. , . - , , . , ,
- , . (Web-) ,
, Web-.
. .
.
, -
, , , , , Web-. .
Web-
. , ( )
, . , ,
, , . Web- .
, .
, , ,
- . ,
.
Web-, , ,
, . , , , . . ? . . , . , : " . ,
. . " . , , , , .
, , , ,
. , , .
. , , . : Internet
Explorer Netscape Navigator.
Web- , HTML.
.

21.2. Web-
Web- " ". .
:

205

Notepad ( "" - Windows) :


<html>
<body bgcolor="#FFDFFF">
<h1> " "</h1>
<i> 30 - </i>
</html>
:

HTML <html> </html>.

<body bgcolor="#FFDFFF"> 16- (.


9.6).

<h1> " ",


. <h2> . ,
- , .
, , .

<i> "", .
HTML- Web-. HTML- htm html. , Web- ,
, .
, Web- HTML-. Web- Microsoft Word FrontPage Express, ,
, Visual Basic . HTML- . Internet Explorer,
HTML- ViewSource.
Web-. HTML- , , (Refresh). HTML-. HTML- .

21.3. Web-
, Web-. "
". Visual Basic (16.2). . 1 . . .
- "" "". , 127,
.
Web-, - Visual Basic. :

cmdTry ""

txtNumber - ,

txtMessage - "", "" " "

txtNumberTry -
:
Dim A As Long
Dim SecretNumber As Long

' -
'

Private Sub Form_Load()


' :
Randomize
SecretNumber = Round(1000000000 * Rnd)
txtNumber.Text = 0
txtMessage.Text = " "
txtNumberTry.Text = 0
End Sub
' :
Sub cmdTry_Click()
A = Val(txtNumber.Text)
'
If A > SecretNumber Then
txtMessage.Text = ""
ElseIf A < SecretNumber Then

206
txtMessage.Text = ""
Else
txtMessage.Text = " "
End If
txtNumberTry.Text = txtNumberTry.Text + 1 '
End Sub
. ,
Web-.
Web-. , :

HTML- . . Visual Basic, VBScript.


Visual Basic. HTML- Visual Basic . ,
VBScript Visual Basic. ,
, . - , ,
Internet Explorer. , , Windows
Internet Explorer. , Windows
.
Internet Explorer HTML-
, , Visual Basic Start.
Internet Explorer. .
, Internet Explorer.
HTML- :
<html>
<body bgcolor="#FFDFFF">
<h1> " "</h1>
<input type="text" size="20" name="txtNumber">
1 ""<p>
<input type="button" name="cmdTry" value=""><p>
- <input type="text" size="30" name="txtMessage"><p>
- <input type="text" size="10" name="txtNumberTry" ><p>
<i> 30 - </i>
<script language="VBScript"><!-'
dim A
' -
dim SecretNumber
'
Randomize
SecretNumber = Round (1000000000 * Rnd)
' :
txtNumber.Value=0
txtMessage.Value = " "
txtNumberTry.Value=0
' :
Sub cmdTry_OnClick()
A = int(txtNumber.Value)
'
if A>SecretNumber then
txtMessage.Value = ""
elseif A<SecretNumber then
txtMessage.Value = ""
else
txtMessage.Value = " "

207
end if
txtNumberTry.Value= txtNumberTry.Value + 1
End Sub
--></script>
</html>
:

<script language="VBScript"><!-

--></script>
Visual Basic. . , Visual Basic. , Dim. Variant. Text Value. Click - OnClick. Val - Int.
:

cmdTry ""

txtNumber - ,

txtMessage - "", "" " "

txtNumberTry -
, Visual Basic ? , HTML. VBScript .
HTML- . :
<input type="text" size="20" name="txtNumber">
1 ""<p>
, Web- .

<input type="text" size="20" name="txtNumber">


Web- . , , , , , input type="text", 20 size="20", name="txtNumber".
- <p>. Web-.
, HTML-
<input type="button" name="cmdTry" value=""><p>
Web- ( input type="button").
value="".
.

21.4.
, Web- (
, - ).
Web- ,
( , 16.2 ), .
, - Web- ?
, , - . ,
. ? , - ? .
, .. . , " " 20- , . . . , -
.
VBScript , , VBScript -, Visual Basic.
, ,
, .
VBScript - .
, . , - , .
( ):

208

.
" ", : INFORMAT.TXT - 0.
: INFORMAT.TXT ,
, 1 " 5 ". ,
, , , .
HTML- :
<html>
<h2>- </h2>
<script language="VBScript"><!-Dim objFs
' -
Dim objFile
' -
Dim sAdres
' -
Dim intSchetchik ' -
sAdres="c:\INFORMAT.TXT"
Set objFs = CreateObject ("Scripting.FileSystemObject")
If objFs.FileExists (sAdres) Then
Set objFile = objFs.OpenTextFile(sAdres, 1)
intSchetchik = objFile.ReadLine
intSchetchik = intSchetchik + 1
Document.Write " " & intSchetchik & " "
Else
Document.Write " "
intSchetchik = 0
Set objFile = objFs.CreateTextFile (sAdres)
End If
objFile.Close
Set objFile = objFs.OpenTextFile(sAdres, 2)
objFile.WriteLine (intSchetchik)
objFile.Close
Set ObjFs = Nothing
--></script>
</html>
: .

sAdres = "c:\INFORMAT.TXT"
, .

Set objFs = CreateObject ("Scripting.FileSystemObject")


. .
, Web-, :

,
. No. : - No.

If objFs.FileExists (sAdres) Then


FileExists objFs, , sAdres.
: c:\INFORMAT.TXT ,

Set objFile = objFs.OpenTextFile(sAdres, 1)


- ( 1).

209

intSchetchik = objFile.ReadLine
. 1,

Document.Write " " & intSchetchik & " "


.
:

Set objFile = objFs.CreateTextFile (sAdres)


.

objFile.Close
, , If - Then Else.

Set objFile = objFs.OpenTextFile(sAdres, 2)


( 2).

objFile.WriteLine (intSchetchik)
.

Set ObjFs = Nothing


.

21.5.
, Web , . : Project Components Microsoft Internet Controls OK.
WebBrowser .

WebBrowser1.Navigate "http://www.yahoo.com/"
,
:

Navigate - WebBrowser1.
, , ,
. , , ,
Visual Basic. WebBrowser1:

Busy. True, - .

DocumentComplete. , .

Stop. , Web-.
.
, Visual Basic (Email), Internet Explorer, , ..
Web-, HTML Word
FrontPage, . .

210

22. Visual Basic

, Visual Basic, -
. , , - , , ,
- , .
, Visual Basic . .
, , , Visual Basic
.

22.1.
, 14.2 . - , , , , :
..
..
..
..
..
..
..


12.4.78
31.11.82
16.10.71
14.2.79
27.1.84
3.3.80


3
3
3
2
2
1

, - . ( ), ( ), ( ), , (, , ). . , ,
14.2, , ,
.
, , -
(). , - ,
. , . . ,
. , 20000 , 1972
, , , .
, 20000 ,
175 180 . .
, , , ,
.
, Visual Basic - Microsoft Access, Microsoft Office Professional. Access
.
Access Visual Basic for Applications, "" Visual Basic
Microsoft Office.
, :

Access, ,
. ,
Visual Basic for Applications.

Visual Basic. ,
,
(, ).
.

211

22.2. Visual
Data Manager
, "" .
:







3.5.1965
15.11.1920
14.7.1974
30.9.1848
12.9.1957
31.12.1831


187
210
118
55
348
26

- : , , , , .
, , 14.2 Visual Basic . Visual Data Manager, Add-Ins. ,
Visual Basic. .
, - "Books" (
, ). : Nazvanie, Avtor, Data,
Kol_stran.
Add-Ins Visual Data Manager File New Microsoft Access ( Microsoft Access, , Visual Data Manager, Access) Version 7.0 MDB.
, MDB.
"" . Visual Data Manager (
, , ):

. . New Table. ( , , - (Avtor) ):

212

. Add Field, ( Nazvanie ):

Type . - . , , ( Close).
, Remove Field.
, Build the Table .
.

22.3. . Data
DBGrid. SQL.
Visual Basic Data,
Toolbox. . Data1. ,
. DatabaseName . , Connect Access, EOFAction - Add New, RecordSource ( Data1) - Books.
. ,

Data1.RecordSource = "Books"
. , -
, , Data .
. - DBGrid. : Project Components Microsoft Data Bound Grid Control 5.0. . DBGrid1. Data,
. :

213
, Data, ,
DBGrid, , . DataSource Data1. True DBGrid1: AllowAddNew (
), AllowDelete ( ), AllowUpdate (
). - Caption.
. . . , , :

Data1, , .
, , . , Visual Basic
"" , " ".
, Delete.
, .
, .
Data DBGrid, , . Data1. DataField
. . DBGrid. , . , , .
. , . -. (current cell), . (DBGrid1.Row) (DBGrid1.Col). DBGrid1.Text . 0, 1. . ,

DBGrid1.Row = 3
DBGrid1.Col = 1
Debug.Print DBGrid1.Text
.
, 2, 3, 4 Kol_str 2- 4-:
Private Sub Command1_Click()
DBGrid1.Col = 3
For i = 2 To 4
DBGrid1.Row = i
DBGrid1.Text = i
Next
End Sub
, :

DBGrid1.Text = DateAdd("d", 1, DBGrid1.Text)

SQL
, , . SQL. , :
Private Sub Command4_Click()
Data1.RecordSource = "SELECT Avtor, Nazvanie, Data FROM Books ORDER BY Data"
Data1.Refresh
End Sub

214
, :
Avtor

Nazvanie





Data
31.12.1831
30.9.1848
15.11.1920
12.9.57
3.5.65
14.7.74

Data1.RecordSource = "Books"
, Data1 Books.
Data1 : Avtor, Nazvanie, Data. ,

SELECT

Avtor, Nazvanie, Data

FROM

Books

ORDER BY

Data

Avtor, Nazvanie, Data

Books

Data

, ,
.
ORDER BY Data ORDER BY Data DESC, .

Data1.Refresh
SELECT .
.
Private Sub Command6_Click()
Data1.RecordSource = "SELECT * FROM Books WHERE Kol_str>100"
Data1.Refresh
End Sub
:

SELECT * FROM Books


, Books.

WHERE

Kol_str

>100

>100

, 100 .
SQL:

SELECT * FROM Books WHERE Avtor = , 21 1970 .


'' AND Data > #21/11/1970# , . ,
'' , , SELECT
, ,
.
SELECT TOP 3 * FROM Books ORDER 3 , .
ORDER BY Data DESC , TOP 3 BY Data DESC
3 .
SELECT * FROM Books WHERE Kol_str 100 200.

BETWEEN 100 AND 200

215

23.
. , .

23.1. Visual Basic


, Visual Basic . Visual Basic,
- . - , ,
.

ActiveX
, , . ,
, Toolbox , Common Dialog, ,
, , . : , New Project Standard EXE, ActiveX Control. , . , . , , ActiveX.
Web-.

Windows API
Visual Basic , . Windows , Windows. Windows Windows API. Windows API , Visual
Basic, , . Visual Basic Windows API, , Visual Basic.
Windows API .

- MDI
Microsoft Word , - . , Word.
. 19.1 , .
,
-MDI.
. , Form1. - Project Add MDI Form.
, , MDIForm1 - . , Form1 . MDIChild Form1 True. . .

OLE

. - , . , Windows Microsoft Word, . , , , Word? . OLE. 3.7 ,
Word. , . Microsoft Excel. , -
OLE, Word, " Excel " .

23.2.
. Visual Basic . , ,
. Visual Basic , , , ..

216
! , - II .
:

-
" ".
.
.
"" 10 10 , , .
, , . - , - 3 3, , 3,
5 . , . , , 20 20. .

-.


. , , (, )
, , : , , , .

, -, . , , , . -.
:
, . -
. , :
- .
, .

.
. . , - . - ,
. . ,
. .
, , .
, . , .
: :
1 - . . 12 , . .
.
2 - . . .
3 - . , ,
, .
.
. ,
. , , 1
.
, .

, . - ,
. , .

. , . ,

217
"". , , , .
, .
, .
,
, , , .
- ,
. .
:

, . .

.
. , , , , , !
: , .
, , .
!

218

1.
" " :
. , , , .
: , , .
.
.
- , " ".
Visual Basic. ,
.
, ..

219

24.


24.1. .
.
: ,
, , , , ,
.. ..? ? , , -
. . ? , , , -
-. , , 17 ,
. , . , :
1.
2.
3.
4. ,
5. 1
6. ,
, , .
- , ? , , . , (, Visual Basic)
:
1.
2.
3.
4.

- .
- .
- .
.

, , , . , , , ..
, ,
, ,
, ,
*
, . , .

- ( , ), , (- - ), .
.
. , , , , ,
. : -,
-; , ; ,
.. , , , .
, ,
*

, . ,
.

220

, - ,
, - , , - -
. , Quake, , , - . Quake , ( , ).
, , ,
.

. , , . ? , , . , . . , - - , , . , CD-R, CD-RW .
, . ,
, , - . ,
.
, : (, ),
.

24.2.
, , , , ,
- . , .
, , - , . , , , , , . , . . , ,
, , .
, ? , .
:

- .
.
. .
, . , .
( ) , ,
. , , ,
( -
). , , ,
.
. , - . , ,
. , , . , , -
, : " ?" , 2500. ,
" ?" ..
. , , - , - ..

, , , , , - .

221

25.

25.1. .
, . , .
, , .
( ):




, :


, , , .
, .

" ". ?
: , ,..., ,..., ... . . (, , ) . , .
. , , , , , . , , .
, . :

1. 5
2.
3. 3
4.
5.
6.
7.

, , .
, , ,
:

222
1.
2.
3.
4.

, , ,
..
, ,

, , ,
, , , , , , .
.

25.2.
? , ,
, . , .
, , ? , , .
? . , , 6 ( 5 ), , , , .
6 7, , .
, , ,
, . , - ,
, .. . , , - .
.
, , . ,
.

133:

, -

25.3. . ?
? , . . , . .
. ?
. , " ", " "
, " ". . . . ,
, . ( 25.1), , ,
, , ,
. ,
.
, . , ? . .
. , . ,
, 25.1, , , , . ,
, , ,
. , :
. , . . , , . , .
, . , - . - ? , .
. , , " ". "
" " " " ".
.
: , , , :

1.
2.
3.

: ( ), . -

223
, . (
), ( 5 ) .

25.4.
, , , ,
. . , , , . , , , .
. , . , . , , -
(, , , ) -
. .
, . , , .
- ,
. , - .
, , ( ).

, :
.
, .

:
.
.
.
.
, .
, "". ,
- , , "" ? , , - . , ,
, "":
1. ""
2. ""
3. ""
, (5-7)/(10+40):
1. 7 5
2. 40 10
3.
4.
, .
.
, ?
, , (),
, .
. ,
, . , , 26.4.

25.5.
? , , , .
. ,
, , - , (
, , ).
- ,
, :



224

,
,

, , , , .
, , , "". , - , - .
, . -
-, "" . ,
.
, , .
, , -, , -, , , , , ..
-, , "
C++". - " " "". , : , , . , ? . , , . ? , , , , , . . , (
) , .

:
Visual Basic

Object Pascal
(Delphi)
Visual C++
Java
Assembler



++
()

Logo

LISP, Prolog

,
,
, , ,

, ,

,

, , . ? -
, . , , . . ,
, ,
.
, , , , .
, , , , .
, , ,
. -. , , .
:

3 + 2
:

Write (3+2)
Visual Basic:

Print 3 + 2
, , ,
( .), ( , .).
, ,
, . , . 3 + 2 , ,
. , , ,
( ) .

, , , , Visual Basic C++ - , ,


.

225

25.6.

.
. . , :

, . .
:

.
, , - .. . - .
.
:
28
60

28 , ,
28 .
60 .

40
90
50
90
40
90
50
90
40
45
36
90
36

,
.
, . - , - - .
. , , , ,
, , , . , ( )
- 60 ( 40), :

, , , - ,
. , . .
. , ,

226
.
? . ,
.

25.7.

, . (.25.1):
0.
1.

2.
3.

4.

5.

, ,
.
, (), , .
. , , , .
.
.
( , , ) . , ,
. , ,
, . , - ,
, .. ( , ).
. ( , , , ,
) , , .. , . , ,
.
, .
. -
, . ,
, . , . . , . , ..
. ,
. , , , !. , , , 37 36
.

25.8.
. . , - , .
- , , , ? , , . . . .
. , , ,
, , . , ,
,
.
: , , , , . , . , ,
. , ..
.
. - ? , . , , , ,
, (),
- , .
, .
. :
1.

( ) . 2.

227
2.
3.
4.
5.

. 3.
. 4.
( ) . 5.
2.

. Visual Basic.
, , , (
, , " 3."). , , , 5, 2-3-4-5. . .
2 3 ,
, . 4
, , , .
. - - , , , . ,
. , .
.
, . ,
.
, .

.. ,
, .
, 25.1 . , ,
, , . ( ). ,
, , . , . 5 :
1. .
2. .
3. .
4. .
5. .
, , 20 . , -. , , , . (
). , :
1.
2.
3.
4.
5.
, , :
1.
2.
3.
.
.

(). :
, , ? . , R , V - .
, , ? , , " ", R , V - . , , . , ,
. :
1.
2.
3.
4.
5.

, - .
, 5.
R, .
V, .
.

228
2,3,4 - . , ,
- . : , , , , - ..
,
:
1. ", - , ?"
2. .
3. "" "", "
!", " !"
4. " - ?"
5. .
6. . . . . . . . . . . . . . .
.............
( , , ).
.
Visual Basic . .

229

26.

, , , . , .
: , , ,
. ,
.

26.1.
. . , , , (), , . , , ,
-, .
, :


, .
: ( ), ( ), , () -. , .
. ,
. ,
, , .

, . , "" - . , , , .. , , , , , , , . ,
" ", " ".
"" , . " "
. , . , ,
- .
,
, . , - -
, .
, ,
. ( , ). 800, ,
800 . 1 .


, . - , ,
. :

230
1.
2.
3.
4.
Visual Basic . Visual
Basic . ,
, . Visual Basic ()
. , Visual Basic, .
, .

. . , . . ( , , , , . .)
, , (
) - , . Visual Basic
, . , . , , , , .
, ,
. , ( ) , ""
, . ( 3) ,
. ,
( ). ,
, - .
( -0.25), , , . (). - , . , , ,
(, ). , , (-0.75) , - . ,
.
, , , , , .
, , , , . , , . 3 -0.25 (
), -0.75 ( ). - ,
, , - , . .
. - , .
10000 , , 10000 .
, ,
. ,
. , , . .
,
() (). - , . .
, . , .
. , .
, , 26.4.

26.2.
. - , . . ? , .
. ,
, , . 5 . 1000 ( , ), , -

231
1000 . , , , . ( , ,
.)
. .
, ,
.

26.3.
, ,
26.1, . . , , .
, 26.1
.
. , . , , ( - ) () - ,
( ),
. Windows. ,
, ,
. , , Visual Basic,
Visual Basic . ,
, () ,
Visual Basic, .
, - Visual Basic
- ( - ). ,
Visual Basic, , , , Visual Basic, , , . , , Visual
Basic ( - ).
, , ,
. - .
. ..
: , ( ..) .
-Visual Basic . Visual Basic
. , , . , Visual Basic . Visual Basic , . , , .. ,
. Visual Basic, , ,
, 26.1.
, . -, ,
, . -, Visual Basic, , ,
. -, .
: .
, , . , . , . - , - , - .
, - , ( !).
. ,
, , , Visual Basic , , ..

26.4.
, "" .
. ,
:

, , .
, , .
, , .
, .

232


.
1. .
2. .
3. . , .
. , , .
4. . , : "
"" " "?". , . : ,
. - .
. - , , .
, . , , "",
. , . , .
, , "? : ,
.
, .
, . , ,
.
5. . , - .
6. . , () . .
7. -. - .
- .


1. (). , (). , , ,
, . . (. ).


, 640 480 . 640480=307200. .
, . , (). , , . ,
, , . . , , - 256 .
2.. , , , , , , , . - , ,
, , .
, . , . () , . , .

233
(),
. , . ,
, .
. .
3. - ,
, .
4.. , , ,
. , . ,
PC Speaker. , .
.
5. . , . .


5 .
1. ( ). : 1) , . - ,
.
2) , ,
4 500 (
1 ) . , , ,
, 100 . ,
, , .
"" - .
, (. ). , . , , 100 50000 .


. ,
, , . - .
: , .. , , , , , .
, , ,
, , , ,
.
2. . . , .
. , .
- . - , ,
, , .
- , , . - .
- .
, , ,
. .
, ,
, , . , . , .
3. - (CD-ROM). - , .

.
- , , , ( 700 ). , , , . ,
- , (, ).

234
4. - (CD-R) (CD-RW). -
. , , -, , .
(, DVD), .
5. -. . . .
. .
.

. .
.
, ,
. .
. , - , .
,
. .
, ,
. , .
. , , ; - . Internet.
,
.

26.5.
, . ?
, , . , - . , .
, - , .
? , ,
*
, , .
(, , , .), . .

? , . () .
, . , . , ,
. (, ) . ,

.-

---.

,
, -
. , - . , , 10000000, - 10010111, 7,
00110111.
, : ? .
,
. . .
. , , ,
:







,
*

-.
, - .
, -.

235
. ,
, 2 .
8 . "" . ,
, .

, - . , . ,
- . - -
, - , .
. , ( ). ,
111
100
010
001
. . . . . . . . . . . . . . . . . . . .
000 ()
, .
, ,
.
. , .., - . - , - .
.
: , . , 88
00111000 00111000, , .
, , . 8
, . , 1 = 8 .
________ _ _________
, , , ,
Visual Basic.

236

2.
Windows.

- ,
Windows. , , Visual
Basic.

Windows
.
, . . . , , ,
, CD-ROM Windows 95 Windows NT 4.0 Windows.
. , . Windows, , .
. " " "". - ()
"", "" ( - ).
"". ( ), ( )
. , , .
- , . , " Windows".
"" . ( "", "
".) Windows - , , ,
, - , . ,
.
, . . "" : "",
" " ..
,
. : "" " "
() " " ,
. ,
.

Windows
Windows, Visual Basic Windows, , ,
. Windows , "". ,
. - ,
.
. - , , . , .
, ( " "):

( " ") .
( , .) , (
!), , , , , -
, , . .
. , ,

237

, :
, ( , ). , . Enter. .
, . - . - - , ,
, -
- ,
. . "". .
Windows .

, - , , , , ,
, Visual Basic. ,
. , , . ,
- , ,
. - - , - .
, Cat.exe "". ( , , ).
, "" .

, . , ("") .
, , , ( "" ). "" .
, . . ().
. "" . .
. . "". .
, , .
"". , ,
. ( , ),
. , . .
- "", .
. , , . . .
, Visual Basic, ,
Visual Basic. "" .
. , . , , " " "". ""
" " , . " "? . - " " .
: , .



, , . - , : , ,
, , . , , . , , .

238
, , Sveta25. : , .
. - , , , Visual Basic, .
.
- , . ,
- . - , - .
- -. . ?
, . . , "". " ", " " .. " " " ", " " ..
? , . .
"" "" ( - ). ""
"". . : "", "", "" .. " " : " " " ".
" " : " ", " " .. "
" -, , , "
2000 ".
, , - .


, .
\ / : * ? " < > |
, ,
.
.
MS-DOS . ,
8 , , - .
, ( ) ,
. . , , ,
, Bulki.Ira. .
(, Visual Basic,
), . , Visual Basic Train,
Train.vbp. (, Visual Basic, )
, , . ,
.

Windows, .
-. Microsoft ( ) - , Windows. , Windows "", - "". ,
.

- . .
. (
) - . , - -

239
, . , " "
" ", - "". ,
- - , . ,
- , - .
, .
. , , ( , ).
, , .
" ". ,
. , .
.
, .
. (, )
, 3.5

. (, )
( Windows Visual Basic) ,
, , .
, , -
, . , ,

C:\\ \ \ 2000 .txt


, .
, -.
. .
. , , , , . , .
. , D, . .
, . , , ,
, , . -
, .
, ? , " 2000 .txt" " ", " ", "", . . . , .
. , , , "" .



,
Visual Basic. Visual Basic - , . Visual Basic .
, ( " "),
Visual Basic . ,
. Tools Visual Basic Options, Editor Auto Syntax Check.
.


Visual Basic, - . - , . , .

240

" " . .
. .

. " Bubble Gum". , , - "". ? - , - . .


, .
.
, .
, "" - "", , . ,
. "", , .
, . - "|".
, , , ,
, , , , , , ,
"|". , ,
.
"", "". "|". , "|".
, BackSpace.
. BS .
"" . . "" .

. "" "" , Shift . - . , ,


"" - . Shift. . Shift .
CapsLock . .
CapsLock. CapsLock, .
. "Bubble Gum". ? ,
- (), . ,
. , . , ,
, . :

Alt - Shift Alt. ,


Alt, Shift.
Ctrl - Shift
Ctrl, Shift.

, En Ru
, .

. . ,
. 0 9.
. Shift. , , - . ,
, , , , , ,
. , Shift, Shift.

241
Alt.

. " Bubble Gum.". "". . - : . , . . . ( ,


Visual Basic ).
- -
. , ,
. , . , "" .
"" "" . , - , - , . "", BackSpace. ,
"" , , "" . " Bubble Gum.".
- Delete. Del.
"". "" "". Delete.
"", .
, BackSpace Delete .
.
. " Bubble Gum.". ""
"". "" "". "" . , "" , "" "Bubble Gum" . " Bubble Gum.".
, , . Insert, Ins, ,
, "" "". , . , Insert.
.


:


-,
- .



.

. .

. , , , ?
. . , , Enter, -
Return, - . . , .
.
. . , ,
. , .
, .
.
, . , - .
, . , , .
. .
- . ,
.

242
? Delete.
? , - .


.
"" .
? Delete
, .

. . .
, . :
, , , , - .
- .
:


, .

, , , , , .
, Visual Basic .
, . ,
.

Delete , , .

, . , , , ,
, .
BackSpace.

-
, .
. , , ,
. , -
.
, , , .
, .
.

,
. ,
.

: , (I),
. , ,
. . ,
. . , . . Visual Basic ,
. :
: ,
(), . .
Copy. . Visual Basic , . , . ,
, Paste. , , .
: Copy Cut. - . : .
, . .
: , Delete Delete .
Edit (Copy, Cut, Paste, Delete)
.

243


, -
! , , , -. , .
. . ,
. , . ,

244


1.
Private Sub _Click()
.Text = Val(1.Text) * Val(1.Text)
End Sub
2.
Private Sub _Click()
1.Text = ""
2.Text = ""
.Text = ""
End Sub
5.
Private Sub __Click()
.Text = Val(1.Text) - Val(2.Text)
_.Left = 2000
_.Caption = "!"
End Sub
Private Sub _Click()
1.Text = ""
2.Text = ""
.Text = ""
_.Left = 3400
_.Caption = "-"
End Sub
6.
0
7.
211.
8.

1001
-100
15

-10

9.
82
10.
Dim a As Long
Dim b As Long
Private Sub Command1_Click()
a = 9000000
b = 1000
b=b+a
Debug.Print b
End Sub

11.
'

245

Dim 1 As Double
'
Dim 1 As Double
'
Dim 1 As Double
'
Dim 2 As Double
'
Dim 2 As Double
'
Dim 2 As Double
'
Dim _ As Double '
Private Sub Command1_Click()
'
1 = 80
1 = 3
2 = 90
2 = 2
'
1 = 1 * 1
2 = 2 * 2
_ = (1 + 2) / (1 + 2)
'
Debug.Print _
End Sub

12.
': .
' , .
'
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim _ As Integer
Dim __ As Integer
Dim _ As Integer
Private Sub Command1_Click()
'
_ = InputBox(" ")
_ = InputBox(" ")
_ = InputBox(" ")
_ = InputBox(" ")
'
_ = _ * _
_ = _ * _
_ = 2 * (_ + _)
_ = _ + _
__ = _ - _
_ = _ - _
'
Text1.Text = _
Text2.Text = __
Text3.Text = _
End Sub
13.
'
Dim R As Double
'
Dim L As Double
'
Dim S As Double
'
Dim Pi As Double
' "", 3,14
Private Sub Command1_Click()
'
R = Text1.Text
'
Pi = 3.1416

246

'
L = 2 * Pi * R
S = Pi * R ^ 2
' 5
Print " ="; Format(L, "0.00000")
Print " ="; Format(S, "0.00000")
End Sub
14.
Dim nazvanie1 As String
Dim nazvanie2 As String
Dim r1 As Double
Dim r2 As Double
Dim v1 As Double
Dim v2 As Double
Dim t1 As Double
Dim t2 As Double
Dim Pi As Double

'
'
'
'
'
'
'
'
' "", 3,14

Private Sub Command1_Click()


'
nazvanie1 = InputBox(" ")
r1 = InputBox(" ( )")
v1 = InputBox(" ( )")
nazvanie2 = InputBox(" ")
r2 = InputBox(" ( )")
v2 = InputBox(" ( )")
Pi = 3.1416
'
t1 = 2 * Pi * r1 / v1
' = 1 = / ,
t2 = 2 * Pi * r2 / v2
' *
' :
Print " "; nazvanie1; " - "; Format(t1, "0"); _
" , "; nazvanie2; " - "; Format(t2, "0"); " "
Text1.Text = " " + nazvanie1 + " - " + Format(t1, "0") _
+ " , " + nazvanie2 + " - " + Format(t2, "0") + " "
End Sub
15.
8

16.
29

17.
6

18.
Dim a As Double
Dim b As Double
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")
If a > b Then Debug.Print a + b Else Debug.Print a * b
Debug.Print " "
End Sub
19.
Dim a As Double, b As Double, c As Double
Private Sub Command1_Click()
a = InputBox(" ")
b = InputBox(" ")
c = InputBox(" ")
If a < b + c Then Debug.Print " " Else Debug.Print " "
End Sub

247

20.
Dim N As Integer, _ As Integer, _ As Integer
Private Sub Command1_Click()
N = InputBox(" ")
If N < 100 Then _ = 3 * N Else _ = 300 + 2 * (N - 100)
_ = 2 * _
Debug.Print _, _
End Sub
21.
Private Sub Command1_Click()
If Command1.Top < 300 Then Command1.Top = Command1.Top + 200
End Sub
22.
Dim k As Integer
Private Sub Command1_Click()
Command1.Left = (Form1.Width - 100) * Rnd
Command1.Top = (Form1.Height - 500) * Rnd
k=k+1
Debug.Print k
End Sub
23.
Dim _ As Integer, _ As Integer
Private Sub Command1_Click()
_ = Int(2 * Rnd)
_ = InputBox(" - 0 1. !")
If _ = _ Then Debug.Print "" Else Debug.Print " "
End Sub
24.
Private Sub Command1_Click()
= InputBox(" ?")
If = "" Then
MsgBox ("!")
ElseIf = "" Then
Form1.BackColor = vbGreen
MsgBox ("!")
ElseIf = "John" Then
MsgBox ("Hi!")
Else
MsgBox ("!")
End If
End Sub
25.
Dim imya As String
Dim vozrast As Integer
Private Sub Command1_Click()
Print ", , ?"
imya = InputBox(" ")
Print " , "; imya; ". ?"
vozrast = InputBox(" ")
Print "! "; vozrast; "! !"
If vozrast > 17 Then
InputBox (" ?")
Print " "
Else
InputBox (" ?")
Print " "
End If
Print " !"
End Sub
26.
Dim a As Double, b As Double, c As Double

248

Private Sub Command1_Click()


a = InputBox(" ")
b = InputBox(" ")
c = InputBox(" ")
If a > b + c Then
Debug.Print " "
ElseIf b > a + c Then
Debug.Print " "
ElseIf c > a + b Then
Debug.Print " "
Else
Debug.Print " "
End If
End Sub
27.
, , 180 184.
28.
Private Sub Command1_Click()
a = InputBox(" ")
If a > 28 And a < 30 Then
MsgBox ("")
ElseIf a >= 30 Then
MsgBox ("")
ElseIf a >= 0 And a <= 28 Then
MsgBox ("")
Else
MsgBox (" ")
End If
End Sub
29.
Dim a As String
'
Dim b As String
'
Private Sub Command1_Click()
a = InputBox(" ")
If a = "" Or a = "" Or a = "" Then
b=a
ElseIf a = " " Or a = "" Then
b = ""
ElseIf a = " " Then
b = ""
Else
b = " "
End If
MsgBox (b)
End Sub
30.
Dim As String
Private Sub Command1_Click()
= InputBox(" ")
Select Case
Case "", "", "", "", "", ""
Print ""
Case "", "", "", "", "", "", "", "", "", "", ""
Print " "
Case "", "", "", "", "", "", "", "", "", ""
Print " "
Case "", "", "", "", "", ""
Print "- , "
Case Else
Print " "
End Select
End Sub

249

32.

10
10
11
13
16
20
25
33.
5 Debug.Print "";
GoTo 5
34.
a = 10000
5 Debug.Print a
a=a-1
GoTo 5
35.
a = 100
5 Debug.Print Format(a, "0.00000000")
a=a/2
GoTo 5
36.
:

m1:

x = x - 0.01

'

:
Private Sub Command3_Click()
y = Image1.Top
' ,
m1: y = y + 0.01
'
Image1.Top = y
' , .
GoTo m1
End Sub
:
m1: y = y - 0.01
'
37 .
Private Sub Command1_Click()
' 1 2 3 4 . . . 100:
a=1
m1: Debug.Print a;
a=a+1
If a <= 100 Then GoTo m1
' 99 98 97 96 . . . 1:
a = 99
m2: Debug.Print a;
a=a-1
If a >= 1 Then GoTo m2
End Sub
38.
Dim a As Double
Private Sub Command1_Click()
a=0
m: Debug.Print Format(a, "0.000"), Format(a ^ 2, "0.000000")
a = a + 0.001
If a <= 1.00001 Then GoTo m
End Sub

250
If a<=1 If a<=1.00001? , ( 4.5). 0.001 a . , :

0,682 + 0,001 = 0,683000000000001


, :

0,999000000000001 + 0,001 = 1,000000000000001


, a=1 ,
.

39.
Private Sub Command1_Click()
x = 2700
m1: y = x / 4 + 20
z = 2 * y + 0.23
If y * z < 1 / x Then GoTo m2
Debug.Print Format(x, "0.000000"), Format(y, "0.000000"), Format(z, "0.000000")
x=x/3
GoTo m1
m2:
End Sub
40.
m1:

x = 300
x = x + 0.01
Image1.Left = x
If x <= 2000 Then GoTo m1

41.
Private Sub Command2_Click()
' :
x = 300
Image1.Left = x
y = 1000
Image1.Top = y
' :
m1: x = x + 0.01
Image1.Left = x
If x <= 2000 Then GoTo m1
' :
m2: y = y + 0.01
Image1.Top = y
If y <= 1500 Then GoTo m2
End Sub
42.
Dim Slovo As String
Dim i As Integer
Private Sub Command1_Click()
i=1
Do
Slovo = InputBox(" ")
Debug.Print i; Slovo; "!"
i=i+1
Loop Until Slovo = ""
Debug.Print " "
End Sub
43.
Dim a As Double
Private Sub Command1_Click()
a=0
Do
Debug.Print Format(a, "0.000"), Format(a ^ 2, "0.000000")
a = a + 0.001
Loop While a <= 1.00001
End Sub

251

44.
Private Sub Command2_Click()
x = 300
Image1.Left = x
y = 1000
Image1.Top = y
' :
Do
x = x + 0.01
Image1.Left = x
Loop While x <= 2000
' :
Do
y = y + 0.01
Image1.Top = y
Loop Until y > 1500
End Sub
45.
v = 20: t = 0:
h = 100:
s=0
Do
s=v*t
h = 100 - 9.81 * t ^ 2 / 2
Debug.Print Format(t, "0.0"), s, Format(h, "0.000")
t = t + 0.2
Loop Until h < 0
46.
Private Sub Command1_Click()
Debug.Print " :";
For i = -5 To 5
Debug.Print i;
Next
Debug.Print " :";
For i = 5 To -5 Step -1
Debug.Print i;
Next
Debug.Print " "
End Sub
47.
N = InputBox(" ?")
For i = 1 To N
a = InputBox(" ")
V=a^3
'
Debug.Print " ="; a, " ="; V
Next i
48.
:

= 300
= 300
= 300

= 1200
= 1200
= 1200

49.
:

= 50

= 150

50.
1)
2)
3)
4)
5)

, 10
, 2
200
1, , 0 -
200, , 0 -

252

51.
c_ = 0
'
c_ = 0
'
c__10 = 0
' , 10
N = InputBox(" ?")
For i = 1 To N
a = InputBox(" ")
If a > 0 Then c_ = c_ + 1
If a < 0 Then c_ = c_ + 1
If a > 10 Then c__10 = c__10 + 1
Next i
Debug.Print " -"; c_; ", -"; c_; _
", , -"; c__10
52.
Dim a As Double, b As Double
Private Sub Command4_Click()
c=0
'
Do
a = InputBox(" ")
b = InputBox(" ")
If a = 0 And b = 0 Then Exit Do
If a + b = 13 Then c = c + 1
Loop
Debug.Print c
End Sub
53.
1)
2)
3)
4)
5)
6)
7)

18
10
5 8
3
10
3
5

54.
s=0
'
For i = 1 To 40
Dlina = InputBox(" ")
Shirina = InputBox(" ")
s = s + Dlina * Shirina
'
Next i
Debug.Print " ="; s
55.
N = InputBox(" ?")
s=0
'
For i = 1 To N
= InputBox(" ")
s = s +
'
Next i
Debug.Print " ="; Format(s / N, "0.000")
56.
N = InputBox(" ?")
proizv = 1
'C , 1. ?
For i = 1 To N
= InputBox(" ")
proizv = proizv *
'
Next i
Debug.Print " "; proizv
57.

253

1)
For k = 3 To 8
For l = 0 To 7
Debug.Print k; l
Next l
Next k
2)
For k = 1 To 3
For l = 1 To 3
For m = 1 To 3
For n = 1 To 3
Debug.Print k; l; m; n
Next n
Next m
Next l
Next k
3)
i=0
'
For k = 1 To 3
For l = 1 To 3
For m = 1 To 3
For n = 1 To 3
i=i+1
Next n
Next m
Next l
Next k
Debug.Print i
4)
i=0
'
For k = 1 To 3
For l = 1 To 3
For m = 1 To 3
For n = 1 To 3
If k <= l And l <= m And m <= n Then i = i + 1 : Debug.Print k; l; m; n
Next n
Next m
Next l
Next k
Debug.Print i
58.
N = InputBox(" ?")
Min = InputBox(" ")
__ = 1
For i = 2 To N
chislo = InputBox(" ")
If chislo < Min Then Min = chislo: __ = i
Next i
Debug.Print Min, __
59.
Dim N As Integer, Min As Integer, Max As Integer, As Integer
Private Sub Command1_Click()
N = InputBox(" ?")
Min = 500 '
Max = 0 '
For i = 1 To N
= InputBox(" ")
If < Min Then Min =
If > Max Then Max =
Next i
If Max - Min > 40 Then Debug.Print "" Else Debug.Print ""
End Sub
60.

254

' Form1 -"" Image1 Image2


' , Image3.
Private Sub Image1_Click()
' "" Image1:
Image3.Stretch = False
' "" Image3
Image3.Visible = False
' Image3
Image3.Picture = Image1.Picture
' "" ""
Image1.BorderStyle = 1
' ,
Form_Factor = Form1.Width / Form1.Height
'
Image_Factor = Image3.Width / Image3.Height
' "" Image3,
If Image_Factor > Form_Factor Then
' , , ...
Image3.Width = 0.9 * Form1.Width
', , ( 1/10)
Image3.Left = 0.05 * Form1.Width
' ( 1/20 )
Image3.Height = Image3.Width / Image_Factor '
Image3.Top = (Form1.Height - Image3.Height) / 2 '
Else
' ...
Image3.Height = 0.9 * Form1.Height
', , ( 1/10)
Image3.Top = 0.05 * Form1.Height
' ( 1/20 )
Image3.Width = Image3.Height * Image_Factor '
Image3.Left = (Form1.Width - Image3.Width) / 2 '
End If
Image3.Stretch = True ' , ""
Image3.Visible = True '
End Sub
Private Sub Image2_Click()
' "" Image2:
Image3.Stretch = False
Image3.Visible = False
Image3.Picture = Image2.Picture
Image2.BorderStyle = 1
Form_Factor = Form1.Width / Form1.Height
Image_Factor = Image3.Width / Image3.Height
If Image_Factor > Form_Factor Then
Image3.Width = 0.9 * Form1.Width
Image3.Left = 0.05 * Form1.Width
Image3.Height = Image3.Width / Image_Factor
Image3.Top = (Form1.Height - Image3.Height) / 2
Else
Image3.Height = 0.9 * Form1.Height
Image3.Top = 0.05 * Form1.Height
Image3.Width = Image3.Height * Image_Factor
Image3.Left = (Form1.Width - Image3.Width) / 2
End If
Image3.Stretch = True
Image3.Visible = True
End Sub

61.
Private Sub Command1_Click()
BackColor = vbWhite
Circle (3300, 1200), 400
DrawWidth = 5
PSet (3450, 1100)
PSet (3150, 1100)
Line (3200, 1400)-(3400, 1400)
DrawWidth = 1
ForeColor = vbRed
Line (3300, 1200)-(3300, 1300)
Line (3300, 1200)-(3050, 1300)
Line (3300, 1300)-(3050, 1300)
ForeColor = vbBlack
Circle (3300, 2200), 600
Line (3500, 1630)-(4550, 1830), , B
Line (2030, 1630)-(3080, 1830), , B
FillStyle = vbSolid
FillColor = vbYellow
Line (3000, 300)-(3600, 800), , B

'
'
'
'
'
'p
'
'
'
'
'
'
'p
'p
'p
' (vbSolid)
'
'

255

FillColor = RGB(220, 220, 220)


Circle (3300, 3600), 800
DrawWidth = 3
ForeColor = vbBlue
Line (2200, 1300)-(1800, 4400)
Font = "Times"
Font.Italic = True
Font.Bold = True
Font.Size = 14
CurrentX = 2700
CurrentY = 3300
Print ""
CurrentX = 2830
Print ""
End Sub

'
'
'
'
'
'
'
'
'
'

62.
Dim c As Long, R As Long, G As Long, B As Long
Private Sub Command1_Click()
x = InputBox(" ")
y = InputBox(" ")
c = Point(x, y)
'
R = c Mod 256
'
BG = c \ 256
'
G = BG Mod 256
'
B = BG \ 256
'
Debug.Print c, R, G, B, " -"; B * 256 * 256 + G * 256 + R
' - R,G,B:
Circle (x, y), 200
DrawWidth = 20
PSet (x, y), RGB(R, G, B)
', - R,G B:
If R > G And R > B Then
Debug.Print " "
ElseIf G > R And G > B Then
Debug.Print " "
ElseIf B > R And B > G Then
Debug.Print " "
Else
Debug.Print " "
End If
End Sub
63.
, , :

x = x + 120
64.
:
x = 200
Do Until x > 8000
65.
100 200.
66.
Dim x As Long, y As Long
Private Sub Command1_Click()
x = 100
y = 6000
Do Until x > 9000
PSet (x, y)
x = x + 100
y = y - 60
Loop
End Sub

256

67.
x = 4000: y = 3000: R = 100
Do Until R > 2500
Circle (x, y), R
R = R + 100
Loop
68.
Private Sub Command3_Click()
BackColor = RGB(0, 0, 150)
ForeColor = vbYellow
'-:
x = 4000: y = 3000: R = 500
Do Until R > 2500
Circle (x, y), R
R = R + 20
Loop
' :
x = 10000: y = 3000: R = 500
Do Until R > 2500
Circle (x, y), R, , , , 1 / 2
R = R + 20
Loop
End Sub
69.
x = 4000: y = 500: R = 0
Do Until R > 2500
Circle (x, y), R, , , , 1 / 2
R = R + 50
y = y + 150
Loop
70.
x = 400: y = 500: R = 0
Do Until R > 1500
Circle (x, y), R
R = R + 20
y = y + 60
x = x + 120
Loop
71.
y=0
Do Until y > Height
Line (0, y)-(Width, y)
y = y + 200
Loop

'
'
'
' = 200

72.
Private Sub Command2_Click()
' :
y=0
'
Do Until y > Height
'
Line (0, y)-(Width, y) '
y = y + 200
' = 200
Loop
' :
x=0
'
Do Until x > Width
'
Line (x, 0)-(x, Height) '
x = x + 200
' = 200
Loop
End Sub

257

73.
Private Sub Command3_Click()
' :
y=0
'
Do Until y > Height
'
Line (0, y)-(Width, y)
'
y = y + 200
' = 200
Loop
' :
x=0
'
Do Until x > Width + 2000
' 2000
Line (x, 0)-(x - 2000, Height) '
x = x + 200
' = 200
Loop
End Sub
74.
x = 100
Do Until x > 8000
Line (x, 3000)-(x + 1000, 4000), , B
x = x + 1500
Loop

'
' 8000
' = 1000, = 4000-3000
' = 1500

75.
Dim x As Integer, y As Integer ' 64
Dim i As Integer
'i - ( 1 8 )
Dim j As Integer
'j - ( 1 8 )
Private Sub Command2_Click()
For j = 1 To 8
' 8
For i = 1 To 8 ' 8
x = 1000 * i
y = 1000 * j
' , , :
If (i + j) Mod 2 = 0 Then _ = vbBlue Else _ = vbYellow
Line (x, y)-(x + 1000, y + 1000), _, BF ' ,
Next i
Next j
End Sub
76.
Dim x As Integer, y As Integer '
Private Sub Command1_Click()
y = 1000
' 1000 6000
Do Until y >= 6000
x = 1000
' 1000 8000
Do Until x >= 8000
Circle (x, y), 300
x = x + 150
' - 150
Loop
y = y + 150
Loop
End Sub
77.

Circle (x, y), 300

If x > 2000 Or y < 5000 Then Circle (x, y), 300
78.

Circle (x, y), 300

If (x > 2000 Or y < 5000) And Not (x > 4000 And x < 5000 And y > 3000 And y < 4000) Then Circle (x, y), 300
:

258

( ) , ( ),
79.
Line (2000, 1000)-(6000, 5500), , BF
'
For i = 1 To 1000
DrawWidth = Round(2 * Rnd) + 1 ' = 1,2,3
PSet (2000 + 4000 * Rnd, 1000 + 4500 * Rnd), 16777216 * Rnd ' 4000 4500? :
'4000=6000-2000, 4500=5500-1000
Next
80.
For i = 1 To 40
Circle (Width * Rnd, Height * Rnd), 200, , , , 1 / 2
Next
81.
Private Sub Command4_Click()
For i = 1 To 150
Circle (Width * Rnd, Height * Rnd), 1000 * Rnd, 16777216 * Rnd
Next
End Sub
82.
BackColor = vbBlack
'
For i = 1 To 200000 ' - . .
' - (Width / 2, Height / 2)
' (Width * Rnd, Height * Rnd):
Line (Width / 2, Height / 2)-(Width * Rnd, Height * Rnd), 16777216 * Rnd
Next
83.
For i = 1 To 1000
' 0 2000,
' - (2000 * Rnd)
' 4000 6000,
' - (4000 + 2000 * Rnd)
' , ,
Line (2000 * Rnd, 6000 * Rnd)-(4000 + 2000 * Rnd, 6000 * Rnd), RGB(100 + 156 * Rnd, 100 + 156 * Rnd, 40 * Rnd)
Next
84.
For i = 1 To 10000
Line (Width * Rnd, Height * Rnd)-(Width * Rnd, Height * Rnd), 16777216 * Rnd, BF
For j = 1 To 1000000: Next
Next
85.
Private Sub Command1_Click() ' 400
BackColor = vbBlack
For i = 1 To 400
DrawWidth = 1 + Round(2 * Rnd)
PSet (Width * Rnd, Height * Rnd), 16777216 * Rnd
Next
End Sub
Private Sub Command2_Click() '
Randomize
DrawWidth = 1
' :
r0 = 500 * Rnd
' :
x = Width * Rnd
y = Height * Rnd
' -
' r0 4 * r0:

259

r = r0
Do Until r > 4 * r0
Circle (x, y), r, vbYellow, , , 1 / 2
r = r + 15
Loop
End Sub
86.
Private Sub Form_Load()
.DeviceType = "WaveAudio"
.FileName = "c:\Windows\Media\Chimes.wav"
End Sub
Private Sub _()
.Command = "Open"
.Command = "Sound"
.Command = "Close"
End Sub

'

Private Sub Command1_Click()


_
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
End Sub
Private Sub Command2_Click()
_
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
End Sub
87.
, , - ? - ?
-
, , ?
! , ?
, , -!
, ! , .
, ?
, - ?
! - !!!
88.
Private Sub Image1_Click()
____
Image3.Picture = Image1.Picture
Image1.BorderStyle = 1
____
End Sub
Private Sub Image2_Click()
____
Image3.Picture = Image2.Picture
Image2.BorderStyle = 1
____
End Sub
Private Sub ____()
Image3.Stretch = False
Image3.Visible = False
End Sub
Private Sub ____()
Form_Factor = Form1.Width / Form1.Height
Image_Factor = Image3.Width / Image3.Height
If Image_Factor > Form_Factor Then
Image3.Width = 0.9 * Form1.Width
Image3.Left = 0.05 * Form1.Width

260

Image3.Height = Image3.Width / Image_Factor


Image3.Top = (Form1.Height - Image3.Height) / 2
Else
Image3.Height = 0.9 * Form1.Height
Image3.Top = 0.05 * Form1.Height
Image3.Width = Image3.Height * Image_Factor
Image3.Left = (Form1.Width - Image3.Width) / 2
End If
Image3.Stretch = True
Image3.Visible = True
End Sub
90.
Dim Otstup As Integer '
Dim Razmer As Integer '
Dim Tsvet As Long
Private Sub __()
Otstup = 300
Razmer = 200
Tsvet = vbRed
Picture1.Circle (Otstup, Otstup), Razmer * 1 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 2 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 3 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 4 / 4, Tsvet
End Sub
Private Sub Command3_Click()
Picture1.Picture = LoadPicture("c:\temp\Balloons.bmp")
__
Picture1.Print , "12.08.2001"
End Sub
91.
Private Sub Form_Load()
.DeviceType = "WaveAudio"
End Sub
Private Sub _(_ As String)
.FileName = _
.Command = "Open"
.Command = "Sound"
.Command = "Close"
End Sub
Private Sub Command1_Click()
_ "c:\Windows\Media\Chimes.wav"
Picture1.Picture = LoadPicture("c:\temp\Rockies.bmp")
End Sub
Private Sub Command2_Click()
_ "c:\Windows\Media\Tada.wav"
Picture1.Picture = LoadPicture("c:\temp\Porthole.bmp")
End Sub
92.
Private Sub __(Otstup As Integer, Razmer As Integer, Tsvet As Long)
Picture1.Circle (Otstup, Otstup), Razmer * 1 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 2 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 3 / 4, Tsvet
Picture1.Circle (Otstup, Otstup), Razmer * 4 / 4, Tsvet
End Sub
Private Sub Command3_Click()
Picture1.Picture = LoadPicture("c:\temp\Balloons.bmp")
__ 300, 200, vbRed

261

Picture1.Print , "12.08.2001"
End Sub
93.
Private Sub (x As Integer, y As Integer, As Integer)
' - 2 (Line)
Line (x, y + / 2)-(x, y - / 2)
Line (x + / 2, y)-(x - / 2, y)
End Sub
Private Sub (x As Integer, y As Integer, As Integer)
' - 3 (Line)
'x y -
Line (x, y)-(x + , y)
Line (x, y)-(x + / 2, y - )
Line (x + , y)-(x + / 2, y - )
End Sub
Private Sub Command1_Click()
4000, 2000, 400
3000, 1000, 800
End Sub
94.
Dim a As Integer, b As Integer
Private Sub _(_ As Integer, As Integer)
= 40
'
For j = 0 To 255
' -
y = j *
'
For i = 0 To 255
' -
x = i * '
Select Case _
Case 1
Line (x, y)-(x + , y + ), RGB(, i, j), BF '
Case 2
Line (x, y)-(x + , y + ), RGB(i, , j), BF '
Case 3
Line (x, y)-(x + , y + ), RGB(i, j, ), BF '
End Select
Next i
Next j
End Sub
Private Sub Command1_Click()
a = InputBox(" 1, 2 3. , 1, - 2, -3")
b = InputBox(" - 0 255")
_ a, b
End Sub
a b - , . , - _ .
95.
Private Sub Command1_Click()
Debug.Print DateAdd("ww", 52, Date)
End Sub
96.
Private Sub Command2_Click()
_ = InputBox(" ")
Debug.Print DateDiff("s", _, Now)
End Sub
97.
Private Sub Command3_Click()

262

_ = InputBox(" ")
' __ .
' .
__ = DateDiff("yyyy", _, Date)
____ = DateAdd("yyyy", __, _)
____ = DateAdd("yyyy", __ + 1, _)
If ____ >= Date Then
'
__ = ____ - Date
Else
__ = ____ - Date
End If
Debug.Print __
End Sub
98.
Private Sub Command4_Click()
_ = #1/1/1920#
Do Until _ > #1/1/2940#
__ = DateAdd("yyyy", 1, _)
___ = DateDiff("y", _, __)
= DatePart("yyyy", _)
If (___ = 366) And Not ( Mod 4 = 0) Then
Debug.Print " -"; , ___
End If
_ = __
Loop
End Sub
( 4) 1920 2940 .
99.
Dim k As Integer
Private Sub Form_Load()
k = 100
End Sub
Private Sub Timer1_Timer()
Debug.Print k
k=k+1
If k > 110 Then Timer1.Enabled = False
End Sub
100.
Dim x As Integer, y As Integer, R As Integer
'
Dim _ As Long, _ As Long
Private Sub Form_Load()
x = 1000: y = 1500: R = 200
DrawWidth = 5
_ = vbBlack
_ = BackColor
End Sub
Private Sub Timer1_Timer()
Circle (x, y), R, _
Circle (x + 1000, y), R, _
Line (x - 300, y)-(x + 1300, y - 400), _, B
For i = 1 To 500000: Next
Circle (x, y), R, _
Circle (x + 1000, y), R, _
Line (x - 300, y)-(x + 1300, y - 400), _, B
x = x + 30
End Sub
101.
Private Sub Timer1_Timer()

'

'
'
'
'
'
'
'
'

263

Shape1.Top = Shape1.Top - 20
Shape2.Top = Shape2.Top - 20
End Sub
102.
Private Sub Timer1_Timer()
Shape1.Top = Shape1.Top + 20
Shape2.Left = Shape2.Left + 20
End Sub

104.
Dim As Integer, x As Integer
Private Sub Form_Load()
x = Shape1.Left
= 50
End Sub
Private Sub Timer1_Timer()
x = x +
Shape1.Left = x
If x > Width - Shape1.Width Then = -50
If x < 0 Then = 50
End Sub

' ,
' ,

105.
Dim x As Integer, y As Integer, dx As Integer, dy As Integer
'dx - p p,
' p p
' . dy - p
Private Sub Form_Load()
Show '
Line (450, 450)-(6200, 4600), , B 'p
x = Image1.Left: y = Image1.Top 'H p
dx = 40: dy = 60
'Hp - p
End Sub
Private Sub Timer1_Timer()
x = x + dx: y = y + dy
'
Image1.Left = x: Image1.Top = y
'
If x < 500 Or x > 5900 Then dx = -dx 'p p p,
'p p p p
If y < 500 Or y > 4300 Then dy = -dy 'p p p,
'p p p p
' p p
' p p p , p:
If (x < 800 And y < 800) Or (x < 800 And y > 4000) _
Or (x > 5600 And y < 800) Or (x > 5600 And y > 4000) Then Timer1.Enabled = False
End Sub

106.
Dim x As Long, y As Long, x0 As Long, y0 As Long
Dim t As Double, s As Double, h As Double, v As Double
Private Sub Form_Load()
Timer1.Enabled = False
Show
AutoRedraw = True
Line (200, 400)-(400, 4400), , B
Line (0, 4400)-(6400, 4400)
x0 = 400:
y0 = 400
v = 20:
t=0
Image1.Left = x0: Image1.Top = y0
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

'
'
'p p
'H p p
'
'

264

Private Sub Timer1_Timer()


s = 40 * v * t:
h = 40 * (100 - 9.81 * t ^ 2 / 2)
x = x0 + Round(s):
y = y0 + (4000 - Round(h))
Image1.Left = x:
Image1.Top = y
PSet (x, y)
t = t + 0.1
If h < 0 Then Timer1.Enabled = False
End Sub
108.
Private Sub Timer1_Timer()
Label1.FontSize = Label1.FontSize + 1
Label1.ForeColor = Label1.ForeColor + 10
End Sub

'p
'
' ,

110-111.
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then PSet (X, Y)
' ,
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then DrawWidth = DrawWidth + 1
' ,
End Sub
112.
' .
' _, _, _
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyR
_.FillColor = vbRed
_.FillColor = vbBlack
_.FillColor = vbBlack
Case vbKeyY
_.FillColor = vbBlack
_.FillColor = vbYellow
_.FillColor = vbBlack
Case vbKeyG
_.FillColor = vbBlack
_.FillColor = vbBlack
_.FillColor = vbGreen
End Select
End Sub
113.
' Image .
' , , _, _
Private Sub Form_Load()
_.Enabled = False
End Sub
Private Sub __Timer()
.Left = .Left - 20
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
_.Enabled = True
End Sub
Private Sub __Timer()
.Top = .Top - 50
End Sub
115.
1) a(i) = a(i-1) + 4

265

2)
3)

a(i) = 2 * a(i-1)
a(i) = 2 * a(i-1) - 1

116-118.
Dim t(1 To 7) As Integer
Private Sub Command1_Click()
t(1) = 8: t(2) = 14: t(3) = 19: t(4) = 22: t(5) = 25: t(6) = 28:
' :
s=0
For i = 1 To 7: s = s + t(i): Next
Debug.Print s / 7
' :
k=0
For i = 1 To 7
If t(i) > 20 Then k = k + 1
Next
Debug.Print k
',
Min = t(1): nomer = 1
For i = 2 To 7
If t(i) > Min Then Min = t(i): nomer = i
Next
Debug.Print nomer
End Sub
119.
Dim fib(1 To 70) As Currency
Private Sub Command1_Click()
fib(1) = 1: fib(2) = 1
For i = 3 To 70
fib(i) = fib(i - 2) + fib(i - 1)
Debug.Print i, fib(i)
Next
End Sub
120.
Dim t(1 To 3, 1 To 4) As Integer
Private Sub Command1_Click()
t(1, 1) = -8: t(1, 2) = -14: t(1, 3) = -19: t(1, 4) = -18
t(2, 1) = 25: t(2, 2) = 28: t(2, 3) = 26: t(2, 4) = 20
t(3, 1) = 11: t(3, 2) = 18: t(3, 3) = 20: t(3, 4) = 25
Min = t(1, 1): Max = t(1, 1)
For i = 1 To 3
For j = 1 To 4
If t(i, j) > Max Then Max = t(i, j)
If t(i, j) < Min Then Min = t(i, j)
Next j
Next i
Debug.Print Max - Min
End Sub
123.
Private Sub Form_Load()
Label_.Caption = HScroll1.Min
Label_.Caption = HScroll1.Max
Label_.Caption = HScroll1.Value
End Sub
Private Sub HScroll1_Change()
Label_.Caption = HScroll1.Value
End Sub
123-1.
Private Sub Combo1_Click()
Combo2.Text = Combo2.List(Combo1.ListIndex)

t(7) = 26

266

End Sub
124.

125.
Private Sub Command1_Click()
' 6
s = ""
Debug.Print Mid(s, 1, 2) + "" + Mid(s, 3, 2) + "" + Mid(s, 5, 2) + ""
End Sub
Private Sub Command2_Click()
'
s = ""
For i = 1 To Len(s) \ 2
'Len(s) \ 2 -
Debug.Print Mid(s, 2 * i - 1, 2) + "";
' ""
Next
' , :
If Len(s) Mod 2 = 1 Then Debug.Print Right(s, 1)
End Sub
126.
Dim s As String
Dim s1 As String

'
'

Private Sub Command1_Click()


s = ""
s1 = ""
'
For i = 1 To Len(s)
'
_ = Mid(s, i, 1)
'
If _ = "" Then
' :
_ = ""
Else
' , :
_ = Chr(Asc(_) + 1)
End If
s1 = s1 + _
'
Next
Debug.Print s1
'
End Sub
127.
Dim SecretNumber As Long
Dim A As Long
Dim As String
Dim _ As Integer

'
' -

Private Sub Form_Load()


= MsgBox(" ?", vbQuestion + vbYesNo)
If = vbYes Then __ Else __
End Sub
Private Sub __()
Randomize
SecretNumber = Round(1000000000 * Rnd)
txtNumber.Text = 0
txtMessage.Text = " "
_ = 0
txtNumberTry.Text = _
Open App.Path & "\.txt" For Output As #1
Write #1, SecretNumber
End Sub
Sub cmdTry_Click()
A = Val(txtNumber.Text)
If A > SecretNumber Then
= ""
ElseIf A < SecretNumber Then

'
'
'
'
' 1 .txt
'
'
' If

267

= ""
Else
= " "
End If
txtMessage.Text =
_ = _ + 1
txtNumberTry.Text = _
Write #1, _; A;
'
End Sub
Private Sub __()
Open App.Path & "\.txt" For Input As #1
Input #1, SecretNumber
Show
Print " "
Do While Not EOF(1)
Input #1, _, A,
Print _, A,
Loop
Close #1
txtNumber.Text = A
txtMessage.Text =
txtNumberTry.Text = _
Open App.Path & "\.txt" For Append As #1
End Sub
Private Sub Form_Terminate()
Close #1
End Sub

' 1 .txt
'
'
', 1
'
'
' 1

' 1 .txt

' 1

128.
' :
Private Function Fibonacci(Nomer As Integer) As Currency
Dim fib(1 To 70) As Currency
fib(1) = 1: fib(2) = 1
For i = 3 To Nomer:
fib(i) = fib(i - 2) + fib(i - 1): Next
Fibonacci = fib(i - 1) ' i - 1, i Nomer + 1
End Function
' :
Private Function Fibonacci1(Nomer As Integer) As Currency
fib1 = 1: fib2 = 1
For i = 3 To Nomer
fib3 = fib1 + fib2
fib1 = fib2
fib2 = fib3
Next
Fibonacci1 = fib3
End Function
Private Sub Command1_Click()
Debug.Print Fibonacci(68), Fibonacci1(68)
End Sub
129.
Dim a(1 To 5) As Integer '
Dim b(1 To 5) As Integer '
Private Function (c As Variant) As Integer
= c(1)
For i = 2 To 5
If c(i) < Then = c(i)
Next
End Function
Private Function (c As Variant) As Integer

268

= c(1)
For i = 2 To 5
If c(i) > Then = c(i)
Next
End Function
Private Function (c As Variant) As Integer
= (c) - (c)
End Function
Private Sub Command1_Click()
a(1) = 4: a(2) = 5: a(3) = 2: a(4) = 5: a(5) = 4
b(1) = 4: b(2) = 3: b(3) = 4: b(4) = 4: b(5) = 3
If (a) < (b)
Then Debug.Print " " _
Else Debug.Print " "
End Sub
130.
Dim A(1 To 366) As Integer
Dim B(1 To 366) As Integer

' A
' B

Private Sub (ByVal As Integer, ByRef c)


For i = 1 To 4
' , 4 .
c(i) = c(i) +
Next
End Sub
Private Sub Command1_Click()
A(1) = 24: A(2) = 25: A(3) = 28: A(4) = 25
B(1) = 14: B(2) = 16: B(3) = 14: B(4) = 17
-2, A
3, B
For i = 1 To 4
'
Debug.Print A(i), B(i)
Next
End Sub
131.
Private Function fib(N As Integer) As Currency
If N = 1 Or N = 2 Then fib = 1 Else fib = fib(N - 2) + fib(N - 1) ' !
End Function
' .
' N , .
' .
' ? ,
' fib.
Private Sub Command1_Click()
Debug.Print fib(20)
End Sub
132.
' . .
', , , .
' , , ,
' , . . ,
' -
' . "",
'
' , "",
' , .
Const M = 3
Const N = 4
Dim a(1 To M, 1 To N) As Integer

'M - p
'N -
'

Private Function (ByVal As Integer) As Integer

' "" -

269

i = ( + N - 1) \ N
j = Mod N
If j = 0 Then j = N
= a(i, j)
End Function

'
'

Private Sub (ByVal As Integer, ByVal As Integer)


' "" - , , ""
i = ( + N - 1) \ N
j = Mod N
If j = 0 Then j = N
a(i, j) =
End Sub
Private Sub () ' .
For k = M * N To 2 Step -1
For i = 1 To k - 1
If (i) > (i + 1) Then
c = (i)
i, (i + 1)
i + 1, c
End If
Next i
Next k
End Sub
Private Sub Command1_Click()
a(1, 1) = 28: a(1, 2) = 14: a(1, 3) = 49: a(1, 4) = 18
a(2, 1) = 29: a(2, 2) = 28: a(2, 3) = 36: a(2, 4) = 20
a(3, 1) = 45: a(3, 2) = 15: a(3, 3) = 20: a(3, 4) = 25

For i = 1 To M '
Debug.Print
For j = 1 To N
Debug.Print a(i, j),
Next
Next
End Sub

270

1.
2.
3.

.. " : Visual Basic 5", , -, 1998.


- .
, " Visual Basic 6", "", 1999.
- .
- "Visual Basic - "
- , Windows.
.

271


- 43

<> .................................................. 56

! 46

= 56

"

>

" 43
#
# 46, 110
$
$ 46
%
% 46
&
& 46, 120, 157
(
( 44
)
) 44
*
* 43, 141
,
, 50
/
/ 43
:
: 26
;
; 50
@
@ .................................................. 46
^
^ 43
+
+ 43, 52, 157
<
< 56
<=.................................................. 56

> 56
>= .................................................. 56
A
Abs ................................................ 44
ActiveX ......................................... 209
Add .............................................. 147
Add Form ...................................... 31
Add project ................................... 12
Add Project .................................... 31
Add-Ins ......................................... 32
AddItem ...................................... 153
Alignment ..................................... 19
And ............................................... 60
Animation ....................................... 25
App ......................................... 33, 159
Appearance ................................... 18
Append ........................................ 159
As ................................................ 159
Asc .............................................. 158
Assembler .................................... 218
Atn................................................. 44
AutoRedraw .............................. 48, 95
AutoSize ......................................... 89
AVI................................................ 25
AVIVideo ...................................... 25
B
BackColor ............................... 18, 91
BackSpace ................................... 235
BackStyle ....................................... 91
BETWEEN ................................. 208
BMP .............................................. 89
Bold ................................................ 17
Bold Italic ......................................... 17
Boolean ......................................... 116
BorderStyle ................................... 18
break ............................................. 41
Breakpoints ................................... 78
Bring to Front ............................... 92
Busy ............................................ 203
ByRef .......................................... 168
ByVal .......................................... 168
C
Call.............................................. 103
Call Stack ....................................... 80

CapsLock .................................... 234


Caption ........................................... 16
CDAudio ....................................... 21
CD-R .......................................... 227
CD-ROM .................................... 227
CD-RW ...................................... 227
ChDir ......................................... 161
CheckBox..................................... 149
Chr ............................................. 158
Circle ....................................... 94, 96
Clear ........................................... 153
Click ........................................ 12, 125
Close ................................. 20, 25, 159
Cls................................................. 97
Code .............................................. 30
Collection..................................... 147
Color Palette ................................. 30
ComboBox ................................... 152
Command ....................................... 19
CommandButton ......................... 10, 90
CommonDialog ............................. 173
Components .................................. 31
Const .................................... 106, 182
Continue ......................................... 42
Control ......................................... 147
Controls .......................................... 31
Copy ......................................... 29, 31
Count ........................................... 147
Ctrl-Alt-Del....................................... 28
Ctrl-Break ..................................... 68
CUR .............................................. 89
Currency .................................... 45, 46
CurrentX ................................. 51, 96
CurrentY ................................. 51, 96
Cut ............................................ 29, 31
D
Data ............................................. 206
Date ..................................... 110, 111
DateAdd ..................................... 111
DateDiff ...................................... 111
DatePart ..................................... 111
DBGrid.......................................... 207
DblClick ................................... 30, 125
Debug ............................................ 79
Debug.Print ............................. 37, 41
DefDbl .......................................... 46
DefInt ........................................... 46
DefLng.......................................... 46
DefSng .......................................... 46
Delete ..................................... 31, 235
Delphi ......................................... 218
DESC ........................................... 208

272

design............................................. 11
DeviceType ..................................... 19
Dim ........................................ 39, 182
DirListBox .................................... 155
Do.............................................70, 71
Do . Loop .................................. 71
Do . Loop Until ......................... 72
Do . Loop While........................ 71
Do Until . Loop ......................... 73
Do While . Loop........................ 72
Docking ........................................ 30
DocumentComplete.................... 203
Double ......................................45, 46
DownPicture ................................... 90
DrawMode..................................... 95
DrawStyle ...................................... 95
DrawWidth .................................... 94
DriveListBox................................. 155
DTPicker ...................................... 154
E
Edit ............................................... 31
Else ............................................... 54
ElseIf.............................................. 59
Enabled ........................................ 19
End ................................... 11, 65, 104
End If ............................................ 59
End Select..................................... 62
End Sub ................................... 12, 103
End Type .................................... 145
Enum ........................................... 119
EOF ............................................. 160
Err ............................................... 162
Exit ............................................... 31
Exit Do ............................................ 73
Exit For ........................................... 76
Exit Sub ....................................... 104
F
False ...................................... 61, 116
File ................................................ 31
FileCopy....................................... 161
FileListBox ................................... 155
FileName .................................... 173
FillColor ....................................91, 95
FillStyle .....................................91, 95
Find .............................................. 31
Fix ................................................. 44
Font................................................ 17
Font Style ........................................ 17
FontBold ....................................... 51
FontItalic ...................................... 51
FontName ..................................... 51
FontSize ........................................ 51
FontStrikethru ............................. 51
FontTransparent .......................... 51
FontUnderline .............................. 51
For .................................... 74, 75, 159
For Each...................................... 147
ForeColor .......................... 18, 51, 95
Form Layout ................................. 30
Form_Load .................................... 20
Form_Terminate ............................... 20
Form_Unload ................................ 161
Format .....................................31, 46
Frame .......................................... 148

FROM ......................................... 208


G
GIF ................................................ 89
GotFocus ........................................ 88
GoTo ............................................. 68
Graphical ........................................ 90
H
Height............................................. 22
Help .............................................. 32
HScrollBar .................................... 151
HTML......................................... 198
HTML- ......................... 201
I
ICO ................................................ 89
Icon ................................................ 33
if 60
If 54
Image.............................................. 90
ImageCombo................................ 156
Immediate Window ................ 37, 78
In ................................................. 147
Input............................................. 159
InputBox ....................................... 38
Insert............................................ 235
InStr ............................................ 157
Int .......................................... 44, 201
Integer .............................. 39, 45, 46
Internet ....................................... 228
Is 63
IsDate ........................................... 121
IsNumeric ..................................... 64
Italic ................................................ 17
J
Java.............................................. 218
JPG ................................................ 89
K
KeyCode ....................................... 127
KeyDown ...................................... 127
KeyPress ...................................... 127
KeyPreview ................................... 128
KeyUp .......................................... 128
Kill ............................................... 161
L
Label .............................................. 17
Lcase ........................................... 157
Left......................................... 22, 157
Len .............................................. 157
Let ................................................. 36
Line .................................... 91, 94, 95
Line Input ................................... 160
LISP ............................................ 218
List .............................................. 153
ListBox ........................................ 152
ListCount .................................... 153
ListIndex..................................... 153
ListView........................................ 155
Load ............................................ 142
LoadPicture.......................... 21, 25, 89
Locals ............................................ 78
Lock Controls ................................ 31

Logo ............................................ 218


Long ........................................ 45, 46
Loop .............................................. 71
LostFocus ...................................... 88
LTrim......................................... 157
M
Main............................................. 180
Make ....................................... 26, 31
MaxButton ................................... 19
MDI ............................................ 209
Me ............................................... 180
Menu Editor ................................. 23
Microsoft Multimedia Control 6.0 ......... 19
Microsoft Windows Common
Controls-2 6.0 ........................... 25
Mid ............................................. 157
MID .............................................. 19
MinButton .................................... 19
MkDir ........................................... 161
Mod .............................................. 43
MonthName ............................... 111
MonthView ................................. 154
MouseDown ................................. 125
MouseIcon .................................... 18
MouseMove................................. 126
MousePointer ............................... 18
MouseUp...................................... 126
Movable ........................................ 19
MP3 .............................................. 19
MSChart ....................................... 156
MSComm .................................... 156
MSDN Library ............................. 32
MsgBox ................................... 23, 25
MultiLine ..................................... 19
N
Name ...................................... 16, 161
Navigate ....................................... 203
New ...................................... 147, 191
New Project ............................. 12, 31
Next .............................................. 75
Not ................................................ 61
Now ............................................ 111
Number ........................................ 162
O
Object..................................... 30, 146
Object Browser......................... 30, 87
Object Pascal ............................... 218
OLE............................................ 209
On Error ....................................... 162
OnClick ......................................... 201
Open ........................... 19, 25, 30, 159
Open Project ........................... 12, 31
Option base ................................ 140
Option Explicit .................................. 40
OptionButton................................ 150
Options ......................................... 32
Or ................................................. 61
OR ................................................ 61
Order ............................................ 31
ORDER BY ................................ 208
Output ........................................ 159

273

P
Package & Deployment Wizard ........... 33
PaintPicture ................................... 97
PasswordChar .............................. 65
Paste .........................................29, 31
Path ........................................ 33, 159
PC Speaker................................. 227
Picture .......................................... 19
PictureBox ....................................... 89
PictureClip................................... 156
Play ...........................................19, 25
Point .............................................. 97
Print ................................. 31, 50, 160
Print Setup .................................... 31
Private .......................................... 182
Private Sub.................................... 103
ProgressBar ................................. 151
Project .......................................... 31
Project Explorer ..................... 30, 180
Prolog .......................................... 218
Properties ...................................... 30
Property Get ................................. 197
Property Let................................. 197
Pset................................................ 95
PSet .............................................. 94
Public .................................... 182, 191
Public Const .................................. 183
Q
Quick Watch ................................... 79
R
Randomize............................. 57, 100
Redo .............................................. 31
Regular ........................................... 17
Remove........................................ 147
Remove Form................................ 31
Remove Project .......................12, 31
RemoveItem ............................... 153
Rename .......................................... 29
Replace ......................................... 31
RGB ............................................... 92
RichTextBox ............................... 155
Right ........................................... 157
RmDir........................................... 161
Rnd...........................................44, 57
Round..................................... 44, 108
RTrim......................................... 157
run ................................................. 11
Run To Cursor .............................. 79
S
Save .........................................28, 29
Save Project.............................12, 31
Save Project As ............................. 31
SavePicture .................................. 177
ScaleLeft ...................................... 130
ScaleTop ...................................... 130
SELECT ..................................... 208
Select Case.................................... 62
Send to Back................................. 92
Sequencer ....................................... 19
Set ........................................ 146, 191
SetFocus ........................................ 87
Setup.exe ....................................... 33
Shape ............................................ 91

Shell ............................................. 162


Shift ............................................. 234
ShowColor ................................... 177
ShowOpen................................... 173
ShowSave .................................... 173
Simple Combo ................................ 153
Single ................................ 40, 45, 46
Size ................................................ 17
Slider............................................ 151
Sorted .......................................... 153
Sound ............................................. 20
Split ............................................... 32
SQL ............................................. 207
Sqr ................................................. 44
Start ................................................ 11
Static ........................................... 167
StatusBar...................................... 156
Step.......................................... 75, 97
Stop ................................ 25, 104, 203
Str ............................................... 157
Strech............................................. 90
String ..................................... 46, 157
Style ......................................... 19, 90
Sub ................................................. 12
T
TabStrip ....................................... 156
Tan ................................................ 44
Text ........................................ 17, 152
TextBox ........................................... 11
Then .............................................. 54
Time ............................................ 111
Timer .......................................... 111
To .......................................... 75, 138
Toolbar ........................................ 174
Toolbox ................................... 10, 30
Tools ............................................. 32
ToolTipText .................................. 18
Top................................................. 22
TOP ............................................ 208
TreeView....................................... 155
Trim ............................................ 157
True ...................................... 61, 116
Type ............................................ 145
TypeName..................................... 147
U
Ucase ........................................... 157
Undo.............................................. 31
UpDown........................................ 155
V
Val.......................................... 17, 157
Value .................................... 149, 201
Variant .......................................... 144
VBScript ..................................... 200
View ........................................ 30, 31
Visible ........................................... 19
Visual Basic ................................. 218
Visual C++................................... 218
Visual Data Manager.................. 205
Visual Studio.................................. 27
VScrollBar .................................... 151
W
Watches.......................................... 79

WAV ............................................. 19
WaveAudio ...................................... 19
Web- ......................... 198
Web- ............................ 198
WeekdayName ........................... 111
WHERE ..................................... 208
While Wend ............................. 74
Width ............................................. 22
Window ................................... 30, 32
Windows API ............................. 209
WindowState ................................ 19
WMF ............................................. 89
Write ............................................ 159
WriteLn ......................................... 41
Z
ZOrder ......................................... 92

................... 44
...................................... 233
.................................... 16
............................... 213
.................................. 121
............................. 108
........ 43
..... 36
................................ 44
.................................. 218

.............................. 204
............................ 145
............................... 40, 224, 229
........................................ 229
.............................................. 229
....................................... 203
.................................. 198
............................ 236
........................................ 225

...................................... 213
.................................... 158
.................. 151
...................................... 53
................................... 221
............................ 226
................................ 226
........................................ 165
................................... 223
.................................. 227
If ............. 60
........................ 84

................................................ 225
............... 225, 227
............... 106
.................... 43
.............. 18
..................................... 53, 221
................................. 158
........... 103, 216
................................... 225
.................................. 36
Visual Basic .................. 28

274

................................ 228
()
............................... 183
()
............................. 182
()
............................... 182

................................................ 151

.................................... 224
.............. 139
.................. 43
........................................ 218
........................................ 233
...................... 44
......................................... 218
.................................. 226
...................................... 227
.............................. 214, 223
.................................... 227
.................................. 223
...................................... 226
) ............. 33
............................. 231
................................... 233
....... 201
.............................................. 96
............................... 96

............................................... 54

....................... 223, 227

............................... 158
................................. 225
Visual Basic.................... 28
..................... 28
.......................... 29
.................................... 156
alphabetic......................... 16
categorized ....................... 16
......................... 12
............................ 158
..................................... 145
.................................... 204
.......................................... 50
......................................... 18
...................................... 44
................................... 183
............................. 68
............................ 227
.............................. 56
................. 164

.................................................. 36
....................................... 230

................................................ 182
.... 181
......... 182

60
......................................... 89
.............................................. 61
........................................... 43
....................................... 16, 231
............................................. 54
.................................. 137
137
.................................... 168
............................. 187
............ 33
............................ 27, 33
..................................... 198
...................... 224

....................................... 232
.............................................. 25
................................ 225
................................ 127
................................. 223

................................................. 235
....................... 135
) ......................... 30
........................................... 147
................... 19
.................... 19
.......................................... 10
........................................ 201

............................. 228
............................................ 12
................................... 147
........................................ 213
...................................... 218
............... 215
.............................. 25
-.......................... 227
.................................. 214
................ 228
............................. 106
................................ 106
............................ 148
....................... 29
............................... 236
.................... 115
....................... 44
........................................... 51

.................... 226
............................................ 218
.................. 60
..................... 233
...... 61
.................................... 218, 219
.................................. 228
.... 183

................................................. 182
. 182

................................................. 182
... 182

...................... 201

...................... 165

.................................... 165

............................... 86
..................................... 11
........................................ 137
..................... 142
..................................... 137
............ 167
142
.................................. 43
............... 226
...................... 217
............................................. 23
............................................ 17
........................................... 68
........................................... 87
........................ 170
...................... 187
................................. 226
................................ 86
( )
If ................................ 58
....................... 121
........................................ 121
........................................ 228
....................................... 214
........................... 190
.......................................... 44
.............................. 180
.................................... 226
......................................... 19
............................... 123
........................................ 225
....................................... 125

........................................ 16
() . 51
............................ 197
Visual Basic . 32
................................................. 61
............... 179
.................... 181

... 103. .
....................................... 187
............. 146
......................................... 9
,
................................................ 171
39
................................ 77
................. 16
Immediate ............................. 80
..................................... 11
................................... 44
................................... 93
................................ 96
................. 223
.............. 40, 224

275

............ 224, 227


.................................... 218
....................... 62
....................... 67
............................. 70
.................................. 9
MsgBox..................... 65
........ 36
............ 225
............................................... 225

.................................................. 43
....................................... 159
....................................... 12
......................................... 77
.................................9, 220
............................. 93
.......................... 94
.......................... 204
........................................ 13
....................................... 162

........................................ 224
......................................... 223
.................. 11
............................. 230
................... 32
......................................... 232
........................ 94, 108
......... 107
........................................... 65

................................................ 168

................................ 168
............................ 29
........................... 150
................ 36
.................. 36
...................... 75
........................... 42, 105
................. 98
................................ 29
............................. 236
............... 51
.... 119
....................... 225
..... 223
................................. 217, 229
.............................. 89
..................................... 227
...................... 165
................ 51
........................................ 204
........................... 197
..................... 233
................... 51
.......................... 214

................................................ 189
144
....................................... 204

............................. 225
................. 41
.................................. 184

.................................... 207
..................................... 226
................................. 214
.............................. 198
.................................. 232
.................................. 217
......................... 214
........... 216
........................... 9, 213
........................................ 9
....................... 124
........................................ 218
Combo .......................... 153
.. 103
.......................... 9, 101
..... 103
................................ 216
.................................. 221
......... 106
.................................... 223
........................... 94
.......................................... 233

......................... 230
...... 53
...................................... 43
.............................. 17
............................ 51
......................................... 148
Combo ............ 153
............ 152
............................. 232
..................................... 234
................... 41
............ 11
............................ 11
........................... 77
................................... 224
..................................... 168

....... 196
.................................... 87
................... 187
....................................... 11

................................................. 228
............................... 96
........................... 96
............................................ 228
........................................ 96
........................................ 228
...................................... 55
............... 56
........................ 22
........................ 22
.......................... 223

.................................... 145

.................................... 204
....................................... 226
.......................................... 43
................................ 29
............................................... 92

........................... 44
................... 57
.................... 100
............ 221
........................................ 20
........................................ 87
.................................... 9
....................................... 12
............... 77
.............................. 170
.................................. 12
............... 28
........................................ 152
........................... 215
............................................. 27
.......... 5
...... 5
......................... 230
......... 167
............................................. 17
..................... 156
........................................ 157
............... 49
........................................... 49
.................. 226
.. 59
......................................... 204
.................................... 83
.................................. 200
....................................... 82
...................... 74

....................................... 112
...................................... 44
....................................... 231
............................................. 22
............................................. 199
....................... 11, 52
........................... 201
.................. 233
..................... 234
..................... 158
......................... 161
....................... 103
........................... 68, 71
................................................ 39
........... 89
................................ 45
............................... 77
.................................................. 54
........................................... 94
............................. 50
........................................ 44
....................... 78
............................................. 18
................... 45

.................................... 237
........................................ 198
..................................... 43
....... 225
............ 225
.......................................... 56
...................... 53

276

.................................... 33
..................... 225
........... 225, 226


................................ 158
....................................... 231

................................................ 161
............................. 204
.................................... 149
............................................ 88
........................................... 10
....................... 196
.......................... 46
.............................................. 19
MsgBox ......................... 65

............. 164

............................................... 92
.................................. 18
.................................... 18
............................... 51
.......................... 44
.................................. 39
................ 43
............. 223
...................................... 67, 221
.............................................. 67
.............. 67

......................... 137
......................................... 158

http://knigaluby.ru

........................................... 223
........................................... 17

..................... 189

.................................... 46
......................................... 96

.............................................. 218
............. 218
........................................... 41
....................................... 40