Вы находитесь на странице: 1из 477

-

-
2009

681.3.06
32.973.26-018.2
90

. .
90

Visual Basic. .
2- ., . . .: -,
2009. 496 .: . + CD-ROM
ISBN 978-5-9775-0365-5
Visual Basic,
.
, , Visual Basic.
.
,
. . -
.

681.3.06
32.973.26-018.2

:

.
.

02429 24.07.00. 29.12.08.


60 901/16. . . . . 31.
2500 .
"-", 194354, -, . , 5.
- 77.99.60.953..003650.04.08
14.04.2008 .
.

" ""
199034, -, 9 , 12

ISBN 978-5-9775-0365-5

. ., 2009
, "-", 2009

........................................................................................... 1
Visual Basic ? ........................................................................ 1
........................................................................................ 2
1. Visual Basic ............................................................................ 7
.............................................................................................. 7
............................................................................... 9
2. .................................................................. 17
.................................................................................... 17
................................................................................................... 18
........................................................................................ 23
....................................... 34
...................................................................................... 40
............................................................................. 43
.................................................................... 46
........................................................................... 46
.............................................................................. 49
......................................................................................... 52
................................................................... 53
EXE- ....................................................................... 56
.......................................................................... 57
........................................................................ 57
.......................................................................... 62
......................................... 66
.............................. 68

IV

3. ........................................................ 70
Label ..................................................................................................... 70
TextBox ................................................................................................. 78
CommandButton ................................................................................... 82
CheckBox .............................................................................................. 87
OptionButton ........................................................................................ 91
ComboBox ............................................................................................ 94
Timer................................................................................................... 100
PictureBox .......................................................................................... 103
Image .................................................................................................. 112
4. ...................................... 118
CommonDialog .............................................................. 120
StatusBar ........................................................................ 126
ProgressBar.................................................................... 131
UpDown.......................................................................... 135
.................................................................................................. 139
5. ............................................................................. 153
................................................................ 153
.................................................................. 155
............................................................................................... 156
............................................................................................... 157
............................................................................... 161
......................................................................... 165
.................................................................................. 168
............................................................................................. 173
................................................................................................ 176
..................................................................................... 182
................................................................................. 196
............................................................................... 201
.............................................. 214
.............................................................. 214
............................................................... 216
............................................................................. 217

6. ................................................................... 221
PlaySound........................................................................... 221
MMControl ..................................................................... 225
MP3- ....................................................................................... 229
MIDI ................................................................................................ 238
CD- ......................................................................................... 245
...................................................................... 251
MIDI .................................................. 263
................................................................ 267
................................ 273
7. .................................................................... 274
........................................................................ 274
......................................... 275
................................................................. 276
...................................................... 276
................................ 277
........................................................................... 278
.............................................. 278
.................................................................. 279
.................................. 279
............................................... 288
........................................ 294
.................................................... 308
....................................................... 308
.......................................................................... 309
............................................................... 310
.......................................................................... 310
..................................................................... 311

......................................................................................... 314
8. ....................................................... 315
HTML Help .................................................... 316
.......................................... 317

Microsoft Word ....................................................................... 318

VI


HTML Help Workshop............................................................ 319
CHM- .................................................................... 324
.......................... 324
..................................... 329
............................................................................... 333
.......................................... 334
9. .................................................... 341
IExpress ............................................................................... 342
..................................................... 344
1. .................................................................... 344
2. ................................................................... 345
3. .................................................................. 345
4. .................................... 346
5. .................................................. 347
6. ............................................. 348
7. ............................................ 348
8. .................................... 349
9. ............................... 349
...................................................................... 351
................................................... 353
10. ...................................................... 354
................................................................ 354
............................................................... 354
....................................................................................... 356
........................................................................ 359
........................................................... 360
..................................................................... 361
........................................................................... 363
.......................................................................... 375
"" ..................................................................................... 377
................................................ 378
.............................................................................................. 380

VII

........................................................... 382
....................................................................................... 383
................................................................................................. 388
............................................................... 391
............................................................. 392
........................................................................... 397
11. .................................................... 411
................................................................................................. 411
...................................................................................... 414
CheckBox ......................................................................................... 414
ComboBox ........................................................................................ 415
CommandButton .............................................................................. 417
CommonDialog ................................................................................ 419
DirListBox ........................................................................................ 420
DriveListBox .................................................................................... 422
FileListBox ....................................................................................... 423
Image ............................................................................................... 425
Label ................................................................................................ 427
Line .................................................................................................. 428
ListBox ............................................................................................. 430
MMControl ...................................................................................... 432
OptionButton .................................................................................... 433
PictureBox........................................................................................ 434
ProgressBar ..................................................................................... 437
Shape ................................................................................................ 438
StatusBar .......................................................................................... 441
TextBox ............................................................................................ 443
Timer ................................................................................................ 444
UpDown ........................................................................................... 445
.............................................................................................. 447
Circle................................................................................................ 448
Line .................................................................................................. 449
LoadPicture...................................................................................... 450
LoadResPicture ................................................................................ 450
PaintPicture ..................................................................................... 451

VIII

Print ................................................................................................. 451


PSet .................................................................................................. 452
RGB .................................................................................................. 452
............................................................................................. 457
.................................................................................. 457
InputBox ..................................................................................... 457
MsgBox ....................................................................................... 458
............................................................. 459
................................................................ 461
........................................................................ 461
.......................................................... 465
.................................................... 467
. -........................................ 472
.................................................................... 479


Visual Basic ?
. - . -
, ,
, .

Windows , , , ,
, .

, Windows,
, .
, ,
,
Microsoft Visual Basic.
(RAD-, Rapid
Application Development ) .
,
,
. RAD- !

Microsoft Visual Basic ,


Visual Basic.
, Visual
Basic, Microsoft
Visual Basic 6.0, "".
Visual Basic 6.0 : ,
, .
Microsoft Visual Basic Windows 98 Windows Vista. , , .


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

, ,
.

, ,
Visual Basic. Microsoft Visual Basic. , :
.
Microsoft Visual
Basic 6.0,
:
.
,
. , ,
. .
. ,
!

Visual Basic

Microsoft Visual Basic . , , CD ,


(. 1.1):
Typical (). CD

Microsoft Visual Basic.


, ;
Custom ().

, .
,
.
, ,
CD- -, MSDN Library
(Microsoft Developer Network) Microsoft
Visual Studio. MSDN:
Typical (). -

( 60 ),

I. Microsoft Visual Basic

-
;
Custom ().

, ; , , - MSDN Library
;
(). (
800 ) .

Full

. 1.1. Microsoft Visual Basic


Typical

Visual Basic,
(Custom) MSDN Library (. 1.2) : VB Documen-

1. Visual Ba

tation ( Visual Basic), VB Product Samples ( Visual Basic) VS Shared Documentation ( Visual Studio).

. 1.2. MSDN Library


Visual Basic ,
Microsoft Visual Basic 6.0
Microsoft Visual Basic 6.0 (. 1.3).

I. Microsoft Visual Basic

10

. 1.3. Visual Basic

Visual Basic ,
() Visual Basic
. ( , , VBProjects)
. ,
, Visual Basic
( Visual
Basic) (. 1.4).
Visual Basic ,
New Project (. 1.5).
New (),
Visual Basic.
, , , , Standard EXE .

Visual Basic New Project
, ,
, File New Project.

1. Visual Ba

11

. 1.4. , Visiual Basic,


Visual Basic . 1.6.


, , , ,
.
(. 1.7)
.
,
, ,
.

I. Microsoft Visual Basic

12

. 1.5. ()

(. 1.8) .


.

(. 1.9) , .

, , , View

1. Visual Ba

13

Toolbox .

. 1.6. Visual Basic


. 1.7.

(. 1.10) () , .

14

I. Microsoft Visual Basic

. 1.8.

. 1.9. ( Toolbox)

1. Visual Ba

15


, ,
, View Project
Explorer .

. 1.10. Project
()

Properties (. 1.11)
. (
). Alphabetic , Categorized
. , Appearance ,
, Position
( )
( ).


(
, , .).
, ()

16

I. Microsoft Visual Basic

. , Caption , Width Height .

. 1.11. Properties


Visual Basic . ,
, (. 2.1).

. 2.1.


, ,
, , File
New Project, New Project

18

I. Microsoft Visual Basic

(Standard EXE)
OK.


() .

(. 2.1) ( , , . .).
2.1.

Name

Caption

Width

Height

StartUpPosition


. (CenterScreen), (CenterOwner).

Top Left (
StartUpPosition
Manual)

Top

2.

19

2.1 ()

Left

Icon

()

MaxButton

MinButton

BorderStyle

() .
(Sizable), (FixedSingle) (
) (None).
FixedDialog,

BackColor

. ,
.

ScaleMode


, .

(Twip), (Pixel),
(Millimeter)

Font

,
(,
, )

20

I. Microsoft Visual Basic

Properties. Properties
,
. ,
.

Caption Form1 . , Properties Caption .
( Form1)
(. 2.2).

. 2.2.

, .
Width Height .

2.

21


(,
) (. 2.3). Width Height

.

. 2.3.

, BorderStyle,

. , (. 2.4).
, , . . , FixedSingle ,
vbFixedSingle.

I. Microsoft Visual Basic

22

. 2.4.

. , .
,
Icon Load Icon,
ICO ,
.
. 2.2 . .
2.2.

Caption

2.

23

2.2 ()

Width

4425

Height

3480

BorderStyle

FixedSingle

MaxButton

False

MinButton

False

StartUpPosition

CenterScreen

ScaleMode

Pixel

Font

Tahoma, , 10 t


( ). TextBox .
TextBox.
TextBox,
(. 2.5),
,
, ,
.
, .
, ,
,
. , TextBox Text1, Text2. ,

24

I. Microsoft Visual Basic

Name,
. , , .

. 2.5. TextBox

. 2.6 ""
TextBox,
. . () Properties. ,

,
Properties.

. 2.6. TextBox

. 2.3 TextBox.

2.

25

2.3. TextBox

Name

Text

Left

Top

Width

Height

Font

ForeColor

Locked

. . True,

MultiLine

(True)

ScrollBars

.
(Vertical), (Horizontal)
(Both).
None,

Visible

(False)
(True)

Width, Height,
Left Top .

26

I. Microsoft Visual Basic

,
,
, ,
,
. (. 2.7) ( Left Top).

. 2.7. Left

, , , ,
, . . Width Height
(. 2.8).
. 2.4 Text1
Text2. Text1 , Text2
. ,

2.

27

.
, .
Text

. 2.8. Width Height


2.4.

Text1

Left

88

Top

47

Text2

Width

113

Height

22

Text

Left

88

Top

87

Width

113

Height

22

Text

I. Microsoft Visual Basic

28

. Label (. 2.9).
Label , .

. 2.9. Label

Label . 2.5.
2.5. Label

Name

Caption

Left

Top

Width

( )

Height

( )

AutoSize

WordWrap

, , ( AutoSize False)

2.

29

2.5 ()

Alignment

.

(LeftJustify), (Center) (RightJustify)

Font

, .
,

ForeColor

BorderStyle

Visible

(False) (True)


Label. Label
,
,
.
Label , . 2.6.
2.6.

Label1

Caption

Left

Top

AutoSize

True

I. Microsoft Visual Basic

30

2.6 ()

Label2

Caption

($)

Left

Top

40

AutoSize

True

Caption

(/$)

Left

Top

72

AutoSize

True

Caption

Left

Top

112

Width

193

Height

41

BorderStyle

FixedSingle

Label3

Label4

Label
, . 2.10.
, , : .
.
CommandButton (. 2.11)
, .
. 2.7.

2.

31

. 2.10.

. 2.11. CommandButton

2.7. CommandButton

Name

Caption

Left

Top

Width

Height

32

I. Microsoft Visual Basic

2.7 ()

Enabled

.
True,
, ,
,
<Enter>.
False,

Visible

(False) (True)

Style

.
(Standard) "" (Graphical).
""

Picture

, "" ( Style
Graphical)

DisabledPicture

"" ,
,
(
Enabled False)

DownPicture

"" ( Style Graphical) ,


,

ToolTipText

(
CommandButton) . 2.8.

2.

33

2.8.

Command1

Caption

Left

Top

168

Width

73

Height

25

Caption

Left

96

Top

168

Width

73

Height

25

Command2

"" . 2.12.

. 2.12. ""

34

I. Microsoft Visual Basic

,
.



, .
, .
,
.
(Event) , . . ,
Click,
TextBox KeyPress.
. 2.9 .
2.9.

Click

DblClick

MouseDown

MouseUp

MouseMove

KeyPress

2.

35

2.9 ()

KeyDown

. KeyDown
KeyPress , , ,
(
KeyUp)

KeyUp

()

Initialize

(, ).


Activate

,
()

Paint

,
,
, ,
,

Resize

GotFocus

LostFocus

, , , ()

36

I. Microsoft Visual Basic

. , Initialize Load Activate Resize


Paint, ,
, QueryUnload Unload Terminate.
- . Visual
Basic
. ,
,
. ,
.
,
. , ,
( TextBox), ,
KeyPress ,
(
) .

Click
.
Text1 (
) Text2 (), (
)
(Label4).
Click , . ,
(. 2.13).
. . -

2.

37

, , .
Command1,
Click.

. 2.13.

, ( View
Code), (. 2.14),
, ,
, , . ,
KeyPress
Text1, Text1, KeyPress (. 2.15).
2.1 Click
. ,
. ,
:
, (
).

38

I. Microsoft Visual Basic

. 2.14. ,

. 2.15. ,

2.1. Click
Private Sub Command1_Click()
Dim usd As Double

'

2.

39

Dim k As Double

'

Dim rub As Double

'

'
usd = CDbl(Text1.Text)
k = CDbl(Text2.Text)
'
rub = usd * k
'
Label4.Caption = Str(usd) + "$ = " + Str(rub) + "."
End Sub

Command1_Click Label4. Text1 Text2 Text.


(Text1 Text2)
(Text).
. Text ( ) , . , , ,
( ).
CDbl, Text
, .
CDbl , .

k usd, .

I. Microsoft Visual Basic

40

Label4
Caption. Str.
. , . End. Click
2.2.
2.2. Click
Private Sub Command2_Click()
End '
End Sub



(Sub, Function, Dim, If, Else .) ,
.
.


.
View Code View Object,
(. 2.16).

, .

2.

41

. 2.16. View Code View Object

, MsgBox (
, ) , , MsgBox c
(. 2.17). .
,
. . ,
.

. 2.17.

42

I. Microsoft Visual Basic

.
()
, (. 2.18).
, (
) <Ctrl>+<Enter>. .

. 2.18.
()


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

2.

43

.
.


Visual Basic , , If, Select, For, While , . :
Dim k As Double
Dim i As Integer
k = CDbl(Text1.Text)
usd = CDbl(Text2.Text)
rub = k * usd

,
:
Dim k As Double : Dim usd As Double
k = CDbl(Text1.Text) : usd = Cdbl(Text2.Text) : rub = k * usd

.
,
, , .
, <Enter>,
,
"",
. :
MsgBox(" .", _
"", vbInformation + vbOk)

I. Microsoft Visual Basic

44

If, Select, For ,


Visual Basic. , Then If
,
( <Enter> , , Visual Basic
).

,
( ), , .

,
,
, .

Select .
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44 '
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 46 '
KeyAscii = 44 '
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If

2.

45

Case 13 ' <Enter>


Text2.SetFocus
Case Else
KeyAscii = 0
End Select

, Case
Select. ,

- KeyAscii ,
Case, ,
Case. ,
End, If,
If, ,
, ,
If.
Select :
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44 '
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 46 '
KeyAscii = 44
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 13 ' <Enter>
Text2.SetFocus
Case Else
KeyAscii = 0
End Select

46

I. Microsoft Visual Basic

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


, , ,
. ( ,
. .), , <F1>.
, Help Contents Index. Contents , Index
. Visual Basic Documentation
.
. , , ,
(. 2.19).


Visual Basic (,
), -

2.

47

(), (EXE) .
(VBP) (FRM).

. 2.19.

, ( , , .). ,
Project Properties Name (. 2.20).
(,
), File
Save Project.

48

I. Microsoft Visual Basic

. 2.20. ,

. 2.21.

2.

49

, Save File As, , Visual Basic,


,
(. 2.21).
Save Project (. 2.22).
,
EXE-, .

. 2.22.


,
. .
Run Start,
<F5> Start (. 2.23),

50

I. Microsoft Visual Basic

(
End, ).

. 2.23.

,
, , (. 2.24). ,
: ( OK), End.

. 2.24.

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

Run Start With Full Compile. -

2.

51

, .
, Visual
Basic .
,
. Option Explicit,
,
Dim.
Option
Explicit Editor Options (. 2.25) Require Variable Declaration (
). Options
ToolsOptions.

. 2.25.
Require Variable Declaration

I. Microsoft Visual Basic

52

,
- (
, ). ,
"" 24.5
,
Run-time error '13': Type mismatch (. 2.26).

. 2.26.

. , ,
CDbl. ,

, ( )
Windows .
24.5 ,
.
, ,

(. 2.27). End , Debug , , .

2.

53

. 2.27.


, .
,
.
:
On Error Goto M,

M () ,
.
On Error 2.3 Click "", ,
.
(. 2.28).

I. Microsoft Visual Basic

54

2.3. ( )
'
Private Sub Command1_Click()
Dim usd As Double

'

Dim k As Double

'

Dim rub As Double

'

On Error GoTo e1 ' , e1


'
usd = CDbl(Text1.Text)
k = CDbl(Text2.Text)
'
rub = usd * k
'
Label4.Caption = Str(usd) + "$ = " + Str(rub) + " ."
Exit Sub '
e1: '
If Len(Text1.Text) = 0 Or Len(Text2.Text) = 0 Then
MsgBox " ", vbExclamation
Else
MsgBox " ." + vbCr + _
" ", _
vbExclamation
End If
End Sub

2.

55

. 2.28.

Click
MsgBox. :
MsgBox , , ,

:
;
. -

(vbInformation), (vbWarning)
(vbCritical).
(. 2.10);
.
2.10.

vbExclamation
vbCritical

vbInformation

,
-

56

I. Microsoft Visual Basic

.
, Application Title Make Project Properties ( Project
Properties).

EXE-
, Visual
Basic, .
(EXE) , File Make Make Project
(. 2.29) OK.

. 2.29. OK
EXE-

2.

57


Visual Basic, File
Exit.
- ,

(. 2.30).

. 2.30.


""
. , ,
,
( <Enter>)
, <Enter>
.
, Visual
Basic .
File Open Project. Open Project. Existing ,

I. Microsoft Visual Basic

58

. Recent ,
. "",
Recent usd2rub (. 2.31).

. 2.31. Recent ,

2.4 "",
KeyPress Text1 Text2.
2.4. ""
Option Explicit
'
Private Sub Command1_Click()
Dim usd As Double

'

Dim k As Double

'

Dim rub As Double

'

2.
'
usd = CDbl(Text1.Text)
k = CDbl(Text2.Text)
'
rub = usd * k
'
Label4.Caption = Str(usd) + "$ = " + Str(rub) + " ."
End Sub
'
Private Sub Command2_Click()
End
End Sub
'
' ( KeyPress Text1)
Private Sub Text1_KeyPress(KeyAscii As Integer)
'
' KeyAscii .
' KeyAscii
' 0, ,
' ,
' ,
' .
' :
' ( 48 57),
' ( 44),
' <Backspace>.
' .

59

I. Microsoft Visual Basic

60

Select Case KeyAscii


Case 8, 48 To 57
' <Backspace>
Case 44 '
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 46 '
KeyAscii = 44
If InStr(1, Text1.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 13 ' <Enter>
Text2.SetFocus
Case Else
KeyAscii = 0
End Select
End Sub
'
' ( KeyPress Text2)
Private Sub Text2_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 48 To 57
' <Backspace>
Case 44 '
If InStr(1, Text2.Text, ",") <> 0 Then

2.

61

KeyAscii = 0
End If
Case 46 '
KeyAscii = 44
If InStr(1, Text2.Text, ",") <> 0 Then
KeyAscii = 0
End If
Case 13 ' <Enter>
Command1.SetFocus
Case Else
'
KeyAscii = 0
End Select
End Sub

KeyPress Text1
(KeyAscii) ,
. KeyAscii
0, , ,
, .
. Text1
, . ,
KeyPress " "
. , KeyAscii 0.
<Enter> -

62

I. Microsoft Visual Basic

SetFocus Text2 Text2. , , (


InStr,
, ).
, KeyAscii
0, .
, . , , ( ).
KeyPress Text2
.

( RunStart With Full Compile),
( FileMake) ( FileSave
Project).


Icon ,
.
, (EXE-) .
(. 2.32).
.
Icon
Load Icon (. 2.33)
(ICO-).

. 2.32. Visual Basic

2.

63

. 2.33.


Visual Basic Microsoft Visual
Studio\Common\Graphics\Icons .


. Image Editor (Imageedit.exe), Visual Basic
Microsoft Visual Studio\Common\Tools\Vb\Imagedit.
, ICO-.
ICO- - . 1616 3232.
1616
(" "). ,
, 1616 3232 "". 3232, ,
, , 1616. , -

64

I. Microsoft Visual Basic

, , ICO- : 1616 3232.


(
). 16- . 256 . , Image Editor 16- .
ICO- , : 1616 3232.
Image Editor File
New. Resource Type Icon
OK (. 2.34). New Icon
Image (. 2.35) EGA/VGA 16-Color 3232.

. 2.34.

. 2.35.

2.

65

ICO-, ,
(. 2.36).

. 2.36. Image Editor

Image Editor
.
,
"" (Screen). , ,
, (
"" ).
3232 ,
1616.
Edit New Image,
New Icon Image Small Icon 16-Color 1616.

66

I. Microsoft Visual Basic

, File
Save . ,
.

,
,
( )
.

. 2.37.

2.

67

, , ( ) .
(. 2.37), EXE- .
, Project
Properties. Application Title
Make (. 2.38).
,
(
Icon , ).

. 2.38.

68

I. Microsoft Visual Basic

( ,
. .), Version Information, Type, ()
Value . . 2.11.
2.11. (EXE-)

Comments

(
)

Company Name

File
Description

( )

Legal
Copyright

Product Name

,
FileMake.

, Visual Basic, , Flash-.


, , Visual Basic,
( , , References, Project References).
Visual Basic,

2.

69

. , -
. ,
Visual Basic
, .

http://microsoft.com/downloads
vbrun60sp5.exe, , ,
Visual Basic 6.0.

(EXE-, ), (
vbrun60sp5.exe)
(CD "") ,
. - ,
.
, ,
Package & Deployment Wizard, Visual Basic, IExpress, Microsoft Windows.


. , -
, . . , .
.
,
( ).
: Label, TextBox, CommandButton, CheckBox, OptionButton, ComboBox, ListBox, PictureBox,
, . () , , , , , ( ).

Label
Label (. 3.1) .

3.

71

. 3.1. Label

, ,
( Caption
Properties), , Caption. Label
. 3.1.
3.1. Label

Caption

Width, Height

(, )

Top, Left

()
()

Font

ForeColor

BackColor

AutoSize


( Caption)

WordWrap

,
, (
AutoSize False)

72

I. Microsoft Visual Basic

3.1 ()

Alignment

.
(0),
(2) (1)

BorderStyle

.
1, 0. Appearance

Appearance

(
BorderStyle 1). (0) "" (1)

BackStyle


. , BackColor
(
1), (0)

Visible

(False)
(True)

Label ,
, ( Str Format), Caption.

Label, , , " " ( 13). ,
Label.Caption = ": " + Str(sum) + "." + Chr(13) + _
": " + Str(discount) + "." _
+ Chr(13) + _
" : " + Str(total)

Label .

3.

73

Chr(13) vbCR. ,
:
Label.Caption = ": " + Str(sum) + "." + vbCr + _
": " + Str(discount) + "." + vbCr + _
" : " + Str(total)

Label
"" ( . 3.2, . 3.2, 3.1).

. 3.2. ""

3.2.

Label1

Left

16

Top

16

Caption

AutoSize

True

74

I. Microsoft Visual Basic

3.2 ()

Label2

Left

16

Top

40

Caption

AutoSize

False

Width

80

Alignment

1 Right
Justify

Left

16

Top

72

Caption

AutoSize

False

Width

80

Alignment

1 Right
Justify

Left

16

Top

144

AutoSize

False

Width

280

Height

50

Caption

Label3

Label4

3.1.
Option Explicit
Private Sub Command1_Click()

3.
Const cena = 17.5

' 1 .

Dim p1 As Double

'

Dim p2 As Double

'

75

Dim rashod As Double '


Dim sum As Double

'

p1 = CDbl(Text1.Text)
p2 = CDbl(Text2.Text)
If p2 >= p1 Then
rashod = p2 - p1
sum = rashod * cena
Label4.ForeColor = vbBlack
Label4.Caption =
": " + Format(rashod, "#0.00 ..") + _
vbCrLf + _
" .. :" + Format(cena, "#0.00 .") + _
vbCr + _
" : " + Format(sum, "#0.00 .")
Else
Label4.ForeColor = &H80& ' -
Label4.Caption =
" ." + vbCr + _
"
."
End If
End Sub
' Text1
Private Sub Text1_Change()

I. Microsoft Visual Basic

76

If Len(Text1.Text) = 0 Or Len(Text2.Text) = 0 Then


Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
' Text1
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44, 46

'

If KeyAscii = 46 Then
'
KeyAscii = 44
End If
' ,
If InStr(1, Text1.Text, ",") <> 0 Then
'
'
KeyAscii = 0
End If
Case 13 ' <Enter>
Text2.SetFocus ' Text2
Case Else
'
KeyAscii = 0
End Select
End Sub

3.

77

' Text2
Private Sub Text2_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44, 46

'

If KeyAscii = 46 Then
'
KeyAscii = 44
End If
' ,
If InStr(1, Text2.Text, ",") <> 0 Then
'
'
KeyAscii = 0
End If
Case 13 ' <Enter>
Command1.SetFocus '
' Text2
Case Else
'
KeyAscii = 0
End Select
End Sub
'
Private Sub Text2_Change()
If Len(Text1.Text) = 0 Or Len(Text2.Text) = 0 Then
Command1.Enabled = False

I. Microsoft Visual Basic

78
Else

Command1.Enabled = True
End If
End Sub

TextBox
TextBox (. 3.3)
( ) . . 3.3.

. 3.3. TextBox

3.3. TextBox
( )

Text

MaxLength

, .
0,

Font

3.

79

3.3 ()

MultiLine

(True)

ScrollBars

:
0 ;
1 ;
2 ;
3

Locked

Visible

.
True,
(False)
(True)


KeyPress Change. KeyPress (
), Change
.
,
TexBox , . . ,
KeyPress,
"" .
TextBox
"-" ( . 3.4,
3.2). ,

I. Microsoft Visual Basic

80

( KeyPress). , Change
. ,
.

. 3.4. "-"

3.2. -
Option Explicit
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44, 46

' (44) (46)

If Len(Text1.Text) = 0 Then
'
KeyAscii = 0
Else
If KeyAscii = 46 Then

3.

81

'
KeyAscii = 44
End If
' ,
If InStr(1, Text1.Text, ",") <> 0 Then
'
'
KeyAscii = 0
End If
End If
Case 13 ' <Enter>
If Len(Text1.Text) > 0 Then
Command1.SetFocus '
' Command1
End If
Case Else
'
KeyAscii = 0
End Select
End Sub
' Text1
Private Sub Text1_Change()
' Text1 , ,
' , Label2,
'
Label2.Caption = ""
If Len(Text1.Text) = 0 Then
' Text1
'

I. Microsoft Visual Basic

82

Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
Private Sub Command1_Click()
Dim f As Double

'

Dim k As Double

'

f = CDbl(Text1.Text)
k = f * 0.409
If k < 1 Then
k = k * 1000
Label2.Caption = Format(f, "#0.00 .") + " = " + _
Format(k, "#0.00 .")
Else
Label2.Caption = Format(f, "#0.00 .") + " = " + _
Format(k, "#0.00 ")
End If
End Sub

CommandButton
CommandButton (. 3.5) . ,
( ). CommandButton . 3.4.

3.

83

. 3.5. CommandButton

3.4. CommandButton

Caption

Enabled

.
True, .
False,
(
Click )

Visible

(
(

Style

: (0
Standard)
"" (1
Graphical). ,

Picture

""
. , Style
1 (Graphical)

DisabledPicture

"" . ,
Style Graphical,
Enabled False

DownPicture

""
. , Style
Graphical

False)
True)

I. Microsoft Visual Basic

84

3.4 ()

MaskColor

"" . ,
,
( ,
UseMaskColor
True)

UseMaskColor

(True), ,
MaskColor,

ToolTipText

CommandButton "-" ( . 3.6, Command1 . 3.5,


3.3). ,
OK , ( Change Text1).

. 3.6. "-"

3.

85

3.5. Command1

Caption

OK

Enabled

False

3.3. -
Option Explicit
' OK
Private Sub Command1_Click()
Dim m As Double
Dim k As Double
m = CDbl(Text1.Text)
k = m * 1.6093
Label2.Caption = Format(m, "# ###.00 m") + " = " + _
Format(k, "# ###.00 .")
End Sub
'
Private Sub Text1_Change()
Label2.Caption = ""
' ,
If (Len(Text1.Text) = 0) Or _
((Mid(Text1.Text, 1, 1) = ",") And _
(Len(Text1.Text) = 1)) Then

I. Microsoft Visual Basic

86

'
' OK
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
'
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8, 48 To 57 ' <Backspace>
Case 44, 46

' (44) (46)

If KeyAscii = 46 Then
'
KeyAscii = 44
End If
' ,
If InStr(1, Text1.Text, ",") <> 0 Then
'
'
KeyAscii = 0
End If
Case 13 ' <Enter>
If Command1.Enabled Then
Command1.SetFocus '
' Command1
End If
Case Else
'

3.

87

KeyAscii = 0
End Select
End Sub

CheckBox
CheckBox (. 3.7) , (),
() .
(),
, .
CheckBox . 3.6.

. 3.7. CheckBox

3.6. CheckBox

Value

: Checked ( );
Unchecked
( )

Caption

Enabled

. True, . False,

88

I. Microsoft Visual Basic

3.6 ()

Visible

(
False) (

True)


( Enabled True).
Click.
CheckBox
"" ( . 3.8,
CheckBox . 3.7, 3.4).
.

. 3.8. ""

3.

89

3.7.

Check1

Caption

Value

0 Unchecked

Caption

Value

0 Unchecked

Caption

Value

0 Unchecked

Check2

Check3

3.4.
'
Private Sub Command1_Click()
Dim w As Double ' ()
Dim h As Double ' ()
Dim s As Double '
Dim sum As Double ' (.)
Dim discount As Double '
Dim total As Double '
s = 0
sum = 0
discount = 0
w = CDbl(Text1.Text)
h = CDbl(Text2.Text)

I. Microsoft Visual Basic

90

s = w * h / 10000
sum = s * CENA
If Check1.Value = 1 Then
' " "
sum = sum + 1800 * s
End If
If Check2.Value = 1 Then
' ""
sum = sum + 300
End If
If Check3.Value = 1 Then
' ""
sum = sum + 1500
End If
If Check1.Value = 1 And Check2.Value = 1 And _
Check3.Value = 1 Then
' 10%
discount = sum * 0.1
total = sum - discount
End If
If discount = 0 Then
Label3.Caption = _
": " + Str(w) + "x" + LTrim(Str(h)) + _
"

" + vbCr + _

": " + Format(s, "#0.00 .") + vbCr + _


": " + Format(sum, "# ##0.00 .")

3.

91

Else
Label3.Caption = _
": " + Str(w) + "x" + LTrim(Str(h)) + _
" " + vbCr + _
": " + Format(s, "#0.00 .") + vbCr + _
": " + Format(sum, "# ##0.00 .") + vbCr + _
" (10%): "+ Format(discount,"# ##0.00 _
.") + vbCr + _
" : " + Format(total, "# ##0.00 .")
End If

End Sub

OptionButton
OptionButton (. 3.9)
(), () () .
, ( OptionButton),
.
.
, .

. 3.9. OptionButton

92

I. Microsoft Visual Basic

OptionButton , Frame. , ,
, .
. 3.8.
3.8. OptionButton

Caption

Value

. , True, ,
False

Font

Enabled

.
True, .
False,

Visible

(False)
(True)

. Click.
OptionButton "" ( . 3.10, . 3.9, 3.5).
3.9.

Option1

Caption

Value

True

3.

93

3.9 ()

Option2

Caption

Value

False

. 3.10. ""

3.5.
Private Sub Command1_Click()
'
Dim r1 As Double
Dim r2 As Double
Dim r As Double '
r1 = CDbl(Text1.Text)
r2 = CDbl(Text2.Text)

I. Microsoft Visual Basic

94

If Option1.Value = True Then


'
r = r1 + r2
Else
' ,
' Option1, Option2
r = r1 * r2 / (r1 + r2)
End If
If r <= 1000 Then
Label4.Caption = " : " + _
Format(r, "#0.00 ")
Else
r = r / 1000
Label4.Caption = " : " + _
Format(r, "#0.00 ")
End If
End Sub

ComboBox
ComboBox (. 3.11)
, .

. 3.11. ComboBox

3.

95

. 3.10.
3.10. ComboBox

Style

: (0 Dropdown Combo); (1 Simple Combo);


(2 Dropdown List)

Text

(,

)

List

ListCount

ListIndex

.
,
1.

Sorted



(
)

Visible

(False) (True)

, ComboBox,
, .
, List
(. 3.12), <Ctrl>+<Enter>.

96

I. Microsoft Visual Basic


AddItem. () ,
. ,
Combo1:
Combo1.AddItem ("")
Combo1.AddItem ("")
Combo1.AddItem ("")

. 3.12. ComboBox

ComboBox
"" ( . 3.13,
Combo1 . 3.11, 3.6).

3.

97

. 3.13. ""

3.11. Combo1

Combo1.Style

0 Dropdown Combo

Combo1.Sorted

False

3.6.
Option Explicit
Dim cena(10) As Double ' -
' Load
Private Sub Form_Load()
' Combo1
' cena

I. Microsoft Visual Basic

98

Combo1.AddItem ("")
cena(0) = 1500
Combo1.AddItem ("")
cena(1) = 500
Combo1.AddItem ("")
cena(2) = 1000
Combo1.AddItem (" ")
cena(3) = 500
Combo1.AddItem ("")
cena(4) = 800
End Sub
'
Private Sub Command1_Click()
Dim w As Double ' ()
Dim h As Double ' ()
Dim c As Double ' 1 .
Dim s As Double '
Dim sum As Double ' (.)
If Combo1.ListIndex = -1 Then
MsgBox " ", vbExclamation, ""
Exit Sub '
End If

3.
s = 0
sum = 0
w = CDbl(Text1.Text)
h = CDbl(Text2.Text)
s = w * h / 10000 ' .
' Combo1
' cena (. ) c
Select Case Combo1.ListIndex
Case 0
c = cena(0)
Case 1
c = cena(1)
Case 2
c = cena(2)
Case 3
c = cena(3)
Case 4
c = cena(4)
End Select
sum = s * c
Label3.Caption = _
": " + Str(w) + "x" + LTrim(Str(h)) + _
"

" + vbCr + _

": " + Combo1.List(Combo1.ListIndex) + _


"(" _
Format(cena(Combo1.ListIndex), _
"#0.00 ./..)") + vbCr + _
": " + Format(sum, "# ##0.00 .")
End Sub

99

100

I. Microsoft Visual Basic

Timer
Timer (. 3.14) Timer.
. 3.12.

. 3.14. Timer

3.12. Timer

Interval

Timer.

Enabled

.
True, Timer Interval

Timer "" ( . 3.15,


Timer . 3.13, 3.7).
3.13. Timer1

Interval

500

Enabled

True

3.

101

. 3.15. ""

3.7.
Option Explicit
Dim min As Integer
Dim sec As Integer
'
Private Sub Form_Load()
min = 0
sec = 0
End Sub
' /
Private Sub Command1_Click()
If Command1.Tag = 0 Then
'
Timer1.Enabled = True '
Command1.Caption = ""
Command1.Tag = 1 ' Command1
Command2.Enabled = False '
'

I. Microsoft Visual Basic

102
Else

'
Timer1.Enabled = False '
Command1.Caption = ""
Command1.Tag = 0 ' Command1
Command2.Enabled = True '
End If
End Sub
' (,
' )
Private Sub Timer1_Timer()
If sec < 59 Then
sec = sec + 1
Label2.Caption = Format(sec, "00")
Else
sec = 0
Label2.Caption = Format(sec, "00")
min = min + 1
Label1.Caption = Format(min, "00")
End If
End Sub
'
Private Sub Command2_Click()
min = 0
sec = 0
Label1.Caption = "00"
Label2.Caption = "00"
End Sub

3.

103

.
Click Command1 Enabled True. Timer,

Label1 Label2.
Tag Command1. ,
1, 0.

PictureBox
PictureBox (. 3.16)
, (, , . .),
. PictureBox
. 3.14.

. 3.16. PictureBox

3.14. PictureBox

Picture

, .
( LoadPicture)

104

I. Microsoft Visual Basic

3.14 ()

AutoSize

(True)
(False) ( ) ,

BorderStyle

. 1, ,
0,

BackColor

. ,

Font

, Print

ForeColor

Print ,
()

FillColor

(),
( )

FillStyle

,
:
0 (Solid) ;
1 (Transparent) ""

;
2 (HorizontalLine) -

;
3 (VerticalLine) .


FillColor

3.

105

3.14 ()

DrawStyle

, :
0 (Solid) ;
1 (Dash) ;
2 (Dot) ;
3 (Dash-Dot) "-";
4 (Dash-Dot-Dot) "--";
5 (Transparent) ""

DrawWidth

ScaleWidth

,
.
ScaleMode

ScaleHeight

,
.
ScaleMode

ScaleMode


.

Width Height (
)

Height

Width

Visible

(False)
(True)

PictureBox "". Picture1

I. Microsoft Visual Basic

106

(
).
.
. 3.17, Picture1
. 3.15. , ( ),
. 3.8, . 3.18.

. 3.17. ""

3.15. Picture1

BorderStyle

0 None

AutoSize

True

Picture

back.bmp

ScaleMode

3 Pixel

3.

107

3.8.
Option Explicit
Const N = 10 '
Dim usd(1 To N) As Double '
Dim min, max As Double

'
'

Dim loaded As Boolean

' True ,
' False

Private Sub Form_Activate()


Dim f As String '
Dim i As Integer
Dim st As String '
loaded = False '
'
' ! Visual Basic
' , .
' (EXE-)
' , EXE-
f = ":\VBProjects\PictureBox\usd.dat" '
' f = CurDir + "\usd.dat"
'
On Error GoTo e1
Open f For Input As #1

'

I. Microsoft Visual Basic

108
For i = 1 To N

Line Input #1, st '


usd(i) = Val(st)
Next i
Close #1 '
loaded = True '
' 100,
'
For i = 1 To N
usd(i) = usd(i) * 100
Next i
'
min = usd(1)
For i = 2 To N
If usd(i) < min Then min = usd(i)
Next i
'
max = usd(1)
For i = 2 To N
If usd(i) > max Then max = usd(i)
Next i
Exit Sub
e1: '
MsgBox " " + f, vbCritical

End Sub

3.

109

' Paint
Private Sub Picture1_Paint()
Dim k As Double '
'
'
'
'
Dim dx As Integer ' X
Dim dy As Integer ' Y
Dim i As Integer
Dim cx, cy As Integer '

If Not loaded Then


'
Exit Sub
End If
'
Picture1.CurrentX = 100
Picture1.CurrentY = 5
Picture1.Font.Size = 14
Picture1.Font.Bold = False
Picture1.ForeColor = vbWhite
Picture1.Print " "
Picture1.CurrentX = 101
Picture1.CurrentY = 6

I. Microsoft Visual Basic

110

Picture1.Font.Size = 14
Picture1.Font.Bold = False
Picture1.ForeColor = vbBlack
Picture1.Print " "
Picture1.Font.Size = 10
Picture1.Font.Bold = False
' Picture1.DrawWidth = 2
dx = (Picture1.ScaleWidth - 20) / N
k = (Picture1.ScaleHeight - 50) / (max - min)
'
Picture1.CurrentX = 20
Picture1.CurrentY = (Picture1.ScaleHeight - 15) _
- (usd(1) - min) * k

' Print
' , CurrentX CurrentY
cx = Picture1.CurrentX
cy = Picture1.CurrentY
Picture1.Print usd(1) / 100
' ,
' Print
Picture1.CurrentX = cx
Picture1.CurrentY = cy
'
For i = 2 To N

3.
' Y
'
dy = (usd(i - 1) - usd(i)) * k
'
Picture1.Line -Step(dx, dy)
cx = Picture1.CurrentX
cy = Picture1.CurrentY
Picture1.Print usd(i) / 100
Picture1.CurrentX = cx
Picture1.CurrentY = cy
Next i
End Sub

. 3.18.
PictureBox

111

112

I. Microsoft Visual Basic

Image
Image (. 3.19) . Image
PictureBox , .
Image . ,
, (
Picture) .
Image . 3.16.

. 3.19. Image

3.16. Image

Picture

(),
.
(
LoadPicture)

Stretch

(True), ( )
. , .
False

3.

113

3.16 ()

Width, Height

.
Stretch False, Width
, Height

Image
" " ( . 3.20). ,
. Image1. , . Label1
.
(Command1) .
3.9.

. 3.20. " "

I. Microsoft Visual Basic

114

3.9.
Option Explicit
Dim aPath As String

' , . JPG-

Dim aPicture As String

'

Dim w, h As Double
Image1

'

'
Private Sub Form_Activate()
' Image1
w = Image1.Width
h = Image1.Height

aPath = Environ("HOMEDRIVE") + Environ("HOMEPATH") + _


"\ \ \"
aPicture = Dir(aPath + "*.jpg") '
' JPG-
If aPicture = "" Then
MsgBox " " + aPath + " JPG-"
Exit Sub
End If
ShowPicture (aPath + aPicture)
aPicture = Dir ' JPG-
If aPicture = "" Then

3.

115

Command1.Enabled = False
End If
End Sub
'
Private Sub Command1_Click()
ShowPicture (aPath + aPicture)
aPicture = Dir ' JPG-
If aPicture = "" Then
Command1.Enabled = False
End If
End Sub
' Image1
Sub ShowPicture(aPicture As String)
Dim kw, kh As Double ' .
'
Dim k As Double

' .
'

Image1.Visible = False
Image1.Stretch = False
Image1.Picture = LoadPicture(aPicture)
If (Image1.Width > w) Or (Image1.Height > h) Then
' ,
' Image1

I. Microsoft Visual Basic

116

kw = w / Image1.Width
kh = h / Image1.Height
' ,
' .
'
If kw < kh Then
k = kw
Else
k = kh
End If
Else
k = 1
End If
'
Label1.Caption = aPicture & vbCr & ":" & _
Image1.Width & "x" & _
Image1.Height & "

:" & _

Format(k, "0.00")
Image1.Width = Image1.Width * k
Image1.Height = Image1.Height * k
Image1.Stretch = True '
Image1.Visible = True
End Sub

showImage. Stretch False. , .


,

3.

117

:
, .
Image1 , Stretch True. (. 3.21).
Image1,

. 3.21. " "


, " ", () .

. 4.1.
Controls

4.

119

,
, Microsoft Windows Common Control 6.0, Microsoft
Windows Common Control-2 6.0 Microsoft Common Dialog 6.0.
,
, ,
Controls Components (. 4.1), Projects Components.

. 4.2. ,

,
, ,

(. 4.2)

120

I. Microsoft Visual Basic


. . 4.3 Microsoft
Windows Common Control 6.0 (SP4) Microsoft Windows Common
Control-2 6.0. : StatusBar,
ProgressBar, UpDown .

. 4.3.
Microsoft Windows Common Control 6.0 (SP4)
Microsoft Windows Common Control-2 6.0

CommonDialog
CommonDialog ( (. 4.4) Microsoft Common
Dialog 6.0) , , , , .

. 4.4. CommonDialog

CommonDialod . 4.1.

4.

121

4.1. CommonDialog

DialogTitle

FileName

( ) ,
.
Cancel,

FileTitle

, .
Cancel,

Filter

, , .
, .
(

)

InitDir

Flags

DefaultExt

,
,
( )

, (. 4.2).
. 4.2.

ShowOpen

I. Microsoft Visual Basic

122

. 4.2 ()

ShowSave

ShowColor

ShowFont

ShowPrinter

ShowHelp

CommonDialog " " ( . 4.5).


, . CommonDialog1 . 4.3,
4.1.

. 4.5. " "

4.

123

4.3. CommonDialog1

DialogTitle

Filter

(*.jpg;*.gif)|*.jpg;*.gif|
(*.bmp;*.gif;*.jpg)|*.bmp;*.gif;*.jpg|
(*.*)|*.*

4.1.
Option Explicit
Const cdlOFNFileMustExist = &H1000
Const cdlOFNHideReadOnly = &H4
Dim Path As String
Dim w, h As Double ' Image
'
Private Sub Form_Activate()
w = Image1.Width
h = Image1.Height
CommonDialog1.Flags = cdlOFNFileMustExist Or _
cdlOFNFileMustExist
If File1.ListCount <> 0 Then
' JPG-
Path = CurDir + "\"
Label1.Caption = Path + File1.List(0)
File1.ListIndex = 0
End If
End Sub

I. Microsoft Visual Basic

124

' ( )
Private Sub Command1_Click()
CommonDialog1.InitDir = _
Environ("HOMEDRIVE") + Environ("HOMEPATH") + _
"\ \ \"
CommonDialog1.FileName = ""
CommonDialog1.ShowOpen
If CommonDialog1.FileName = "" Then
'
Exit Sub
End If
'
Path = Mid(CommonDialog1.FileName, 1, _
Len(CommonDialog1.FileName) - _
Len(CommonDialog1.FileTitle))

' JPG- File1


' (FileList)
File1.Pattern = "*." & Right(CommonDialog1.FileName, 3)
File1.Path = Path
' File1.List
Dim i As Integer
i = 0
Do While File1.List(i) <> CommonDialog1.FileTitle
i = i + 1

4.

125

Loop
File1.ListIndex = i
End Sub
'
'
'
Private Sub File1_Click()
Label1.Caption = Path & File1.List(File1.ListIndex)
ShowPicture (Path & File1.List(File1.ListIndex))
End Sub
' Image1
Sub ShowPicture(aPicture As String)
Dim kw, kh

As Double ' .
'

Dim k As Double

' .
'

Image1.Visible = False
Image1.Stretch = False
Image1.Picture = LoadPicture(aPicture)
If (Image1.Width > w) Or (Image1.Height > h) Then
' ,
' Image1
kw = w / Image1.Width
kh = h / Image1.Height
' ,
' .
'

I. Microsoft Visual Basic

126

If kw < kh Then
k = kw
Else
k = kh
End If
Else
k = 1
End If
Image1.Width = Image1.Width * k
Image1.Height = Image1.Height * k
Image1.Stretch = True '
Image1.Visible = True
End Sub

StatusBar
StatusBar ( (. 4.6)
Microsoft Windows
Common Controls 6.0 (SP4))
.
StatusBar . 4.4.
4.4. StatusBar

Style

() .
(0 sbrNormal) ""
(1 sbrSimple).
,

4.

127

4.4 ()

SimpleText

, , (
Style sbrSimple)

. 4.6. StatusBar

. 4.7. StatusBar

(),
,

128

I. Microsoft Visual Basic

,
, . .
,
. , StatusBar
( Properties)
Panels InsertPanel (. 4.7) , . .
StatusBar . 4.5.
4.5. StatusBar

Style

, . : (0 sbrText), (5
sbrTime), (6 sbrDate), (1 sbrCaps, 2 sbrNum, 3 sbrIns)

, (
Style sbrText)

Alignment

.
(0 sbrLeft),
(2 sbrRight)
(1 sbrCenter)

Picture

AutoSize

. 2
(sbrContents),
( ). 1 (sbrSpring),
,

. ,
,

4.

129

StatusBar
" " ( . 4.8,
StatusBar . 4.6).
, , . Change TextBox ( 4.2), ,
sbrTime.
4.6. StatusBar

Name

StatusBar1

Style

sbrNormal

StatusBar1.Panels(1).Style

sbrText

StatusBar1.Panels(1).Autosize

sbrSpring

StatusBar1.Panels(2).Style

sbrTime

StatusBar1.Panels(2).Autosize

sbrNone

StatusBar1.Panels(2).Alignment

sbrCenter

. 4.8. " "

I. Microsoft Visual Basic

130

4.2.
Dim n As Integer ' ,
Dim p As Integer '
'
Private Sub Form_Load()
Dim n1, n2, n3 As Integer
Randomize '
n1 = Int(Rnd * 8) + 1 ' . 19
n2 = Int(Rnd * 9)

' . 09

n3 = Int(Rnd * 9)

' . 09

n = 100 * n1 + 10 * n2 + n3 ' .
100999
p = 1
StatusBar1.Panels(1) = ":" + Str(p)
End Sub
' OK
Private Sub Command1_Click()
Dim m As Integer '
m = CInt(Text1.Text)
If m = n Then
'
MsgBox " ! ?", _

4.

131

vbInformation + vbYesNo, " "


End '
Else
p = p + 1
StatusBar1.Panels(1) = ":" + Str(p)
End If
End Sub
'
Private Sub Text1_Change()
If Len(Text1.Text) < 3 Then
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
'
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
MsgBox " :" + Str(n)
End Sub

ProgressBar
ProgressBar (. 4.9) ,

, () -

132

I. Microsoft Visual Basic

, . .
, Microsoft
Windows Common Controls 6.0 (SP4).
ProgressBar . 4.7.

. 4.9. ProgressBar

4.7. ProgressBar

Value

, ( )
. (
)
Value.

Min

Value

Max


Value

Scrolling

.
(0
ccScrollingStandard) (1
ccScrollingSmooth)

Appearance

:
(0 ccFlat), 3D (1 cc3D)

Border

: (1 ccFixedSingle),
(0 ccNone)

4.

133

ProgressBar "" ( . 4.10,


4.3). ProgressBar1 , (
Command1), ,
, .

. 4.10. ""

4.3.
Dim delay As Integer
Dim dv As Integer ' Value
' ProgressBar:
' 1 , -1
' OK
Private Sub Command1_Click()
'
If Option1.Value = True Then

I. Microsoft Visual Basic

134

'
ProgressBar1.Scrolling = ccScrollingStandard
Else
'
ProgressBar1.Scrolling = ccScrollingSmooth
End If
' 100 ,
'
ProgressBar1.Max = Text1.Text * 10
If Check1.Value = vbChecked Then
'
ProgressBar1.Value = ProgressBar1.Max
dv = -1
Else
'
ProgressBar1.Value = 0
dv = 1
End If
Command1.Enabled = False
Timer1.Enabled = True
End Sub
'
Private Sub Timer1_Timer()
ProgressBar1.Value = ProgressBar1.Value + dv
If ProgressBar1.Value = ProgressBar1.Max Or _
ProgressBar1.Value = ProgressBar1.Min Then

4.

135

Timer1.Enabled = False
ProgressBar1.Value = 0
Command1.Enabled = True
End If
End Sub
' Text1
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) _
Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub

UpDown
UpDown (. 4.11) ,
( )
-. UpDown
, Label
TextBox,
-. UpDown
. 4.8.

. 4.11. UpDown

136

I. Microsoft Visual Basic

UpDown , Microsoft Windows Common Controls-2 6.0.


4.8. UpDown

Value

. Up ()
Down ()

Increment

Max

- Value

Min


- Value

BuddyControl

,
- (, Label TextBox)

BuddyProperty

,
BuddyControl,
- (Caption,
Label)

AutoBuddy

-, -.

Label,
BuddyProperty
Caption

SyncBuddy

(True)
Value

4.

137

4.8 ()

Orientation

( ) :
0 (OrientationVertical)

(, );
1 (OrientationHorizontal) -

(, )
Wrap

False,
Value Up.
Down. True , Value

Enabled

( True)
( False)

Visible

( False) ( True)

UpDown
"" ( . 4.12, UpDown1 . 4.9, 4.4).
4.9. UpDown1

Min

Max

50

I. Microsoft Visual Basic

138

4.9 ()

Wrap

True

BuddyControl

Text1

BuddyProperty

Text

SyncBuddy

True

. 4.12. ""

4.4.
Option Explicit
Private Sub Command1_Click()
Dim cena As Double '
Dim kol As Integer '
Dim sum As Double

'

Dim frm As String

'

4.

139

kol = CInt(Text1.Text)
'
If Option1.Value = True Then
cena = 3.3 ' 9x12
frm = "9x12"
End If
If Option2.Value = True Then
cena = 3.6 ' 10x15
frm = "10x15"
End If
If Option3.Value = True Then
cena = 7.2 ' 15x24
frm = "15x24"
End If
sum = cena * kol
Label3.Caption = ": " + frm + vbCr + _
": " + Format(cena, "0.00 .") + _
vbCr + _
": " + Format(sum, "0.00 .")
End Sub

Visual Basic , .
.

140

I. Microsoft Visual Basic

Menu Editor
(. 4.13). , Tools ( ) .

. 4.13. Menu Editor

, Caption Name Menu Editor


(, File) <Enter>.
.
. (
Caption, Name).
,
(
). , , ( ).

4.

141

. 4.14 Menu Editor


MEdit,
.

. 4.14. MEdit

,
Menu.
Menu . 4.10. Menu Editor,
.
4.10. Menu

Caption

Name

142

I. Microsoft Visual Basic

4.10 ()

Enabled

. False,
(
Click ,
)

Checked

, . True,
. Checked
,

Shortcut

(
),

. 4.15. Medit

Menu ( )
Click, -

4.

143

<Enter> ( ). Click
,
.
MEdit (
. 4.15).
. 4.11, Text1 . 4.12,
4.5.
4.11. MEdit
Caption

Name

File

FileOpen

FileSave

FileExit

Parameters

ParametersFont

PatametersStatusBar

Help

HelpHelp

HelpAbout

4.12. Text1

MultiLine

True

Scroll

2 Vertical

I. Microsoft Visual Basic

144

4.5. MEdit ( Form1)


Option Explicit
Dim fName As String

'

' >>
Private Sub FileOpen_Click()
Dim f As Integer
Dim buf As String
CommonDialog1.FileName = "*.txt"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "*.txt" Then
'
fName = CommonDialog1.FileName
f = FreeFile
'
Open fName For Input As f
Input #f, buf
Close #f
Text1.Text = buf
Text1.SelStart = Len(Text1.Text) '
'
Form1.Caption = "MEdit " & fName
End If
End Sub
' >>
Private Sub FileSave_Click()

4.

145

SaveFile
End Sub
' >>
Private Sub FileExit_Click()
Dim r As Integer
If Text1.DataChanged Then
r = MsgBox(" . ?", _
vbExclamation + vbYesNo, "MEdit")
If r = vbYes Then
SaveFile '
End If
End If
Unload Form1 '
End Sub
' >>
Private Sub ParametersStatusBar_Click()
If ParametersStatusBar.Checked Then
' ,
'
StatusBar1.Visible = False '
Text1.Height = Form1.ScaleHeight
ParametersStatusBar.Checked = False '
Else
Text1.Height = Form1.ScaleHeight StatusBar1.Height
StatusBar1.Visible = True
ParametersStatusBar.Checked = True
End If
End Sub

I. Microsoft Visual Basic

146

' >>
Private Sub ParametersFont_Click()
CommonDialog1.Flags = cdlCFScreenFonts
' cdlCFPrinterFonts
' cdlCFScreenFonts
' cdlCFBoth
CommonDialog1.FontName = Text1.FontName
CommonDialog1.FontSize = Text1.FontSize
CommonDialog1.FontBold = Text1.FontBold
CommonDialog1.FontItalic = Text1.FontItalic
CommonDialog1.ShowFont
If Trim(CommonDialog1.FontName) <> "" Then
'
Text1.FontName = CommonDialog1.FontName
Text1.FontSize = CommonDialog1.FontSize
Text1.FontBold = CommonDialog1.FontBold
Text1.FontItalic = CommonDialog1.FontItalic
End If
End Sub
' ? >>
Private Sub HelpAbout_Click()
Form2.Show vbModal
End Sub
'
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
Dim r As Integer

4.

147

If Text1.DataChanged Then
r = MsgBox(" ?", _
vbExclamation + vbYesNoCancel, "MEdit")
Select Case r
Case vbYes
SaveFile '
Case vbCancel
Cancel = 1 '
End Select
End If
End Sub
Private Sub Form_Load()
' Text1 ,
'
Text1.Width = Form1.ScaleWidth
Text1.Height = Form1.ScaleHeight StatusBar1.Height
End Sub
'
Private Sub Form_Resize()
Text1.Width = Form1.ScaleWidth
Text1.Height = Form1.ScaleHeight StatusBar1.Height
End Sub
'
Private Sub SaveFile()
Dim fn As Integer
If fName = "" Then
'

I. Microsoft Visual Basic

148

CommonDialog1.FileName = ""
CommonDialog1.DefaultExt = "txt" '
' ,
'
'
CommonDialog1.Filter = "*.txt"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
fName = CommonDialog1.FileName
Else
Exit Sub
End If
End If
'
f = FreeFile
Open fName For Output As f
Write #f, Text1.Text
Form1.Caption = "MEdit - " & fName
Close #f
End Sub

, (
Text1), , CommonDialog1.
.
Input,
Write.
MEdit .
(Form1 ) ,
(Form2) (. 4.16),
? .

4.

149

. 4.16.

(,
), Project
Add Form. (
).
Show (. HelpAbout_Click).
,
, ,
(
).
Click OK
4.6.
4.6. MEdit ( )
Option Explicit
Private Sub Command1_Click()
Form2.Hide
End Sub

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

PictureBox. , , , . ,
Form1.Line (10,10) (50,10)

.

Paint, ,
.


, (, , . .), ( PictureBox)

154

II.

,
. (x) (y) .
(x) (y). , , (0,0) (. 5.1).

. 5.1.

, ( ), , ,
. . ScaleMode
( PictureBox)
Pixel ( ) vbPixels (
).

( ) (
).

5.

155

, , , ,
.
(0,0),
, . ,
Form1.Line (10,10)-(60,10)

(60,10).

Step. ,
Form1.Line (10,10)-step(50,0)

(10,10) 50 ( ).
CurrentX CurrentY.

. CurrentX CuttentY. ,

st = "Visual Basic"
Picture1.CurrentX = _
(Picture1.ScaleWidth - Picture1.TextWidth(st)) / 2
Picture1.CurrentY = 10
Picture1.Print st

Picture1, , "Visual Basic".


, : , , , ,
.

II.

156

(. 5.1).
5.1.

Line

Circle

, , ,

PSet

Print

PSet.
PSet :
.PSet(x,y),Color

,
.
x y , .
Color . Color
(. 5.2).
5.2. ,

vbBlack

vbRed

vbGreen

5.

157

5.2 ()

vbYellow

vbBlue

vbMagenta

vbCyan

vbWhite

Color
RGB, ,
, . RGB :
(Red), (Green), (Blue)
. 0 255. ,
RGB(205,127,50) "" .
Color . , , ForeColor
, .
() , PSet,
DrawWidth ,
.

Line.
Line :
.Line Step(x1,y1,)-Step(x2,y2),Color

158

II.

,
.
, .
x1 y1 , x2, y2 .
,
.
.
Color .
, ,
ForeColor ,
.
x1, x2 Step, . Step x2, y2,
.
, Line, DrawWidth DrawStyle , . . 5.3 , .
,
.
5.3. ,

vbSolid

vbDash

( )

vbDot

( )

5.

159

5.3 ()

vbDashDot

vbDashDotDot

Line ""
( . 5.2, 5.1).

. 5.2. ""

5.1.
Option Explicit
Private Sub Picture1_Paint()
Dim x, y As Integer

'

Dim dx, dy As Integer

'

Dim w, h As Integer

' Picture1

II.

160
x = 0: y = 0
dx = 20: dy = 20

w = Picture1.ScaleWidth - 1
h = Picture1.ScaleHeight - 1
' Picture1.DrawStyle = vbDash
Picture1.ForeColor = RGB(192, 192, 192) '
'
Do
Picture1.Line (x, y)-Step(0, h)
x = x + dx
Loop While x < Picture1.ScaleWidth
'
x = 0: y = 0
Do
Picture1.Line (x, y)-Step(w, 0)
y = y + dy
Loop While y < Picture1.ScaleHeight
'
Picture1.ForeColor = vbBlack '
Picture1.DrawWidth = 3

'

'
' (0,0)
Picture1.CurrentX = 0
Picture1.CurrentY = 0
Picture1.Line -Step(w, 0)

'

Picture1.Line -Step(0, h)

'

5.

161

Picture1.Line -Step(-w, 0) '


Picture1.Line -Step(0, -h) '
End Sub

Line , (. 5.3).
, Color B.
x2
(x1,y1)

(x1,y1)

(x1,y1)

y2

(x2,y2)
Line (x1,y1) -Line
(x2,y2),
(x1,y1)
vbBlack,
- (x2,y2),
B vbBlack, B

x2

(x1,y1)

y2

(x2,y2)

Line (x1,y1) -Line


Step(x2,y2),
(x1,y1) - vbBlack,
Step(x2,y2),
B vbBlack, B

. 5.3. Line B

Line,
, :
.Line (x1,y1,)-(x2,y2),Color,B

,
(
, ).
x1 y1 (
) , x2, y2 ( ) .

162

II.

B , .
Color. , ForeColor , .
DrawWidth DrawStyle , .
, , ( ) ,
, x1, y1 x2, y2. ,
( )
, DrawStyle
vbInsideSolid.
, (x1,y1) (x2,y2).
FillColor FilStyle , .
FillStyle vbFSTransparent,
.
, FillColor, FillStyle , vbFSTransparent, vbFSSolid ( ).
, ,
. 5.4.
5.4.

()

vbFSTransparent

vbFSSolid

5.

163

5.4 ()

()

vbHorizontalLine

vbVerticalLine

vbUpwardDiagonal

(
)

vbDownwardDiagonal

(
)

vbCross

vbDiagonalCross

, x1, y1 x2,
y2 Step. Step
x1, y1, ()

. Step
x2, y2, ()

,
(x2 , y2 ).
B BF, Line , .
Color , , ForeColor , .
, , Line ,
(x2,y2).
Line "" (

II.

164

5.2).
(. 5.4).
5.2.
Option Explicit
Private Sub Form_Paint()
Dim w, h As Integer '
Dim x, y As Integer '
Dim st As String
w = 25
h = 45
x = (Form1.ScaleWidth - w * 3) / 2
y = 20
'
Form1.Line (x, y)-Step(w, h), RGB(33, 94, 33), BF
Form1.Line (x + w, y)-Step(w, h), vbWhite, BF
Form1.Line (x + 2 * w, y)-Step(w, h), vbRed, BF
'
Form1.FillStyle = vbFSTransparent
Form1.Line (x, y)-Step(w * 3, h), vbBlack, B
st = ""
CurrentX = (Form1.ScaleWidth - Form1.TextWidth(st)) / 2
CurrentY = y + h + 10
Print st
End Sub

5.

165

. 5.4. Line
B


Circle, ,
, , .
Circle, , :
.Circle Step(x,y), r, Color

,
(
, ).
x y .
Step, .
r ().
Color .
, ( )
ForeColor , .

DrawWidth DrawStyle ,
.

II.

166

FillColor FillStyle , .
,
FillStyle vbFSTransparent.
Circle "" ( 5.3).
Paint (. 5.5). ,
, .
5.3.
Option Explicit
Private Sub Form_Paint()
Dim x, y As Integer
Dim r As Integer '
Dim st As String '
Dim w As Integer '
r = 20
x = Form1.ScaleWidth / 2 - 2.25 * r
y = 40
DrawWidth = 2
FillStyle = vbFSTransparent '
'
'
Circle (x, y), r, RGB(50, 50, 205)
'
' 2.25r

5.

167

Circle Step(2.25 * r, 0), r, vbBlack


'
' 2.25r
Circle Step(2.25 * r, 0), r, vbRed
'
'
'
Circle Step(-2.25 * r, 0), r, RGB(35, 142, 35)
Circle Step(-1.125 * r, r), r, vbYellow
st = ", , !"
Form1.Font.Size = 10
w = Form1.TextWidth(st) '
'
CurrentX = (Form1.ScaleWidth - w) / 2
CurrentY = CurrentY + 2.25 * r
Print st
End Sub

. 5.5.

II.

168


Circle,
, :
.Circle Step(x,y), r, Color, start, fin

x, y, r Color, ,

(), (),
() ( ).
,
DrawWidth, DrawStyle, FillColor FillStyle , .
start , start X. fin
(. 5.6).
.
start fin
.

fin

start
start

fin

Circle (x,y), r, vbBlack, start, fin


. 5.6. start fin

5.

169

start fin ,
(. 5.7). :
, 0 ,
start 360.

start

fin
start

fin

Circle (x,y), r, vbBlack, -start, -fin


. 5.7. Circle

. 5.8.

Circle 5.4
,
(. 5.8)

II.

170

. , ,
.
5.4.
Option Explicit
Const N = 4

'

Dim title As String

'

'
Dim d(1 To N) As Double '
Dim s(1 To N) As String '
Dim p(1 To N) As Double '
Dim fc(1 To N) As Long

'

Private Sub Form_Activate()


Dim f As Integer '
Dim sum As Double
Dim i As Integer

'
f = FreeFile
' Open "d:\temp\result.txt" For Input As f
Open Environ("APPDATA") + "\result.txt" For Input As f

5.

171

Line Input #f, title


For i = 1 To N
Line Input #f, s(i) '
Input #f, d(i)

'

Next i
Close #f
fc(1) = vbGreen
fc(2) = vbRed
fc(3) = vbMagenta
fc(4) = vbBlue
'
sum = 0
For i = 1 To N
sum = sum + d(i)
Next i
'
For i = 1 To N
p(i) = d(i) / sum
Next i
Exit Sub
End Sub
Private Sub Form_Initialize()
Form1.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim r As Integer

'

II.

172

Dim a1, a2 As Double '


Dim x, y As Integer

'

Dim i As Integer
Const k = 3.1415926 / 180

'
'
'

'
Form1.Font.Size = 11
Form1.FontBold = True
CurrentY = 10
CurrentX = (Form1.ScaleWidth - Form1.TextWidth(title)) / 2
Print title
'
Form1.Font.Size = 10
Form1.FontBold = False
r = 80
x = 2 * r ' Form1.ScaleWidth / 2
y = r + 40 ' Form1.ScaleHeight / 2
FillStyle = vbFSSolid
'
'
a1 = 0

5.

173

For i = 1 To N
FillColor = fc(i)
a2 = a1 + 360 * p(i) * k
If a1 = 0 Then
' 360 -a2
Circle (x, y), r, , -6.2831852, -a2
Else
Circle (x, y), r, , -a1, -a2
End If
a1 = a2
Next i
'
x = x + r + 20
y = y - r + 20
For i = 1 To N
FillColor = fc(i)
Line (x, y)-Step(20, 10), , B '
CurrentX = x + 30
CurrentY = y
Print s(i) + Format(p(i), " - #0.00%")
y = y + 20
Next i
End Sub

Circle , .

II.

174
Circle,

, :
.Circle Step(x,y), r, Color, start, fin, aspect

x y , Color
. , ,
()
DrawWidth, DrawStyle,
FillColor FillStyle , . start fin
. r ,
aspect ().
aspect ,
, (. 5.9). , aspect
1, .
r

aspect < 1

aspect > 1

Circle (x,y),r, , , ,aspect


. 5.9. Cirle

Circle 5.5
,

5.

175

(. 5.10). ,
, . ,
( ).
, Resize (
, ,
) Refresh, Paint, .
5.5.
Option Explicit
Private Sub Form_Initialize()
Form1.ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim x, y As Integer '
x = Form1.ScaleWidth / 2
y = Form1.ScaleHeight / 2
FillColor = RGB(56, 176, 222) ' " "
FillStyle = vbSolid
Circle (x, y), 40, , , , 1

'

FillStyle = vbFSTransparent '


'
Circle Step(0, 0), 40, , , , 0.5 ' ""
'

II.

176

Circle Step(0, 0), 40, , , , 0

'

Circle Step(0, 0), 40, , , , 1.5 ' ""


Circle Step(0, 0), 40, , , , 3

' ""

End Sub
'
Private Sub Form_Resize()
Form1.Refresh ' (
' Paint)
End Sub

. 5.10. Circle


Print. :
.Print

, . ,
, . , , Print,

5.

177

( CurrentX CurrentY) , .
:
CurrentX = 20
CurrentY = 20
Print "Microsoft Visual Basic"

. 5.11.
,
(0,y). y , , ,
, .

. 5.11. Print
(CurrentX, CurrentY)

, Print , Font ,
ForeColor.
Print
, String, . ,

II.

178

Today Date,

Today = Now ' Now
CurrentX = 10
CurrentY = 10
Print Today

.
Format. :
, ,
. ,
Format(Sum, "### ### ##0.00 .") Sum , ,
(
), . ,
. , Sum
28580,446, Format(Sum, "### ### ##0.00
.") 28 580,45 .
. 5.5.
5.5.

#.##

( ). ,
()

Format(x,
"#.##")

5.

179

5.5 ()

#0.00

( ).

Format(x,
"#0.00")

### ### ##0.00

,

. .
(

)

Format(sum,
"### ###
##0.00 .")

#0.00%

. 100,

Format
(discount,
"#0.00%")

dd/mm/yy

", ,
". -

Format
(Now,"dd/mm/yy"
)

dddd

Format
(Now,"dd/mm,
dddd")

mmmm

Format(Now,"dd
mmmm, dddd")

. , Discount = 285,
Format(Discount, ": ### ### ##0.00 ."

II.

180


: 285,00 .
Print
Print demo (
5.6).
(. 5.12). , . ,
,
, .
TextWidth, ,
, ,
; TextHeight, , .

. 5.12.

5.6. (Print demo)


Private Sub Form_Load()
ScaleMode = vbPixels
End Sub
Private Sub Form_Paint()
Dim st As String '

5.

181

Dim w As Integer '


Dim h As Integer '
Dim t As Integer ' ()
t = Hour(time)
Select Case t
Case 0 To 4
st = " !"
Case 5 To 12
st = " !"
Case 13 To 16
st = " !"
Case 17 To 23
st = " !"
End Select

Font.Name = "Times New Roman"


FontSize = 28
ForeColor = RGB(35, 35, 142)
'
w = TextWidth(st)
h = TextHeight(st)
' ,
'
'
CurrentX = (ScaleWidth - w) / 2

'

ScaleWidth

'

II.

182

CurrentY = ScaleHeight / 2 - h

'

ScaleHeight

'

Print st ' (CurrentX,CurrentY)


Font.Name = "Tahoma"
FontSize = 10
ForeColor = vbBlack
st = Format(Now, " d mmmm, dddd")
w = TextWidth(st)
CurrentX = (ScaleWidth - w) / 2
Print st
End Sub

PictureBox Image (. 5.13).


BMP, GIF, JPEG PNG, (WMF, EMF) (ICO).
PictureBox Image ,
PictureBox ,
( , ,
), Image, , . , PictureBox .

5.

183

PictureBox . 5.6.

. 5.13. PictureBox Image


5.6. PictureBox

Picture

,
( Width Height Picture , )

AutoSize


. True,

Visible


. (False)
(True)

Appearance

.

( 3D)

(
Flat)

BorderStyle

.
(FixedSingle) (None)

ScaleMode

II.

184

5.6 ()

ScaleWidth

ScaleHeight

Left

Top

Width

Height

, PictureBox, ,
.
,
Picture
(. 5.14) Load Picture . , , , ,
(Visual Basic ).
,
AutoSize True.
PictureBox
LoadPicture. , Picture.

5.

185

,
Picture1.Picture = LoadPicture("d:\images\ufo.bmp")

Picture1 , .

. 5.14. ,
Picture

, ,
Image.
Image . 5.7.
5.7. Image

Picture

II.

186

5.7 ()

Stretch

,
. , True

Width

( )

Height

Left

Top

Visible

.
(False) (True)

Appearance

.
(
3D)
( Flat)

BorderStyle

.
(FixedSingle) (None)

, Image,
( Picture), ( LoadPicture). , Image (
Stretch False) .

5.

187

Image
" " ( . 5.15).
(JPG-), .

. 5.15.
" "

(. 5.16),

.
.
Image1
. 5.8 . 5.9, 5.7.

II.

188

. 5.16. , ,

5.8.

Form1.BorderStyle

FixedSingle

Form1.ScaleMode

Pixel

5.9. Image1

Width

400

Height

300

Stretch

False

5.

189

5.7.
Option Explicit
Private Declare Function SHBrowseForFolder Lib "shell32"
Alias "SHBrowseForFolderA" (ByRef b As Any) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32"
(ByVal ResPIDL As Any, ByVal patch As String) As Long
' SHELL API
Const CSIDL_DRIVES As Long = 17
Const BIF_RETURNONLYFSDIRS As Long = 1
Const MAX_PATH = 260
'
' SHBrowseFolder,
'
Private Type bi ' browseinfo
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String ' ( )
lpzTitle As String

'

ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Dim Folder As String

' ,
'

Dim fn As String

'

Dim ImageW, ImageH As Integer

'
' Image

II.

190
Private Sub Form_Load()

' ,
' ,
'
Form1.ScaleMode = 1 ' ScaleMode Twip
' Image1
ImageW = Image1.Width
ImageH = Image1.Height
' Environ("HOMEDRIVE")
' Environ("HOMEPATH")
' Windows XP Documents and Settings\User,
' User
Folder = Environ("HOMEDRIVE") + _
Environ("HOMEPATH") + _
"\ \ \"
fn = Dir(Folder + "*.jpg") ' JPG-
If fn = "" Then
MsgBox " " & Folder & _
" JPG- ", _
vbExclamation, " "
Exit Sub
End If
DisplayPic (Folder + fn) '
fn = Dir ' JPG-
If fn = "" Then

5.

191

' Folder
' jpg
Command2.Enabled = False
Else
Command2.Enabled = True
End If
End Sub
' Image1
Private Sub DisplayPic(fn As String)
' :
Dim kx As Single ' X
Dim ky As Single ' Y
Dim k

As Single '

' fn
Image1.Visible = False
Image1.Stretch = False '
'
Image1.Picture = LoadPicture(fn)
' Image1.Picture.Width
' Image1.Picture.Height
' ( )
If (Image1.Picture.Width <= ImageW) And _
(Image1.Picture.Height <= ImageH) Then
'
Image1.Visible = True
Else
' , Image1

II.

192

'
Image1.Stretch = True
'
kx = ImageW / Image1.Picture.Width
ky = ImageH / Image1.Picture.Height
' ,
'
'
If kx < ky Then k = kx Else k = ky
Image1.Width = Image1.Picture.Width * k
Image1.Height = Image1.Picture.Height * k
Image1.Visible = True
End If
End Sub

'
Private Sub Command2_Click()
DisplayPic (Folder + fn) '
'
fn = Dir
If fn = "" Then
' Folder
' jpg
Command2.Enabled = False
End If
End Sub

'
Private Sub Command1_Click()

5.

193

'
' ( ,
' , ), .
' ,
'
' Folder

Dim buf As String


buf = GetFolder()
If buf = "" Then Exit Sub
'
Folder = buf
' JPG-
fn = Dir(Folder + "*.jpg")
If fn = "" Then
MsgBox " " & Folder & " _
JPG-", _
vbExclamation, " "
Exit Sub
End If

DisplayPic (Folder + fn) '


' Image1
'
fn = Dir

II.

194
If fn = "" Then

' Folder jpg


Command2.Enabled = False
Else
Command2.Enabled = True
End If
End Sub
' ,
'
Public Function GetFolder() As String
Dim t As bi
Dim ResPIDL As Long
Dim Path As String
Dim r As Long
Dim p As String
t.hwndOwner = Form1.hwnd
t.lpzTitle = " , _
"
t.ulFlags = BIF_RETURNONLYFSDIRS ' OK ,
'
t.pszDisplayName = String(MAX_PATH, 0)
ResPIDL = SHBrowseForFolder(t) '
If ResPIDL <> 0 Then
'
'

5.

195

Path = String(MAX_PATH, Chr(0))


r = SHGetPathFromIDList(ResPIDL, Path)
p = InStr(1, Path, Chr(0))
Path = Mid(Path, 1, p - 1)
If Mid(Path, p - 1, 1) <> "\" Then Path = Path + "\"
End If
GetFolder = Path
End Function

Load
ImageW ImageH
Image1. . Dir,
JPG- ( ), .
DisplayPic, Image1 . True Visible
( Image1 ), .
LoadPicture. ,
Image1, Visible True, Image1 .
, , . , True
Stretch (
, ). , Image1
.
. -

196

II.

.

Image1 ( ImageW ImageH) ( Picture.Width Picture.Height Image1).
DisplayPic ,
True Stretch Visible. .
Click Dir,
. ,
JPG-, ,
Dir.
Click
GetFolder,
. API-
SHBrowseForFolder. ,
GetFolder
. Dir
jpg.
, Dir
( ,
Dir , ).


, , .
(bitmap) , -

5.

197

.
, , .
.

.
, .
Visual Basic StdPicture.
StdPicture (. 5.10)
.
5.10. StdPicture

Type

. ,

Width

Height

Handle

. API

LoadPicture. , ufo.bmp ufo:


Dim ufo As StdPicture
Set ufo = LoadPicture("d:\pictures\ufo.bmp")

(
),
PictureBox.
PaintPicture.

198

II.

PaintPicture
:
.PaintPicture aBitmap, x1,y1,w1,h1,x2,y2,w2,h2,opcode

x2, y2, w2 h2 , .
x1, y1, w1 h1 , ,
x2, y2, w2 h2. ,
PaintPicture
. opcode ,
. , vbSrcCopy,

.
PaintPicture
, . ,
Form1.PaintPicture ufo,10,20

ufo UFO " ".


PaintPicture "" ,
" " (. 5.17).
, , PaintPicture
"" ,
- .
, , , , , ,
. , .

5.

199

. 5.17.

. 5.18 .

. 5.18.

,
PaintPicture
, . opcode PainPicture
vbSrcAnd, vbSrcPaint.
( 5.8) , . : .
Load. Paint. , .
Bitmap

II.

200

. , Bitmap
.
Bitmap . 5.19.
5.8.
Option Explicit
'
Dim plane As StdPicture

'

Dim plane_m As StdPicture

'

Private Sub Form_Load()


'
Set plane = LoadPicture("d:\pictures\plane.bmp")
Set plane_m = LoadPicture("d:\pictures\plane_m.bmp")
End Sub

Private Sub Form_Paint()


'
Form1.PaintPicture plane_m, 50, 80, , , , , , , vbSrcAnd
'
Form1.PaintPicture plane, 50, 80, , , , , , , vbSrcPaint
End Sub

'
Private Sub Command1_Click()
Form1.PaintPicture plane_m, 200, 170, , , , , , , _
vbSrcAnd
End Sub

5.

201

' Bitmap
Private Sub Command2_Click()
Form1.PaintPicture plane, 200, 170, , , , , , ,
vbSrcPaint
End Sub

. 5.19.

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

II.

202

) " ".

"". .
"-" ( . 5.20, . 5.11)
, ,
, .

. 5.20. "-"

5.11. "-"

BorderStyle

FixedSingle

ScaleMode

Pixel

, , , , , "" ,
. ,

5.

203

( )
.
( 5.9)

Timer. ()
. dx
dy. dx (dy) , ( ),
( ).
dx dy , ""
.
dx dy, Timer.
5.9. -
Option Explicit
Dim x, y As Integer

'

Dim dx, dy As Integer

'

Dim r As Integer

'

Dim cBall As Long

'

Dim cBack As Long

'

Dim wp, hp As Integer

' ()

Private Sub Form_Load()


r = 2
x = r
y = 50
dx = 1
dy = 1

II.

204

cBall = RGB(217, 217, 25) ' -


cBack = RGB(33, 94, 33)

' ""

Form1.BackColor = cBack
wp = Form1.ScaleWidth
hp = Form1.ScaleHeight
'
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
'
Private Sub Timer1_Timer()
'
Form1.Circle (x, y), r, cBack
' ** **
If dx > 0 Then
'
If x + dx + r > wp Then dx = -dx
Else
'
If x + dx - r < 0 Then dx = -dx
End If
If dy > 0 Then
'

5.

205

If y + dy + r > Form1.ScaleHeight Then dy = -dy


Else
'
If y + dy - r < 0 Then dy = -dy
End If
x = x + dx
y = y + dy
'
Form1.Circle (x, y), r, cBall
End Sub


. .
( 5.10) , . "--2" (. 5.21), .
Timer.
KeyDown, .
rd . rd Timer , ,
. ,
Timer "" . ,
, ,
: . KeyUp
rd
Timer,
.

II.

206

. 5.21.

5.10. --2
Option Explicit
Dim x, y As Integer

'

Dim dx, dy As Integer

'

Dim r As Integer

'

Dim cBall As Long

'

Dim cBack As Long

'

Dim wp, hp As Integer

' ()

'
Dim rd As Integer ' 0 ;
' 1 ; 2
Dim rx1, rx2 As Integer ' X
Dim ry As Integer

' Y

Dim rdx As Integer

'

Private Sub Form_Load()


r = 3
x = r
y = 50

5.

207

dx = 1
dy = 1
cBall = RGB(217, 217, 25)
cBack = RGB(33, 94, 33)
Form1.BackColor = cBack
wp = Form1.ScaleWidth
hp = Form1.ScaleHeight
' ** **
rd = 0

'

rx1 = 100
rx2 = 125
ry = Form1.ScaleHeight - 20
rdx = 2 '
End Sub
Private Sub Form_Paint()
Form1.Line (rx1, ry)-(rx2, ry), vbRed '
'
End Sub
Private Sub Timer1_Timer()
' *** ****
'
Form1.Circle (x, y), r, cBack
'
If dx > 0 Then

II.

208

'
If x + dx + r > wp Then dx = -dx
Else
'
If x + dx - r < 0 Then dx = -dx
End If
If dy > 0 Then
'
If (x >= rx1) And (x <= rx2) And (y = ry - r - 1)
Then
'
dy = -dy
Else
If y + dy + r > Form1.ScaleHeight Then dy = -dy
End If
Else
'
If (x >= rx1) And (x <= rx2) And _
(y >= ry - r) And (y <= ry + r) Then
'
'
' ,
Line (rx1, ry)-(rx2, ry), vbRed
End If
If y + dy - r < 0 Then dy = -dy
End If
x = x + dx
y = y + dy
'
Form1.Circle (x, y), r, cBall

5.

209

'*** ***
If rd <> 0 Then
'
' " " " "
' (. Form_KeyDown)
If rd = 1 Then
'
If rx2 < wp Then
Line (rx1, ry)-(rx1 + rdx, ry), cBack
'
Line (rx2, ry)-(rx2 + rdx, ry), vbRed
'
rx1 = rx1 + rdx
rx2 = rx2 + rdx
End If
Else
'
If rx1 > 1 Then
Line (rx2, ry)-(rx2 - rdx, ry), cBack
'
Line (rx1 - rdx, ry)-(rx1 + rdx, ry), vbRed
'
rx1 = rx1 - rdx
rx2 = rx2 - rdx
End If
End If
End If
End Sub
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As
Integer)

II.

210
If rd <> 0 Then

' ,
Exit Sub
End If
Select Case KeyCode
Case 37 ' ()
rd = 2
Case 39 ' ()
rd = 1
End Select
End Sub
'
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
rd = 0
End Sub


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

5.

211

. PaintPicture,
,
(. 5.22).

Form1

aStdImage

. 5.22. ,
,

5.11.
Option Explicit
'
Dim back As StdPicture

'

Dim plane As StdPicture

'

Dim plane_m As StdPicture

'

Dim x, y As Integer

' ()

Dim dx, dy As Integer '


Dim w, h As Integer '
Private Sub Form_Load()
Set back = LoadPicture("d:\Pictures\sky.bmp")
Set plane = LoadPicture("d:\ Pictures \plane.bmp")
Set plane_m = LoadPicture("d:\ Pictures \plane_m.bmp")

II.

212

'
'
' StdPicture
' , HiMETRIC
' HiMETRIC
' ScaleX ScaleY

Form1.Width = ScaleX(back.Width, vbHimetric, vbTwips)


Form1.Height = (Form1.Height - Form1.ScaleHeight) + _
ScaleY(back.Height, vbHimetric, vbTwips)

Form1.Picture = back

w = ScaleX(plane.Width, vbHimetric, vbPixels)


h = ScaleY(plane.Height, vbHimetric, vbPixels)

Form1.ScaleMode = vbPixels

'
x = 0
y = 100

'
'
dx = 1
Timer1.Interval = 10
Timer1.Enabled = True

End Sub

5.

213

Private Sub Timer1_Timer()


'
Form1.PaintPicture back, x, y, w, h, x, y, w, h
' *** ***
'
Form1.PaintPicture plane_m, x, y, , , , , , , vbSrcAnd
'
Form1.PaintPicture plane, x, y, , , , , , , vbSrcPaint
If x < Form1.ScaleWidth Then
x = x + dx
Else
x = 0
dx = 1 + 1 * Rnd
End If
End Sub

Load
( ,
),
, , .
Timer.

( ''"
), .

II.

214



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


VB Resource Editor, Visual Basic. VB
Resource Editor, Tools Resource
Editor.
VB Resource Editor . 5.23.

Resource Editor Tools ,
Add-Ins Add-In Manager. Avalable Add-Ins Add-In Manager
VB 6 Resource Editor, Load Behavior Loaded/Unloaded Load on Startup
OK.
Visual Basic.

5.

215

. 5.23. VB Resource Editor

,
Add Bitmap (. 5.24)
BMP-, , .

. 5.24. AddBitmap


,
Bitmap. , , . ,
. .
, -

216

II.

Properties ID .
, () . ,
, .
. 5.25 , "
". bitmaps.RES : (101), (102) (103).

. 5.25.


,
, ,
Project Explorer

5.

217

AddResource File .

(. 5.26).

. 5.26.


LoadResPicture.
vbResBitmap.
,
plane = LoadResPicture(101, vbResBitmap)

plane 101.
5.12 "
", .

II.

218

5.12. (
)
Option Explicit
'
Dim back As StdPicture

'

Dim plane As StdPicture

'

Dim plane_m As StdPicture

'

Dim x, y As Integer

' ()

Dim dx, dy As Integer '


Dim w, h As Integer '
Private Sub Form_Load()
'
Set plane = LoadResPicture(101, vbResBitmap)

'

Set plane_m = LoadResPicture(102, vbResBitmap) '


Set back = LoadResPicture(103, vbResBitmap)

'

'
' .
' StdPicture
' , HiMETRIC.
' HiMETRIC
' ScaleX ScaleY
Form1.Width = ScaleX(back.Width, vbHimetric, vbTwips)
Form1.Height = (Form1.Height - Form1.ScaleHeight) + _
ScaleY(back.Height, vbHimetric, vbTwips)

5.

219

Form1.Picture = back
w = ScaleX(plane.Width, vbHimetric, vbPixels)
h = ScaleY(plane.Height, vbHimetric, vbPixels)
Form1.ScaleMode = vbPixels
'
x = 0
y = 60
'
'
dx = 1
Timer1.Interval = 10
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()


'
Form1.PaintPicture back, x, y, w, h, x, y, w, h
'
'
Form1.PaintPicture plane_m, x, y, , , , , , , vbSrcAnd
'
Form1.PaintPicture plane, x, y, , , , , , , vbSrcPaint
If x < Form1.ScaleWidth Then
x = x + dx

II.

220
Else
x = 0
dx = 1 + 1 * Rnd

' Timer1.Enabled = False


End If
End Sub

, , ,
. .

, Windows,
.
, , ,
.
.
Visual Basic MMControl (Microsoft Multimedia Control), . API- PlaySound.

PlaySound
API- PlaySound
,
,
. ,
WAV-. PlaySound

Windows.
PlaySound ,
:
Private Declare Function PlaySound Lib "winmm.dll" Alias
"PlaySoundA" _

222

II.
(ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

PlaySound
:
r = PlaySound(, 0, )

, ,
. : . PlaySound

, . , .
, &H1 ( ) &H0 ( ).
,
PlaySound ("tada.wav", 0, &H1)


.
,
( ),
PlaySound : ,
Windows. , "
" ( Windows). " ".
&H2.
PlaySound
PlaySound. (. 6.1)
notify.wav.
.
recycle.wav.

6.

223

FileListBox. Pattern Path.


Pattern *.wav,
Path Media,
Windows. File1,
, , Initialize. ,
- notify.wav Media
, ,
, PlaySound
SND_NODEFAULT. 6.1.

. 6.1.
API- PlaySound

6.1. API- PlaySound


Option Explicit
' API-,

II.

224

Private Declare Function PlaySound Lib "winmm.dll" Alias


"PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
' API-
Const SND_ASYNC = &H1
Const SND_SYNC = &H0

'

'

'

'

Const SND_NODEFAULT = &H2 '


'

"
"

Private Sub Form_Initialize()


' Environ "windir"
' Windows
File1.Pattern = "*.wav"
File1.Path = Environ("windir") + "\Media\"
PlaySound File1.Path + "\notify.wav", 0, SND_ASYNC + _
SND_NODEFAULT
End Sub
' Play
Private Sub Command1_Click()
Dim aWAVFile As String ' ,
aWAVFile = File1.Path + "\" + File1.FileName
PlaySound aWAVFile, 0, SND_ASYNC
End Sub
'
'

6.

225

Private Sub Form_Unload(Cancel As Integer)


PlaySound Environ("windir") + "\Media\" + _
"recycle.wav", 0, _
SND_ASYNC + SND_NODEFAULT
End Sub

MMControl
MMControl
(WAV, MP3, MID) (AVI), CD.

. 6.2. MMControl

. 6.3. MMControl

II.

226

(. 6.2) , :
Project Components, Controls Components Microsoft
Multimedia Control 6.0 (. 6.3) OK.
MMControl (. 6.4),
, -
. . 6.1.
MMControl, ,
. 6.2. , , Enable Visible.
Enable , Visible .

. 6.4. MMControl

6.1. MMControl

Play

Pause

Stop

Next

Prev

Step

, CD

6.

227

6.1 ()

Back

, CD

Record

Eject

CD-

6.2. MMControl

DeviceType

. , MMControl.
: WaveAudio ; AVIVideo ; CDAudio CD-

FileName

UpdateInterval


StatusUpdate,
. , CD
()

, (. 6.3)
MMControl Properties .

II.

228

6.3. MMControl,

Length

, (, WAV AVI)
CD

Tracks


( CD)

Track

Position

, CD

TrackPosition

CD ( CD ,
TimeFormat)

TrackLength

,
CD

TimeFormat


Length, Position, TrackLength
TrackPosition. mciFormatMilliseconds

Mode

. (msiModePlay).
(msiModeStop) (msiModePause)

hWndDisplay

(), , .
, ,

6.

229

( MMControl) ( ) ,
(. 6.4) Command. , , MMControl,
() Close.
6.4. MMControl

Open

Play

. Play

Stop

Pause

Next

, CD

Prev

,
CD

Step

Back

MP3-
MMControl ,
(MP3 WAV) .
"MP3-" . 6.5.
File1 (FileList) .

230

II.

. 6.5. "MP3-"

Label1 , Label2

6.

231

, Label3 . Command1 , , .
6.2.
6.2. MP3-
Option Explicit
' API-
Private Declare Function SHBrowseForFolder Lib "shell32"
Alias _
"SHBrowseForFolderA" (ByRef b As Any) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" _
(ByVal ResPIDL As Any, ByVal patch As String)
As Long
' SHELL API
Const CSIDL_DRIVES As Long = 17
Const BIF_RETURNONLYFSDIRS As Long = 1
Const MAX_PATH = 260
Const mciTormatMilleseconds = 0
'
' SHBrowseFolder,
'
Private Type bi ' browseinfo
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String ' ( )
lpzTitle As String

'

II.

232
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Dim status As Integer ' :


'

0 ()

'

'
Private Sub Form_Initialize()
Dim aPath As String
On Error Resume Next
aPath = Environ("homepatch") + File1.Path + _
"\ \ "
File1.Path = aPath
Label1.Caption = aPath
' File1
' mp3
File1.Pattern = "*.mp3"
' MMControl1 Play, Pause, Step
' Back,
MMControl1.PrevVisible = False
MMControl1.NextVisible = False
MMControl1.RecordVisible = False
MMControl1.EjectVisible = False

6.

233

Form1.ScaleMode = vbPixels
File1.ListIndex = 0
status = 0 ' ""
End Sub
'
' ListIndex
Private Sub File1_Click()
If MMControl1.Command <> "CLOSE" Then MMControl1.Command =
"CLOSE"
If File1.FileName <> "" Then
MMControl1.FileName = File1.Path + "\" + File1.FileName
MMControl1.TimeFormat = mciTormatMilleseconds
MMControl1.Command = "OPEN"
Label2.Caption = toHMS(MMControl1.Length)
Label3.Caption = "00:00"
If status = 1 Then
' Step Back,
' ,
'
'
MMControl1.Command = "Play"
End If
End If
End Sub

II.

234
'

Private Sub MMControl1_PauseClick(Cancel As Integer)


' ,
'
If status = 0 Then
status = 1
Command1.Enabled = False
Else
status = 0
Command1.Enabled = True
End If
End Sub
' Play
Private Sub MMControl1_PlayClick(Cancel As Integer)
status = 1
Command1.Enabled = False
End Sub
'
Private Sub MMControl1_StopClick(Cancel As Integer)
status = 0
Command1.Enabled = True
End Sub
' Step
'
Private Sub MMControl1_StepClick(Cancel As Integer)
If File1.ListIndex < File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
If File1.ListIndex = File1.ListCount Then

6.
MMControl1.StepEnabled = False
End If
Else
File1.ListIndex = 0
End If
End Sub
' Back
'
Private Sub MMControl1_BackClick(Cancel As Integer)
If File1.ListIndex > 0 Then
File1.ListIndex = File1.ListIndex - 1
Else
File1.ListIndex = File1.ListCount - 1
End If
End Sub
' StatusUpdate, MMControl
Private Sub MMControl1_StatusUpdate()
If MMControl1.Position < MMControl1.Length Then
'
Label3.Caption = toHMS(MMControl1.Position)
Else
'
If File1.ListIndex < File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
Else
MMControl1.Command = "Stop"
status = 0
Command1.Enabled = True

235

II.

236
End If
End If
End Sub

' Eject ( )
Private Sub Command1_Click()
Dim ResPIDL As Long
Dim t As bi
Dim Path As String
Dim r As Long
Dim p As String
t.hwndOwner = Form1.hWnd
t.lpzTitle = " , _
MP3-"
t.ulFlags = BIF_RETURNONLYFSDIRS ' OK
' ,
t.pszDisplayName = String(MAX_PATH, 0)
ResPIDL = SHBrowseForFolder(t) '
If ResPIDL <> 0 Then
'
'
Path = String(MAX_PATH, Chr(0))
r = SHGetPathFromIDList(ResPIDL, Path)
' Path -,
' NULL- ( 0).
' ,

6.

237

p = InStr(1, Path, Chr(0)) ' NULL-


Path = Mid(Path, 1, p - 1)
If Mid(Path, p - 1, 1) <> "\" Then Path = Path + "\"
File1.Path = Path

'
'
' File1 (FileList)

File1.ListIndex = 0 '
' File1.Click
End If
End Sub
' (
' ) "::"
Private Function toHMS(time As Long) As String
Dim H As Integer

'

Dim M As Integer

'

Dim S As Integer

'

H = Int((time / 1000) / 3600)


M = Int((time / 1000 Mod 3600) / 60)
S = (time / 1000 Mod 3600) Mod 60
If H > 0 Then toHMS = Str(H) + ":"
toHMS = toHMS + Format(M, "0#") + ":" + Format(S, "0#")
End Function
'
Private Sub Form_Unload(Cancel As Integer)

II.

238

MMControl1.Command = "STOP"

'
'

MMControl1.Command = "CLOSE"

' ""

End Sub

.
Initialaze
Path Pattern File1 (FileList), , \ .
, , , On Error
Resume Next ( ). , Play. Click File1
, (,
) Label2.
( Length MMControl1), , :
toHMS.
MMControl1
StatusUpdate (
UpdateInterval).
Label3 Position
, .

MIDI
, ,
, MIDI, .
MIDI

6.

239

(Musical Instrument Digital Interface)


. MIDI-.
MIDI-
MMControl " " (
. 6.6 . 6.7). (, MIDI-)
.

. 6.6. " "

. 6.7.
" " MIDI-

, MMControl
( Visible

II.

240

MMControl False).
( )
Command.
" " 6.3.
6.3.
Option Explicit
Dim comp As Integer

' ,

Dim sek As Integer

' ( )

'
Private Sub Form_Load()
MMControl1.Visible = False
MMControl1.FileName = Dir("*.mid")
If MMControl1.FileName = "" Then
' MIDI-
' Windows\Media
MMControl1.FileName = Environ("windir") + "\Media\" + _
Dir(Environ("windir") + _
"\Media\*.mid")
End If
' MIDI-
MMControl1.Command = "Open"
MMControl1.Command = "Play"
Randomize (Time()) '
'

6.

241

comp = Int(99 * Rnd() + 1) ' 1 99


Command1.Enabled = False
Text1.MaxLength = 2
Text1.Text = ""
sek = 60 ' 60
End Sub
Private Sub Form_Activate()
Text1.SetFocus
End Sub
' MMControl
Private Sub MMControl1_StatusUpdate()
If MMControl1.Position = MMControl1.Length Then
'
MMControl1.Command = "Prev" '
'
MMControl1.Command = "Play" '
End If
End Sub

'
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57

'

Case 8

' <Backspace> ""

Case 13

' <Enter>

' ,

II.

242
Call IsItOk
Case Else

'
KeyAscii = 0
End Select
End Sub
'
Private Sub Text1_Change()
' OK ,
' 2
Label6.Caption = ""
If Len(Text1.Text) = 0 Then
Command1.Enabled = False
Else
Command1.Enabled = True
End If
End Sub
' OK
Private Sub Command1_Click()
Call IsItOk
End Sub
' ,
Sub IsItOk()
Dim igrok As Integer '
igrok = CInt(Text1.Text)
If igrok = comp Then
Timer1.Enabled = False '

6.

243

Command1.Enabled = False
Text1.Enabled = False
Label6.Caption = "!"
MsgBox "! _
" + Str(60 - sek) + ".", _
vbOKOnly, " "
Else
If igrok < comp Then
Label6.Caption = ""
Else
Label6.Caption = ""
End If
End If
End Sub
'
Private Sub Timer1_Timer()
sek = sek - 1
Label1.Caption = Str(sek)
If sek = 0 Then
' , ,
Timer1.Enabled = False
Command1.Enabled = False
Text1.Enabled = False
MsgBox " _
." + vbCr + _
" : " + Str(comp), _
vbOKOnly, " "
End If
End Sub

II.

244

'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop"

'

MMControl1.Command = "Close" ' ""


End Sub

. Load FileName
MMControl MIDI-, . Dir. mid, MIDI- Media,
Windows ( Windows ). Windows - (, Windows
Winnt),
Environ windir.
Environ ( . environment ) windir, Windows.
Open Play. , MIDI-. StatusUpdate.
Length (, ) , ,
Prev ( ) Play.
. , ,
. . KeyPress Text
.
Change -

6.

245

OK,
.
. , Unload .

CD-
,
MMControl
-. CD Player
. 6.8, MMControl1 . 6.5.
Timer1 "",
CD.

. 6.8. CD Player

6.5. MMControl1

DeviceType

CDAudio

BackVisible

False

StepVisible

False

II.

246

6.5 ()

StopVisible

False

RecordVisible

False

BorderStyle

msiNone

UpdateInterval

1000

. 6.9.
, ,
.
Play .

. 6.9.

CD

. 6.10.

6.

247


, (. 6.10).
6.3.
StatusUpdate,
MMControl (
UpdateInterval). , ,
,
CD. , ( Mode 526).
, Position () , . , ,
Position TrackPosition ( ).
, Track
. ,
Position
(TrackPosition + TrackLength),
Track , Position , Length,
.
( Ready)
( Stop 1),
StatusUpdate .
( )
Visible Label1, ,
Label1, Timer1.Interval.
, , Unload,
,
.

II.

248
6.4. CD-
Option Explicit
'
Private Sub Form_Load()

MMControl1.DeviceType = "CDAudio"
MMControl1.Command = "Open"
MMControl1.TimeFormat = 0 '
'

End Sub
' CD,
'
Private Sub MMControl1_StatusUpdate()
Select Case MMControl1.Mode
Case 525: ' msiModeStop
If MMControl1.Tracks > 1 Then
Label1.Caption = " Play"
Label2.Caption = _
": " + Str(MMControl1.Tracks) + _
" : " + _
toHMS(MMControl1.Length)
Else
Label1.Caption = " !"
Timer1.Enabled = True
End If
Case 526: ' msiModePlay
Timer1.Enabled = False
Label1.Visible = True
Label2.ForeColor = &H80000012

'
'

Button Text

6.

249

If MMControl1.Position < _
MMControl1.TrackPosition + _
MMControl1.TrackLength Then
'
Label1.Caption = _
": " + Format(MMControl1.Track, _
"0#") + "

" +

toHMS(MMControl1.Position - _
MMControl1.TrackPosition)
Else
'
If MMControl1.Position < MMControl1.Length
Then
'
MMControl1.Track = MMControl1.Track + 1
Label1.Caption = _
": " + Format(MMControl1.Track, _
"#") + "

" + _

toHMS(MMControl1.Position - _
MMControl1.TrackPosition)
Else
MMControl1.Command = "Stop"
End If
End If
Case 529: ' msiModePause
Label1.Caption = "Pause"
Timer1.Enabled = True
Case 530: ' msiModeReady
Label1.Caption = " !"
Label2.Caption = ": 0 : 0:00"
Label2.ForeColor = &H80000011

'
' Disabled Text

II.

250

Timer1.Enabled = True
Case Else
Label1.Caption = "Mode:" & Str(MMControl1.Mode)
End Select
End Sub
'
Private Sub Timer1_Timer()
DoEvents
Label1.Visible = Not Label1.Visible
End Sub
'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop"

'
' CD

MMControl1.Command = "Close"
End Sub
' ( )
' "::"
Private Function toHMS(time As Long) As String
Dim H As Integer

'

Dim M As Integer

'

Dim S As Integer

'

H = Int((time / 1000) / 3600)


M = Int((time / 1000 Mod 3600) / 60)
S = (time / 1000 Mod 3600) Mod 60
If H > 0 Then toHMS = Str(H) + ":"
toHMS = toHMS + Format(M, "0#") + ":" + Format(S, "0#")
End Function

6.

251



(. 6.11).
. , MP3 ( WAV-
).

. 6.11.

WAV-
API- waveOutSetVolume.
:
r = waveOutSetVolume(, )

, .
WAV- .
( 4 )
:

252

II.

, .
FFFF, 0000. , , &HFFFFFFFF (
Visual Basic &H). 50%
&H7FFF7FFF.
, waveOutSetVolume
,
(. p. 6.11).
MP3-,
"MP3-" (
. 6.12).

. 6.12. MP3-


Slider ( ,
Microsoft Windows Common Controls-2 6.0

6.

253

Project Components ).
Slider . 6.6. ,
Value
, . Value 65535 0.
, , Value
, .
6.5.
6.6. Slider

Orientation

ccOrientationVertical

TickStyle

slbBoth

Height

89

Width

42

Min

-65535

Max

TickFrequency

10992

SmallChange

256

LargeChange

8192

6.5. MP3-
Option Explicit
' API-:
'

II.

254

Private Declare Function waveOutSetVolume Lib "winmm.dll" _


(ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
'
Private Declare Function waveOutGetVolume Lib "winmm.dll" _
(ByVal uDeviceID As Long, ByVal dwVolume As Long) As Long
' API-
Private Declare Function SHBrowseForFolder Lib "shell32"
Alias "SHBrowseForFolderA" (ByRef b As Any) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32"
(ByVal ResPIDL As Any, ByVal patch As String) As Long
' SHELL API
Const CSIDL_DRIVES As Long = 17
Const BIF_RETURNONLYFSDIRS As Long = 1
Const MAX_PATH = 260
Const mciTormatMilleseconds = 0
'
' SHBrowseFolder,
'
Private Type bi ' browseinfo
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String ' ( )
lpzTitle As String
ulFlags As Long
lpfn As Long
lParam As Long

'

6.

255

iImage As Long
End Type
Dim status As Integer ' :
'

0 ()

'

'
Private Sub Form_Initialize()
Dim v As Long '
Dim st As String * 8
Dim aPath As String
' Slider
With Slider1
.Min = -65535
.Max = -0
.SmallChange = 256
.LargeChange = 8192
' ,
'
.Height = 89
.Width = 42
.TickFrequency = 10992
End With
' 30%
v = &H2FFF
st = Hex(v) & Hex(v)
' st
'

II.

256

waveOutSetVolume 0, "&H" & st '


'
Slider1.Value = -v ' ,
'
'
On Error Resume Next
aPath = Environ("homepatch") + File1.Path + _
"\ \ "
File1.Path = aPath
Label1.Caption = aPath
File1.Pattern = "*.mp3"
' MMControl1 Play, Pause,
' Step Back
'
MMControl1.PrevVisible = False
MMControl1.NextVisible = False
MMControl1.RecordVisible = False
MMControl1.EjectVisible = False
Form1.ScaleMode = vbPixels
File1.ListIndex = 0
status = 0 '
End Sub
' Scroll
' , " ", " ", <PgUp>
' <PgDown>
Private Sub Slider1_Scroll()

6.
Dim v As Long

257
'

Dim st As String '


'
v = Abs(Slider1.Value)
st = "000" + Hex(v)
st = Right(st, 4)
st = st + st
waveOutSetVolume 0, "&H" + st
End Sub
'
' ListIndex
Private Sub File1_Click()
If MMControl1.Command <> "CLOSE" Then _
MMControl1.Command = "CLOSE"
' Label1.Caption = File1.Path + "\" + File1.FileName
If File1.FileName <> "" Then
MMControl1.FileName = File1.Path + "\" + File1.FileName
MMControl1.TimeFormat = mciTormatMilleseconds
MMControl1.Command = "OPEN"
Label2.Caption = toHMS(MMControl1.Length)
Label3.Caption = "00:00"
If status = 1 Then
MMControl1.Command = "Play"
End If
End If
End Sub

II.

258
'

Private Sub MMControl1_PauseClick(Cancel As Integer)


' ,
'
If status = 0 Then
status = 1
Command1.Enabled = False
Else
status = 0
Command1.Enabled = True
End If
End Sub
' Play
Private Sub MMControl1_PlayClick(Cancel As Integer)
status = 1
Command1.Enabled = False
End Sub
'
Private Sub MMControl1_StopClick(Cancel As Integer)
status = 0
Command1.Enabled = True
End Sub
' Step
'
Private Sub MMControl1_StepClick(Cancel As Integer)
If File1.ListIndex < File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
If File1.ListIndex = File1.ListCount Then

6.
MMControl1.StepEnabled = False
End If
Else
File1.ListIndex = 0
End If
End Sub
' Back
'
Private Sub MMControl1_BackClick(Cancel As Integer)
If File1.ListIndex > 0 Then
File1.ListIndex = File1.ListIndex - 1
Else
File1.ListIndex = File1.ListCount - 1
End If
End Sub
' StatusUpdate, MMControl
Private Sub MMControl1_StatusUpdate()
If MMControl1.Position < MMControl1.Length Then
'
Label3.Caption = toHMS(MMControl1.Position)
Else
'
If File1.ListIndex < File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
Else
MMControl1.Command = "Stop"
status = 0
Command1.Enabled = True
End If

259

II.

260
End If
End Sub

' Eject ( )
Private Sub Command1_Click()
Dim ResPIDL As Long
Dim t As bi
Dim Path As String
Dim r As Long
Dim p As String
t.hwndOwner = Form1.hWnd
t.lpzTitle = " , _
MP3-"
t.ulFlags = BIF_RETURNONLYFSDIRS ' OK ,
'
'
t.pszDisplayName = String(MAX_PATH, 0)
ResPIDL = SHBrowseForFolder(t) '
If ResPIDL <> 0 Then
'
'
Path = String(MAX_PATH, Chr(0))
r = SHGetPathFromIDList(ResPIDL, Path)
' Path -,
' NULL- ( 0).
' ,
p = InStr(1, Path, Chr(0)) ' NULL-
Path = Mid(Path, 1, p - 1)
If Mid(Path, p - 1, 1) <> "\" Then Path = Path + "\"

6.

261

File1.Path = Path

'
'
' File1
' (FileList)

File1.ListIndex = 0 '
'

File1.Click

End If
End Sub

' (
' ) "::"
Private Function toHMS(time As Long) As String
Dim H As Integer

'

Dim M As Integer

'

Dim S As Integer

'

H = Int((time / 1000) / 3600)


M = Int((time / 1000 Mod 3600) / 60)
S = (time / 1000 Mod 3600) Mod 60
If H > 0 Then toHMS = Str(H) + ":"
toHMS = toHMS + Format(M, "0#") + ":" + Format(S, "0#")
End Function

'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "STOP"

'
'

MMControl1.Command = "CLOSE"
End Sub

' ""

262

II.


Scroll (
Slider), <PgUp>,
<PgDown> .
Value
,
,
, .

waveOutSetVolume. "" waveOutSetVolume .
. Visual Basic ,
:
Dim vl as Word
Dim vl as Word
Dim vl as DoubleWord
vl = &H7777
vr = &H7777
v = vl or vr
waveOutSetVolume 0, v

Visual Basic . (
) Long (4 ),

( ). (
)
00000 7FFF,
Long .
( &H10000 Long, &H7FFF)
, .

6.

263

MIDI
MIDI

midiOutSetVolume.

midiOutSetVolume , waveOutSetVolume.
.
MIDI-. MIDI , , , , .
( midiOutSetVolume) ,
.
, "
MIDI" ( . 6.13, 6.6).

. 6.13. MIDI

6.6. MIDI
Option Explicit
' API-
Private Declare Function midiOutSetVolume Lib "winmm.dll" _
(ByVal uDeviceID As Long, ByVal dwVolume As Long) As _
Long

II.

264

' uDeviceID ,
' dwVolume (c
' , )
Private Declare Function midiOutGetNumDevs Lib "winmm" ()
As Integer
Dim id As Long ' MIDI-,
'
Private Sub Form_Load()
Dim n As Integer ' - MIDI-
Dim r As Long

' - API-

Dim v As Long
Dim i As Long
' MIDI-,
' , .
'
n = midiOutGetNumDevs
For i = 0 To n - 1
r = midiOutSetVolume(i, "&H00FF00FF")
If r = 0 Then
' MsgBox "id=" & Str(i) & "r=" & Str(r)
id = i
Exit For
End If
Next i
UpDown1.Min = 0
UpDown1.Max = 65535 '
' FFFF

6.

265

UpDown1.Increment = (UpDown1.Max - UpDown1.Min) / 20


UpDown1.Value = UpDown1.Increment * 6 '
'
' 30%

MMControl1.FileName =

Dir("*.mid")

If MMControl1.FileName <> "*.mid" Then


Label2.Caption = MMControl1.FileName
MMControl1.Command = "OPEN"
MMControl1.Command = "Play"
Else
Label1.Caption = " MIDI-"
End If
End Sub
' Change
' Value, , ,
' UpDown
Private Sub UpDown1_Change()
Dim v As Currency
Dim s As String
Dim r As Long
v = UpDown1.Value
' value midiOutSetVolume
' , VB .
' (
' )
' midiOutSetVolume

II.

266

s = Right("000" & Hex(v), 4)


r = midiOutSetVolume(id, "&H" & s & s)
End Sub

' StatusUpdate MMControl


Private Sub MMControl1_StatusUpdate()
If MMControl1.Position >= MMControl1.Length Then
MMControl1.Command = "Stop"
MMControl1.Command = "Close"
MMControl1.FileName = Dir '
' MIDI-
If MMControl1.FileName <> vbNull Then
Label2.Caption = MMControl1.FileName
MMControl1.Command = "Open"
MMControl1.Command = "Play"
Else
' MIDI-
MMControl1.FileName = Dir("*.mid")
Label2.Caption = MMControl1.FileName
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End If
End If
End Sub

'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "STOP"
MMControl1.Command = "CLOSE"
End Sub

6.

267

.
Load API-
midiOutGetNumDevs, MIDI, .
( ,
midiOutSetVolume ). UpDown MIDI-.
Change UpDown.
, , MIDI- , , ,
. ( Dir
vbNull), Dir , .
. MIDI- .


, MMControl .

Video (. 6.14), ,
AVI.
Video . 6.15,
MMControl1 . 6.7. Picture1 , . CommonDialog1
,

Eject AVI-.

268

II.

. 6.14.
MMControl

. 6.15. Video

6.

269

,
MMControl, Play Eject,
Visible MMControl
False.
6.7. MMControl1

DeviceType

AVIVideo

hWndDisplay

Picture1.hWnd


.


Load

Visible

False

Video 6.7.
MMControl1: hWhdDisplay
AVI- .
Dir, ,
, . ( ,
) avi,
MMControl1 Open Next,
Picture1 . , Command1 , .
Play Pause.
, Command1 -

II.

270

. , Command1 . MMControl1
StatusUpdate.
,
, .
6.7.
Option Explicit
'
' ( AVI-)
Const cdlOFNHideReadOnly = &H4
" "

' CheckBox

Const cdlOFNFileMustExist = &H1000 '


'
'
'
Private Sub Form_Load()
' MMControl
MMControl1.hWndDisplay = Picture1.hWnd
' - Picture1
' AVI-
' MMControl1.FileName = Dir("*.avi")
If MMControl1.FileName <> "" Then
' AVI-
MMControl1.Command = "Open"

6.

271

MMControl1.Command = "Next" '


Command1.Enabled = True ' Play
End If
' CommonDialog
CommonDialog1.DialogTitle = " AVI-"
CommonDialog1.FileName = "*.avi"
CommonDialog1.Flags = cdlOFNHideReadOnly + _
cdlOFNFileMustExist
End Sub
' Play/Pause
Private Sub Command1_Click()
If (MMControl1.Mode = 525) Or _
(MMControl1.Mode = 529) Then ' 525 mciModeStop,
' 529 mciModePause
' "" ""
MMControl1.Command = "Play"
Command1.Caption = "Pause"
Command2.Enabled = False
Else
' ""
If MMControl1.Mode = 526 Then ' 526 mciModePlay
MMControl1.Command = "Pause"
Command1.Caption = "Play"
Command2.Enabled = True
End If
End If
End Sub
' Eject
' ( )

II.

272

Private Sub Command2_Click()


CommonDialog1.FileName = "*.avi"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "*.avi" Then
'
MMControl1.Command = "Close"
MMControl1.FileName = CommonDialog1.FileName
MMControl1.Command = "Open"
MMControl1.Command = "Next" '
Command1.Enabled = True
End If

End Sub

' StatusUpdate
Private Sub MMControl1_StatusUpdate()
If MMControl1.Position >= MMControl1.Length Then
MMControl1.Command = "Stop"
MMControl1.Command = "Prev"
Command1.Caption = "Play"
Command2.Enabled = True
End If
End Sub

'
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Stop"
MMControl1.Command = "Close"
End Sub

6.

273



, Visual Basic,
. . MMControl ActiveX- ( mci32.ocx). ,
, . ,
,
MMControl, , (EXE) ,
mci32.ocx. Windows (C:\Windows\System32). ,
,
. (
) regsvr32
mci32.ocx.
,
, . ,
, 9.


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

: Microsoft Access
Microsoft SQL Server Oracle.


() , . , ,
(). Microsoft Access . -

7.

275

, ,
.



,
,
.
,
(). .
. Microsoft Access .
, . "-". ()
. , , ,
.
() ,
() , . , , , . Microsoft SQL Server 2000, MySQL
Oracle .

276

II.



.
, .
. ,
""
Projects (), Tasks () Resources ().
. , . ,
Projects
( , , , ), Tasks ( , , , , ,
), Resources (, ).
. ( ) . ,
Projects ID ( ),
Title ( ), Start ( ), Finish ( ). ()
.


. Microsoft Visual Basic 6.0
Microsoft ActiveX Data Objects
(ADO ).
ADO Visual Basic ,

(Adodc, DataGrid .).

7.

277



Adodc,
DataGrid (. 7.1).
, Adodc , Microsoft Jet.

. 7.1. Adodc ,
DataGrid

. 7.2. Adodc DataGrid

II.

278

, , . 7.3.

Adodc

Jet

DataGrid

. 7.3. ,
/


ConnectionString ( )
Adodc ,
. , , Microsoft Access " ", AdrBk.mdb D:\Database, :
Provider=Microsoft.Jet.OLEDB.3.51;Data
Source=D:\Database\ADRBK.MDB


,
Microsoft Access "".

7.

279


Visual
Basic, Microsoft Access
"" (contacts.mdb).
"" -
Contacts (. 7.1).
7.1. a Contacts

Name

50

(, , ).

Phone

50

Comment

100



,

Adodc DataGrid ( Microsoft ADO Data Control 6.0 Microsoft DataGrid Control 6.0).
Adodc DataGrid (. 7.4).
.
Adodc
ConnectionString RecordSource. ConnectionString , .
( Adodc),
,

280

II.

ConnectionString, Property Pages


Use Connection String Build
(. 7.5).
"" (Microsoft
Jet 4.0 OLE DB Provider) (. 7.6).

. 7.4. ""

. 7.5. ,
Build

7.

281


(. 7.7). , ,
OK
, Property Pages.

. 7.6.
( 1)

ConnectionString Adodc .
RecordSource Adodc ,
.
( ), (, -

282

II.

), ,
. ,
, RecordSource SQL-, . ,
SELECT Name, Phone FROM Contacts

Contacts ,
Name Phone.

. 7.7. ( 2)

SQL-
RecordSource Command Text (. 7.8)

7.

283

RecordSource Property Page,


,
RecordSource.

. 7.8. Command Text SQL-,


Adodc . 7.2.
7.2. Adodc

ConnectionString

Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=D:\Database\Contacts.mdb;
Persist Security Info=False

RecordSource

SELECT Name, Phone FROM Contacts


ORDER BY Name

Visible

False

II.

284


.
. Visual Basic .
, (EXE) .

, , DataGrid,
,
(, ). DataGrid
(. 7.3) , .
7.3. DataGrid

DataSource

, ( Adodc)

AllowAddNew

AllowDelete

AllowUpdate

Caption

. ,

ColumnHeaders

.

. False,

HeadFont

Font

7.

285

,
DataGrid
, SELECT,
,
SELECT .
DataGrid , .
DataGrid Columns
Property Page,
DataGrid
Properties. Caption (. 7.9),
Column
DataGrid, DataField .

. 7.9. Caption

DataGrid1 . 7.4,
. 7.10.

II.

286

7.4. DataGrid1

DataSource

Adodc1

AllowAddNew

True

AllowDelete

True

AllowUpdate

True

. 7.10. DataGrid1

.
. .
, .
Error
Adodc,
Initialize ( 7.1).
Error , Initialize
.

7.

287

7.1.
Private Sub Adodc1_Error(ByVal ErrorNumber As Long, _
Description As String, ByVal Scode As Long, _
ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, fCancelDisplay As _
Boolean)
Dim msg As String '
msg = ": " + Str(ErrorNumber) + vbCr + Description
MsgBox msg, vbCritical, ""
fCancelDisplay = True '
'
End Sub
Private Sub Form_Initialize()
Form1.ScaleMode = vbPixels
'
DataGrid1.Columns(0).Width = 270
End Sub

""
. 7.11. , . ,
(
), <F2> . ,
<Del>.
() . , .

288

II.

. 7.11. ""




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

SELECT.
SQL-, , :
SELECT FROM WHERE() ORDER BY

7.

289

, .
. , SELECT, , (
, "").
, ORDER BY, ,
, .
,
SELECT Author, Title FROM Books WHERE Author = ". "

Books ,
Author ". ".
.
SELECT

Author,
Title
FROM
Books
WHERE (Author = ". ") AND (PYEAR = 2008)

. , 2008 .
, , . , % , "",
%% , () "", : . , ., . .
. . "" LIKE.
SELECT Author, Title FROM Books
WHERE (Author LIKE "%") AND (Title LIKE "%Basic%")

, Basic.

II.

290

,
.

.
.
. 7.12.

. 7.12. ""

Adodc
DataGrid, "". Initialize Error Adodc ( 7.2).
7.2.
Option Explicit
Public KeyWord As String '
Private Sub Adodc1_Error(ByVal ErrorNumber As Long, _
Description As String, ByVal Scode As Long, _
ByVal Source As String, ByVal HelpFile As String, _

7.

291

ByVal HelpContext As Long, fCancelDisplay As _


Boolean)
Dim msg As String '
msg = ": " + Str(ErrorNumber) + vbCr + Description
MsgBox msg, vbCritical, ""
fCancelDisplay = True '
'
End Sub
Private Sub Form_Initialize()
Form1.ScaleMode = vbPixels
'
DataGrid1.Columns(0).Width = 270
End Sub


(. 7.13).
.

. 7.13.

,
, -

II.

292

. , Project
Add Form, ( Add Form)
( Form).
,
: (. 7.5) (. 7.14).
7.5.

Name

Form2

BorderStyle

FixedDialog

( ),

StartPosition

Center

. 7.14.

(Form2),

Click ( 7.3),
Form2 Click
OK ( 7.4). , -

7.

293

KeyWord,
Form1 Public.
7.3. Click

'
Private Sub Command1_Click()
KeyWord = ""
Form2.Show (vbModal) '
If KeyWord <> "" Then
'
' SQL-
Adodc1.RecordSource = _
"SELECT * FROM Contacts WHERE Name LIKE " + _
Chr(39) + "%" + KeyWord + "%" + Chr(39) + _
"ORDER BY Name"
Adodc1.Refresh '
End If
End Sub

'
Private Sub Command2_Click()
Adodc1.RecordSource = _
"SELECT Name, Phone FROM Contacts ORDER BY Name"
Adodc1.Refresh '
End Sub

II.

294

7.4. Click OK

Private Sub Command1_Click()
Form1.KeyWord = Text1.Text '
'
' (Form1)
Form2.Hide

'

End Sub



:
.
,
.

, ( )
( ,

).
.
,
(. 7.15).
.
( ) ,
.
.

7.

295

. 7.15.

" ". (, , )
Microsoft Access " " (ArdBk.mdb).
" " -
Contacts (. 7.6).
7.6. a Contacts " "

Title

50

Phone

50

Manager

50

( )

Address

50

Email

50

296

II.

" " . 7.16. , (Command1) (Command2) , Adodc1. CommandButton.


Paint. StatusBar , .
,
Microsoft Windows Common Control 6.0 ( Project
Components).

. 7.16. " "

,
( ) TextBox, .
(KeyPress
GotFocus TextBox)

7.

297

, .
, :
1. ,

, (
Text1 Text).
2. Edit Copy.
3. Edit Paste.
4. You already have a control named Do you

want to create a control array? (


. ?)
(. 7.17).
.
5. 3 , -

. 7.17. ,


( ),
.
.
,
, ,

II.

298

, .

.
, ,
Index. ( ),
. 7.5 KeyPress TextBox " ".
Text <Enter> .
7.5.
'
Private Sub Text_KeyPress(Index As Integer, KeyAscii As
Integer)
If KeyAscii = 13 Then ' <Enter>
'
If Index < 4 Then Text(Index + 1).SetFocus
End If
End Sub

( TextBox)
, : DataSource DataField .
DataSource ,
DataField (. 7.18).

" " . 7.7 7.8,
7.6.

7.

299

. 7.18.

7.7. a Adodc1

ConnectionString

Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\Database\ADRBK.MDB;Persist
Security Info=False

RecordSource

SELECT * FROM CONTACTS ORDER BY TITLE

7.8. Text(0) Text(4)

Text(0).DataSource

Adodc1

Text(0).DataField

TITLE

II.

300

7.8 ()

Text(1).DataSource

Adodc1

Text(1).DataField

MANAGER

Text(2).DataSource

Adodc1

Text(2).DataField

PHONE

Text(3).DataSource

Adodc1

Text(3).DataField

ADDRESS

Text(4).DataSource

Adodc1

Text(4).DataField

EMAIL

7.6.
" "
Option Explicit
'
Private Sub Form_Load()
' ,
'
Text(0).MaxLength = 50
Text(1).MaxLength = 50
Text(2).MaxLength = 50
Text(3).MaxLength = 50
Text(4).MaxLength = 50
If Adodc1.Recordset.RecordCount = 0 Then
'
' ,

7.

301

' ,
' . ,
' . ,
' - ,
' ,
' ,
Adodc1.Recordset.AddNew
End If
End Sub
' "+" ( )
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
Text(0).SetFocus
End Sub

' "-" ( )
Private Sub Command3_Click()
Dim r
r = MsgBox(" ?", vbQuestion + vbOKCancel, _
" ")
If r = vbOK Then
If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.Delete
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
Else

II.

302

Adodc1.Recordset.MoveLast
End If
End If
If Adodc1.Recordset.RecordCount = 0 Then
Adodc1.Recordset.AddNew
End If
End If
End Sub
'
Private Sub Text_GotFocus(Index As Integer)
Text(Index).Text = RTrim(Text(Index).Text)
' ,
Text(Index).SelStart = 0
Text(Index).SelLength = Len(Text(Index).Text)
End Sub
'
Private Sub Text_KeyPress(Index As Integer, KeyAscii As
Integer)
If KeyAscii = 13 Then ' <Enter>
'
If Index < 4 Then Text(Index + 1).SetFocus
End If
End Sub
'
Private Sub Adodc1_MoveComplete(ByVal adReason As
ADODB.EventReasonEnum,
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)

7.

303

StatusBar1.SimpleText =
" " &
Str(Adodc1.Recordset.AbsolutePosition) & _
" " & Str(Adodc1.Recordset.RecordCount)
End Sub
'
Private Sub Form_Unload(Cancel As Integer)
If Text(0).DataChanged Or Text(1).DataChanged Or _
Text(2).DataChanged Or Text(3).DataChanged Or _
Text(4).DataChanged Then
Adodc1.Recordset.UpdateBatch (adAffectCurrent)
End If
End Sub

.
. 7.19
" ",
DataGrid1 ( . 7.9),
.
, DataGrid1
. Command3
.
(. 7.20).
(. 7.21),
.
. Click
7.7.
7.9. DataGrid1

DataSource

Adodc1

AllowAddNew

True

II.

304

7.9 ()

AllowDelete

True

AllowUpdate

True

. 7.19. " -2"

7.7. Click
'
Private Sub Command3_Click()
'
If DataGrid1.Visible Then
'

7.

305

DataGrid1.Visible = False
Form1.Height = Form1.Height - _
Form1.ScaleY(DataGrid1.Height + 8, _
vbPixels, vbTwips)
Command3.ToolTipText = " "
Else
'
DataGrid1.Visible = True
Form1.Height = Form1.Height + _
Form1.ScaleY(DataGrid1.Height + 8, _
vbPixels, vbTwips)
Command3.ToolTipText = " "
End If
End Sub

. 7.20.

, Load
,
( 7.8). .

II.

306

. 7.21.

7.8. Load
'
Private Sub Form_Load()
' ,
'
Text(0).MaxLength = 50
Text(1).MaxLength = 50
Text(2).MaxLength = 50
Text(3).MaxLength = 50
Text(4).MaxLength = 50
If Adodc1.Recordset.RecordCount = 0 Then

7.

307

'
' ,
' ,
' . ,
' . ,
' - ,
' ,
' ,
Adodc1.Recordset.AddNew
End If
Command1.ToolTipText = " "
Command2.ToolTipText = " "
' DataGrid
DataGrid1.Columns(0).Caption = ""
DataGrid1.Columns(1).Caption = ""
DataGrid1.Columns(2).Caption = ""
DataGrid1.Columns(3).Caption = ""
DataGrid1.Columns(4).Caption = "E-Mail"
' ( DataGrid)
DataGrid1.Visible = False
Form1.Height = Form1.Height - _
Form1.ScaleY(DataGrid1.Height + 8, vbPixels,
vbTwips)
Command3.ToolTipText = " "
End Sub

308

II.


""
" " , (
contacts.mdb AdrBk.mdb ) .
,
, Microsoft Access
Microsoft Access.


Create
Catalog. Catalog ADO, Microsoft ADO Ext. 2.5 for DLL and Security
(ADOX).

. 7.22. Catalog,
,
ADOX

7.

309

, ,
ADOX (. 7.22).
, Create,
. ,
aCatalog.Creat("Provider=Microsoft.Jet.OLEDB.3.51; _
Data Source=D:\Database\AdrBk.mdb")

D:\Database AdrBk.mdb Microsoft Access. ,


Microsoft Jet, Microsoft Access. , Create
, , ActiveConnection.


,
.
,
SQL- CREATE TABLE, :
CREATE TABLE (1 1, 2 2, k k)

: ,
SQL- CREATE; i i- , i i- . ,

CREATE TABLE Contacts (Title CHAR(50), Phone CHAR(50), Manager CHAR(50),
Address CHAR(50), Email CHAR(50))

, ,
Contacts. ,
,
.

II.

310

, , . CHAR () NUMBER (),


CURRENCY (), DATE () TIME ().
(
),
NOT NULL. , , Contacts Title .
, ,
:
CREATE TABLE Contacts (Title CHAR(50) NOT NULL, Phone
CHAR(50),
Manager CHAR(50), Address CHAR(50), Email
CHAR(50))


(),
INSERT INTO, ,
. , :
INSERT INTO Contacts (Title, Phone)
VALUES (' ', '555-86-35')

Contacts .
, , .
, .


. , SQL-
DROP TABLE.

7.

311

,
DROP TABLE Expenses

Expenses.


, ,
" ".
. 7.23, 7.9.
, ADODB (Connection
Command) ADOX (Catalog)
Microsoft ActiveX Data Objects 2.1 (ADODB) Microsoft ADO Ext. 2.5 for DLL and Security (ADOX).

. 7.23. " "

. 7.9.
Option Explicit
' ADODB ADOX
' :

II.

312
'

- Microsoft ActiveX Data Objects 2.1 Library (ADODB)

'

- Microsoft ADO Ext. 2.5 for DLL and Security (ADOX)

Private Sub Command1_Click()


Dim ConnStr As String '

Dim aCatalog As New ADOX.Catalog


Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
ConnStr = "Provider=Microsoft.Jet.OLEDB.3.51;Data _
Source=" + _
Text1.Text
' (MDB-)
On Error GoTo er1
aCatalog.Create (ConnStr)
MsgBox " " + Text1.Text + " .", _
vbInformation + vbOKOnly, " "
Set conn = aCatalog.ActiveConnection
If Check1.Value = Checked Then
'
'
Set cmd.ActiveConnection = conn
cmd.CommandText = Text2.Text
On Error GoTo er2
cmd.Execute '

7.

313

MsgBox "SQL-: " + vbCr + Text2.Text + _


".", _
vbInformation, " SQL-"
'
conn.Close
End If
Exit Sub
er1: '
MsgBox " ." + vbCr + Error, _
vbExclamation + vbOKOnly, ""
Exit Sub

er2: ' SQL-


MsgBox " SQL-." + vbCr + Error, _
vbExclamation + vbOKOnly, ""
conn.Close
Exit Sub
End Sub
Private Sub Check1_Click()
If Check1.Value = Checked Then
Text2.Enabled = True
Text2.SetFocus
Else
Text2.Enabled = False
End If
End Sub

II.

314

Private Sub Text1_GotFocus()


Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Text2_GotFocus()
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text) - 1
End Sub




.
,
( ) ,
.


. , -
.

: <F1>
.
: WinHelp, HTML Help MS
Help 2.
WinHelp, Windows 3.1,
,
.
WinHelp HLP-.

HTML Help (. 8.1). HTML (CHM-), () HTML- (
), . HTML

316

II.

Help hh.exe.

. 8.1. HTML Help 1.x

.NET
MS Help 2.
.NET- Microsoft. MS Help 2
, , , ,
, .

HTML Help
HTML Help
CHM- HTML-,

8.

317

() HTML-,
, (. 8.2).

(HTML-,
)

CHM-

CHM-

. 8.2. CHM-

CHM- .
,
HTML-. .


"" CHM- , HTML.
HTML ,
, Microsoft Word,
HTML, HTML-, ,
HTML Help Workshop.
HTML-.
,
,
HTML-.

318

II.


Microsoft Word
, 1, 2.
,
, , ,
, .
, , ,

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

8.

319

,
, ( ), .
.
, .
, , , , , ,
OK.
, ,

.


HTML Help Workshop
HTML- , HTML Help Workshop, File
NewHTML File HTML Title ,
(. 8.3).
OK HTML, HTML-.
<BODY> .
HTML
HTML- ,

, HTML- .

320

II.

< >.
. , <H1></H1>
HTML-, ,
,

.

. 8.3.
HTML-

. 8.1 , HTML- CHM- .

8.

321

8.1. HTML-

<TITLE></
TITLE>

HTML-.
HTML
, .
,

<BODY BACKGROUND
= ""
BGCOLOR=""
TEXT="">

BACKGROUND , BGCOLOR ,
TEXT HTML

<BASEFONT FACE=
""
SIZE=n>

,
: FACE ,
SIZE . SIZE 3.
( <H>) , SIZE

<H1></H1>

, <H1> </H1> .
<H2></H2>
,
<H3></H3>

<BR>

. ,
,

<P></P>

, ,

<B></B>

,
,

II.

322

8.1 ()

<I></I>

, ,

<A NAME=

. NAME

""> </A>
<A HREF=".htm
#">
</A>


,
,
HREF

<IMG SRC=
"">

,
SRC

HTML- .
, . ,
,
() . ,
, HTML- "" "" (, ). , ,
, <BR> (
<P></P>),
, HTML-
<BR> .

HTML- , .
View In Browser , Internet
Explorer.
8.1 HTML-
"".

8.

323

8.1. HTML-

<HTML>
<TITLE></TITLE>
<BODY>
<BASEFONT FACE="Arial" SIZE=2>
<H1></H1>
<P> ,
.
.</P>
<P> ,
, , .
, .
, , ,
( , , ,
) .
, ,
, . ,
, , , . , , . ()
, .
,
, .</P>
<I>.</I><BR>
<A HREF="saper_01.htm#"></A><BR>
<A HREF="saper_03.htm#_"> </A><BR>
</BODY>
</HTML>

324

II.

CHM-
,
CHM-.
HTML Help Workshop, File
NewProject New Project
(. 8.4). HTML Help
Workshop , . 8.5.

. 8.4.


, , ,
. ,
Add/Remove topic files, (. 8.6),
Topic Files (. 8.7) Add
HTML-.

8.

325

. 8.5. HTML Help Workshop


. 8.6. Add/Remove topic files

, .
Topic Files
, ,
OK.
( Project) FILES, HTML-,
(. 8.8).

326

II.

. 8.7. Topic Files

. 8.8. FILES ,
CHM-

8.

327

, , .
Title Default file
General Options (. 8.9),
Change project
options (. 8.10).

. 8.9. Options

. 8.10. Change project options

, ,
,
. ,

328

II.

(, )
h-, :
#define ; ,

: HTML- ( ), ; ( );
.
8.2 h-
"".

. 8.11. HtmlHelp API Information

. 8.12. HtmlHelp API information

8.

329

8.2. saper.h
#define saper_01 1; ( )
#define saper_02 2;
#define saper_03 3;

h- ,
HtmlHelp API Information (. 8.11) , Header Files
h-.
MAP h- (. 8.12), , MAP .


, .

. 8.13. Contents

330

II.

, Contents, ,
.
Contents (. 8.13),
.

. 8.14.

Contents ,
, Insert a
heading, Entry title Table
of Contents Entry (. 8.14)
Add. Path or URL (. 8.15).
HTML titles
( HTML-) , ( -

8.

331

FILES Project). , ,
HTML- <TITLE>. , OK. Contents
.

. 8.15. ,

,
, Edit selection (. 8.16)
, Image index Advanced Table of
Contents Entry, ( ).

332

II.

. 8.16. Edit selection

, , ,
, Move
selection right. ,
.
, , , Insert a page (. 8.17).

. 8.17. Insert a page



. ,
(. 8.18). Move selection
up Move selection down . Move selection right
, . Move selection
left .

. 8.18. Move selection

8.

333

. 8.19 Contents,

"".

. 8.19. Contents

,
, , . File Compile,
Create a compiled file -

334

II.

Automatically display compiled help file when done ( )


Compile (. 8.20).
, , .

. 8.20. Create a compiled file


. <F1>, .
, Visual
Basic, <F1>, ( Project Properties)
Help File Name (. 8.21).

8.

335

. 8.21. CHM- Help File Name

<F1>
, , ,
. ,
, ,
. <F1>,
, , ,
HelpContextID
. ,
h-, MAP- . ,
HelpContextID , ,
HelpContextID .

II.

336


,
, hh.exe. hh.exe : (
mapid), CHM- . hh.exe
Shell.
, (
, ), , , . , ,
hh.exe "", saper.chm, :
Shell "hh.exe -mapid 2 saper.chm", vbNormalFocus

,
() MsgBox.
, MsgBox ,
,
.
. 8.22 ,
MsgBox " .", _
vbExclamation + vbMsgBoxHelpButton, _
"", _
"convert.chm", 2


"" (
. 8.23).

8.

337

. 8.22.

. 8.23. ""

""
(. 8.24). <F1>, . ( )
<F1> ( ,
). ,
, .
,
, . 8.3,
8.3, convert.h 8.4.

II.

338

. 8.24. ""

8.2. ,

Help File Name

onvert.chm


Project Properties

Form1.HelpContextID

Text1.HelpContextID

Text2.HelpContextID

8.3. ( )
'
Private Sub Command1_Click()
Dim usd As Single '

8.
Dim k As Single

339

'

Dim rub As Single '


usd = Val(Text1.Text)
k = Val(Text2.Text)
If usd = 0 Or k = 0 Then
MsgBox " .", _
vbExclamation + vbMsgBoxHelpButton, _
"", _
"convert.chm", 2
Else
rub = usd * k
Label3.Caption = Text1.Text & "$ - " & Str(rub) & _
"."
End If

End Sub

'
Private Sub Command2_Click()
Shell "hh.exe -mapid 0 convert.chm", vbNormalFocus
End Sub

'
' , <F1>,
' KeyPress
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Text2.SetFocus
End Sub

II.

340

'
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1.SetFocus
End Sub

8.4. convert.h
#define konvertor_01 1;

#define konvertor_02 2;

#define konvertor_03 3;

#define konvertor_04 4;

#define konvertor_05 5;


Visual Basic
,
, USB-.
.
,
. , .
-,
, .
,
. ,
.
, . , , InstallShield, Install
Aware, Inno Setup. ,
, - ,
.

II.

342

""
, Windows
IExpress, " ".

IExpress
IExpress (iexpress.exe)
Windows. .
. "".
IExpress,
,
.
, (readme-).
"", , .
. ,

saper.exe

Program Files\Saper

saper.chm

Program Files\Saper

readme.txt

Program Files\Saper

IExpress iexpress.exe System32,


(. 9.1).

9.

343

. 9.1. Iexpress

IExpress . 9.2.

. 9.2. IExpress Wizard

IExpress
(Wizard) ,
, . ()
.

344

II.

( ).
, .


IExpress 9 .
.

1.
(. 9.3) ,
, .

. 9.3.

9.

345

,
,
Extract files only ( ).

2.
(. 9.4) ,
.
Setup.

. 9.4.

3.
(. 9.5) ,
, . -

346

II.

. Confirmation prompt Prompt user with (, ) : .


? No prompt ( ), ( Setup ), ,
.

. 9.5.

4.
(. 9.6) . Display a license RTF-, . ,
-

9.

347

.
,
,
, . Do not display a license,
, , .

. 9.6.

5.
(. 9.7) , .
Add
. ,
( ). ,
Add, ,
, <Ctrl> , ,
.

348

II.

. 9.7. ,

6.
, .
(Default),
(Maximized), (Minimized) (Hidden). ,
Default.

7.
(. 9.8) ,
, .

9.

349

. 9.8.

8.

(. 9.9)
, . setup.exe.

9.

(. 9.10)
, , .

350

II.

. 9.9.

. 9.10.
SED-

9.

351


. setup-.
setup.exe ,
(. 9.11).

. 9.11.


, , setup.exe, IExpress (,
setup.exe, ).
. 9.129.15 ,
"".

352

II.

. 9.12.

. 9.13. ,

. 9.14.

. 9.15.

9.

353


, , Visual Basic,
(runtime library).
Visual
Basic. . ,
, . Visual
Basic 6.0 ( vbrun60sp6.exe),
Microsoft (http://www.microsoft.com/downloads).

10




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


:
,

10.

355

;
;
-

, : "", "", "" "";


;
-

. ,
.
. 10.1
.

. 10.1. "":

356

II.


,
.
:
;
;
.

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

, , " ",

<Enter>. .
Line Input .
, , , , . .
( ) .

10.

357

:
10

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

321
herm.jpg


,
( ). (
), herm.jpg.

-.
-
-.

358

II.


.
7
-!
6
-,
.
5
-.
4
, , -?
:
321
isaak.jpg



1834 , :
210
I.
1812 .

321
herm.jpg



()

310



, ,
I, :
331
bot.jpg


320

10.

359

, -
, -

I
210

Microsoft Word.
Microsoft Word
, .
,
(*.txt).


"" . 10.2.

. 10.2. ""

360

II.

Label1 ,
. Image1 , .
OptionBtn Option

.
. 10.1 .
10.1.

BorderStyle

1 FixedSingle

ScaleMode

1 Pixel

StartUpPosition 2 CenterScreen


Image1,

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

10.

361

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


. ,
,
.

( ).
,


(. 10.3).

. 10.3.


Command. , , -

II.

362

, "" :
fTest = Command()
If fTest = "" Then
'
Label1.Caption = " _
." & _
vbCr & ": exam.exe
d:\exam\.txt"
Command1.Tag = 2
Exit Sub
End If

. 10.4.
Command Line Arguments

,
, Visual Basic Command

10.

363

Line Arguments Make Projects Properties (. 10.4),


Project Properties.


"" 10.1.
10.1.
Option Explicit
' 4
' 4
Dim fTest As String

'

Dim fn As Integer

'

Dim title As String

'

Dim vopros As Integer

'

Dim otv As Integer

'

Dim right As Integer

'

Dim nright As Integer

'

Dim level(1 To 4) As Integer ' - ,


'
'
Dim mes(1 To 4) As String

' ( )

'
Private Sub Form_Initialize()
'
fTest = Command()

II.

364
If fTest = "" Then

'
Label1.Caption = " _
." & _
vbCr & ": exam.exe
d:\exam\.txt"
Command1.Tag = 2
Exit Sub
End If
'
On Error GoTo e1
Call InitForm
fn = FreeFile '
'
Open fTest For Input As #fn'
Call info

'

Call getLevel

'

Form1.ScaleMode = vbPixels
Command1.Tag = 0
Label1.WordWrap = True
Label1.AutoSize = True
Exit Sub
e1:
'
Label1.WordWrap = True
Label1.AutoSize = True

10.

365

Label1.Caption = " " & fTest


Command1.Tag = 2
End Sub
'
Sub info()
Dim buf As String
Line Input #fn, buf

'

Form1.Caption = buf

'

title = buf
Line Input #fn, buf

'

Label1.Caption = buf

'

End Sub
'
Sub getLevel()
Dim buf As String
Dim i As Integer
i = 1
For i = 1 To 4
Line Input #fn, buf '
level(i) = buf
Line Input #fn, buf '
mes(i) = buf
Next i
End Sub

II.

366

' OK/
Private Sub Command1_Click()
Select Case Command1.Tag
'
Case 0:
Command1.Enabled = False
Call InitForm
Call voprosToScr
Command1.Tag = 1
Command1.Caption = ""
'
Case 1:
If otv = right Then nright = nright + 1
Command1.Enabled = False
Call InitForm
If Not EOF(fn) Then
Call voprosToScr
Else
Close #fn
Command1.Caption = "Ok"
Form1.Caption = title
Command1.Tag = 2
Command1.Enabled = True
Call itog
End If

'

10.

367

'
Case 2:
Unload Me
End Select
End Sub
'
Sub InitForm()
Dim i As Integer
' ""
For i = 0 To 3
OptionBtn(i).Visible = False
OptionBtn(i).Caption = ""
OptionBtn(i).Value = False
Next i
Image1.Visible = False
End Sub
'
Sub voprosToScr()
Dim n As Integer

' -

' Dim right As Integer


Dim p As Integer

'

'

Dim fPicture As String

'

Dim buf As String

'

Dim i As Integer

II.

368
vopros = vopros + 1

Form1.Caption = " " + Str(vopros)


Line Input #fn, buf

'

Label1.Caption = buf '


' : N R P,
' : N ;
'

R ;

'

P (1 , 0 )

Line Input #fn, buf '


n = Val(Substr(buf, 1))
right = Val(Substr(buf, 2))

' right
'

p = Val(Substr(buf, 3))
If p = 1 Then
'
Line Input #fn, fPicture
Image1.Tag = 1
On Error Resume Next
Image1.Picture = LoadPicture(fPicture)
If Err Then
'
' ( )
Image1.Tag = 0
End If
Else
Image1.Tag = 0
End If

10.

369

'
For i = 1 To n
Line Input #fn, buf
Select Case i
Case 1: OptionBtn(0).Caption = buf
Case 2: OptionBtn(1).Caption = buf
Case 3: OptionBtn(2).Caption = buf
Case 4: OptionBtn(3).Caption = buf
End Select
Next i

'
' ,
If Image1.Tag = 1 Then

'

Call showPicture
End If

'
'
If OptionBtn(0).Caption <> "" Then
If Image1.Tag = 1 Then
OptionBtn(0).Top = Image1.Top + Image1.Height + 5
Else
OptionBtn(0).Top = Label1.Top + Label1.Height + 5
End If
OptionBtn(0).Visible = True
OptionBtn(0).Value = False
End If

II.

370

'
For i = 1 To 3
If OptionBtn(i).Caption <> "" Then
OptionBtn(i).Top = OptionBtn(i - 1).Top + _
OptionBtn(i - 1).Height
OptionBtn(i).Visible = True
OptionBtn(i).Value = False
End If
Next i
Command1.Enabled = False
End Sub
'
Private Sub OptionBtn_Click(Index As Integer)
otv = Index + 1 '
Command1.Enabled = True
End Sub
'
Sub itog()
Dim i As Integer
Dim buf As String
buf = " " + vbCr + vbCr + _
" : " + Str(vopros) + vbCr + _
" : " + Str(nright) + vbCr
i = 0
' nright -
' " ",
' " " . .

10.

371

While (nright <= level(i)) And (i < 3)


i = i + 1
Wend
buf = buf + mes(i)
Label1.Caption = buf
End Sub
'
Sub showPicture()
Dim w As Integer, h As Integer

'
'

Dim k As Single '


Dim i As Integer
Image1.Stretch = False
Image1.Top = Label1.Top + Label1.Height + 7
'
w = Form1.ScaleWidth - Label1.Left * 2
h = Command1.Top - (Label1.Top + Label1.Height) - 10 * 2
'
'
' ,
For i = 0 To 3
If OptionBtn(i).Caption <> "" _
Then h = h - OptionBtn(i).Height
Next I
' WH,

II.

372

'
If (Image1.Height > h) Then
k = Image1.Width / Image1.Height
Image1.Stretch = True
Image1.Width = h * k
Image1.Height = h
End If
'
If (Image1.Width > w) Then
Image1.Stretch = True
Image1.Width = w
Image1.Height = w / k
End If

Image1.Visible = True
End Sub

'
' ( )
Function Substr(st As String, n As Integer) As String
Dim s As Integer '
Dim f As Integer '
Dim i As Integer
s = 1
For i = 1 To n - 1
s = InStr(s, st, " ")
s = s + 1
Next i

10.

373

f = InStr(s + 1, st, " ")


If f <> 0 Then
f = f - 1
Else
f = Len(st)
End If
Substr = Mid(st, s, f - s + 1)
End Function


Initialize ,
. ,
, . ,
Label1. , ,
,
.
.
,
level mes.
,
Ok (Command1).
Command1 ( ),
( )
( ,
). , Command1,

374

II.

Tag . Tag .
Click ,
Tag 1.
Tag Command1 1.
Click
(otv) (right),
(
) .
(
, ),
, Ok (
Tag 2).
(, , ,
, )
voprosToScr.
()
Label1.
N R P, : N ; R
; P (1 , 0 ). right.
,
,
.
. OptionBtn(0),
, Image1 ( ) Label1, . OptionBtn
OptionBtn (OptionBtn(1) OptionBtn(0), OptionBtn(2) OptionBtn(1) . .).

10.

375

(Command1) . ,
, .
Click OptionBtn. otv ( OptionBtn, ).
, Click Option
( , Option
).
,
itog ( Click
Command1, , , , EOF True) .


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

376

II.

, . , txt
. txt, , exm ( . examiner ). EXM "". ,
,
.
.
,
, . , "", .
exm
(. 10.5).

. 10.5. exm
""

10.

377

, "",
. , exm.
, .

""
, Windows,
"". .
, , , . 10.6.

. 10.6. ""

II.

378


,
.
.
, , ,
. ,
. , ,
, ( , , , ) .
, , , . ,
,
. , , . () , .
, , .
0 1 2

...

M M+1

0
1
2

N
N+1

. 10.7.

10.

379

N+2 M+2,
N M .
1 N 1 M
(. 10.7),
.
, , 0 9. ,
9. ,
. , -
, , ( 1 8).
, , 3.
. 10.8 , .

. 10.8.

380

II.

( )
. , 100. , ,
, , 109. , ,
100. , 200.
.

"" : ( ) .
() "" . 10.9.

. 10.9. ""

,
.
. Load,
( )
Width Height.

10.

381


. ,
, . ?.
Menu Editor, Tools. Menu Editor
""
. 10.10, . 10.2.
10.2. ""
(Caption)

(Name)

new_game

question

help

about

. 10.10. ""

II.

382


Load
( 10.2)
(. 10.11) , ,
. ( ) ( ) .

. 10.11. , ,

10.2. Load
Private Sub Form_Load()
Dim row As Integer, col As Integer
' (
' ) -3.
' n_open
'
For row = 0 To MR + 1
For col = 0 To MC + 1
Pole(row, col) = -3
Next col
Next row
'
Set bm1 = LoadPicture("bm1.bmp") '

10.

383

Set bm2 = LoadPicture("bm2.bmp") '


Set bm3 = LoadPicture("bm3.bmp") ' ,
'
Set bm4 = LoadPicture("bm4.bmp") ' ,
'
W = ScaleX(bm1.Width, vbHimetric, vbPixels)
H = ScaleX(bm1.Height, vbHimetric, vbPixels)
'
frmSaper.Width = (frmSaper.Width - frmSaper.ScaleWidth) + _
(MC * W) * Screen.TwipsPerPixelX
frmSaper.Height = (frmSaper.Height - _
frmSaper.ScaleHeight) + _
(MR * H) * Screen.TwipsPerPixelY
'
frmSaper.ScaleMode = vbPixels
Call NewGame '
End Sub



, .
NewGame ( 10.3) .
10.3. NewGame
'
Sub NewGame()

II.

384
Dim row As Integer

'

Dim col As Integer


Dim n As Integer

'

Dim k As Integer

'

'
For row = 1 To MR
For col = 1 To MC
Pole(row, col) = 0
Next col
Next row
'
Randomize

'

n = 0

'

Do
row = Int((MR * Rnd) + 1)
col = Int((MC * Rnd) + 1)
If (Pole(row, col) <> 9) Then
Pole(row, col) = 9
n = n + 1
End If
Loop Until (n = NM)
'
'
For row = 1 To MR
For col = 1 To MC
If (Pole(row, col) <> 9) Then

10.

385

k = 0
If Pole(row - 1, col - 1) = 9 Then k = k + 1
If Pole(row - 1, col) = 9 Then k = k + 1
If Pole(row - 1, col + 1) = 9 Then k = k + 1
If Pole(row, col - 1) = 9 Then k = k + 1
If Pole(row, col + 1) = 9 Then k = k + 1
If Pole(row + 1, col - 1) = 9 Then k = k + 1
If Pole(row + 1, col) = 9 Then k = k + 1
If Pole(row + 1, col + 1) = 9 Then k = k + 1
Pole(row, col) = k
End If
Next col
Next row
status = 0

'

nMin = 0

'

nFlag = 0

'

End Sub

NewGame ,
ShowPole ( 10.4) .
10.4. ShowPole
'
Sub ShowPole(status As Integer)
Dim row As Integer, col As Integer
For row = 1 To MR
For col = 1 To MC
Call Kletka(row, col, status)

II.

386
Next col
Next row
End Sub

ShowPole , . Kletka ( 10.5).


Kletka
, . ( status = 0) ,
, .
Kletka status.
PaintPicture,
, , .
10.5. Kletka
Sub Kletka(row As Integer, col As Integer, status As Integer)
Dim X As Integer, Y As Integer

'
'

'
X = (col - 1) * W
Y = (row - 1) * H
If status = 0 Then '
'
Line (X, Y)-Step(W, H), frmSaper.BackColor, BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B

10.

387

Exit Sub
End If
' *** ***
If Pole(row, col) < 100 Then
Line (X, Y)-Step(W, H), frmSaper.BackColor, BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
' (status = 2)
' , ( ,
' )
If (status = 2) And (Pole(row, col) = 9) Then _
frmSaper.PaintPicture bm2, X, Y '
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '
'
Exit Sub
End If
' *** ***
Line (X, Y)-Step(W, H), RGB(255, 255, 255), BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
' ,
If (Pole(row, col) = 100) Then Exit Sub
' ,
If (Pole(row, col) >= 101) And (Pole(row, col) <= 108)
Then
frmSaper.CurrentX = X + 3
frmSaper.CurrentY = Y + 3

II.

388

'
' Font ForeColor
Print Str(Int(Pole(row, col) - 100))
Exit Sub
End If
'
If (Pole(row, col) >= 200) Then
frmSaper.PaintPicture bm1, X, Y

'

Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '


'
End If
'
If (Pole(row, col) = 109) Then
frmSaper.PaintPicture bm4, X, Y '
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '
'
End If
'
If (Pole(row, col) = 209) And (status = 2) Then
frmSaper.PaintPicture bm3, X, Y ' ,
'
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
End If
End Sub

10.

389


MouseDown ( 10.6). , , , . ,
, . Pol ,
, Kletka,
.
, , n_open,
( ). , ,
ShowPole , , .
10.6. MouseDown

'
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Dim row As Integer, col As Integer
If status = 2 Then Exit Sub

'

If status = 0 Then status = 1

'

'
row = Int(Y / H) + 1
col = Int(X / W) + 1
'
If Button = vbLeftButton Then

II.

390

If Pole(row, col) = 9 Then


' ,
Pole(row, col) = Pole(row, col) + 100
status = 2

'

Call ShowPole(status)

'

Else
'
If Pole(row, col) < 9 Then Call n_open(row, col)
End If
End If
'
If Button = vbRightButton Then
' ,
If Pole(row, col) >= 200 Then
nFlag = nFlag - 1
'
Pole(row, col) = Pole(row, col) - 200
'
Call Kletka(row, col, status)
' ,
Else
' , ,
' ,
If Pole(row, col) >= 100 Then Exit Sub
nFlag = nFlag + 1
Pole(row, col) = Pole(row, col) + 200

'
'

Call Kletka(row, col, status)

'

10.

391

If Pole(row, col) = 209 Then


nMin = nMin + 1
' ,
If (nMin = NM) And (nFlag = NM) Then
status = 2

'

Call ShowPole(status)

'

End If
End If
End If
End If
End Sub


?
<F1>
(. 10.12).
,
<F1>, , Help File Name
Project Properties, Project Project Properties.

? ,
Click . ,
.

II.

392

. 10.12. ""

Click
.
' C
Private Sub help_Click()
Shell "hh saper.chm", vbNormalFocus
End Sub


?
(. 10.13).

, (), .

10.

393

Project Add Form.



.

. 10.13. . ,

"-"

frmAbout . 10.14, . 10.3.

. 10.14.

II.

394

10.3.

Name

frmAbout

BorderStyle

4 FixedToolWindow

StartUpPosition

1 CenterOwner

Click, ?
( 10.7).
Show vbModal, . , ,
. ,
, ,
, .
10.7.
' ?
Private Sub about_Click()
frmAbout.Show vbModal, Me
End Sub

,
. ,
StartUpPosition CenterOwner,
,
. .
"-" (. . 10.13). ,
. ,

10.

395

Click Label1. ,
, MousePointer
MouseIcon. 3232.
(
cur) Image Editor
(. 10.15).

, , Resource Type,
File
New, Cursor, Icon.

. 10.15.
Image Editor

Label1 . 10.4,
Click 10.8.

II.

396

10.4. Label1

Caption

http:\\www.bhv.ru

MousePointer

99 Custom

MouseIcon

hpoint.cur

10.8. URL
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Label1_Click()


Dim r As Long
r = ShellExecute(Me.hwnd, "Open", "http:\\www.bhv.ru", _
"", "", 0)
End Sub

API- ShellExecute,
, .
URL, , , .

OK. 10.9.

10.

397

10.9. OK
Private Sub Command1_Click()
Hide ' ()
End Sub


"" 10.10 ( ) 10.11 ( ).
10.10.
Const MR = 10

'

Const MC = 10

'

Const NM = 10

'

'
Dim Pole(0 To MR + 1, 0 To MC + 1) As Integer
' :
' 08 ,
' 9 ,
' 100109 ,
' 200209
Dim nMin As Integer

'

Dim nFlag As Integer

'

Dim status As Integer

' : 0 ,
' 1 , 2

'
Dim bm1 As StdPicture '

II.

398

Dim bm2 As StdPicture '


Dim bm3 As StdPicture ' ,
Dim bm4 As StdPicture ' ,

Dim W, H As Integer '

'
Private Sub Form_Load()
Dim row As Integer, col As Integer

' (
' ) -3.
' n_open
'
For row = 0 To MR + 1
For col = 0 To MC + 1
Pole(row, col) = -3
Next col
Next row

'
Set bm1 = LoadPicture("bm1.bmp") '
Set bm2 = LoadPicture("bm2.bmp") '
Set bm3 = LoadPicture("bm3.bmp") ' ,
'
Set bm4 = LoadPicture("bm4.bmp") ' ,
'
W = ScaleX(bm1.Width, vbHimetric, vbPixels)
H = ScaleX(bm1.Height, vbHimetric, vbPixels)

10.

399

'
frmSaper.Width = (frmSaper.Width - frmSaper.ScaleWidth) + _
(MC * W) * Screen.TwipsPerPixelX
frmSaper.Height = (frmSaper.Height - frmSaper.ScaleHeight) + _
(MR * H) * Screen.TwipsPerPixelY
'
frmSaper.ScaleMode = vbPixels
Call NewGame

'

End Sub
'
Sub NewGame()
Dim row As Integer

'

Dim col As Integer


Dim n As Integer

'

Dim k As Integer

'

'
For row = 1 To MR
For col = 1 To MC
Pole(row, col) = 0
Next col
Next row
'
Randomize

'

n = 0

'

Do
row = Int((MR * Rnd) + 1)

II.

400

col = Int((MC * Rnd) + 1)


If (Pole(row, col) <> 9) Then
Pole(row, col) = 9
n = n + 1
End If
Loop Until (n = NM)
'
'
For row = 1 To MR
For col = 1 To MC
If (Pole(row, col) <> 9) Then
k = 0
If Pole(row - 1, col - 1) = 9 Then k = k + 1
If Pole(row - 1, col) = 9 Then k = k + 1
If Pole(row - 1, col + 1) = 9 Then k = k + 1
If Pole(row, col - 1) = 9 Then k = k + 1
If Pole(row, col + 1) = 9 Then k = k + 1
If Pole(row + 1, col - 1) = 9 Then k = k + 1
If Pole(row + 1, col) = 9 Then k = k + 1
If Pole(row + 1, col + 1) = 9 Then k = k + 1
Pole(row, col) = k
End If
Next col
Next row
status = 0

'

nMin = 0

'

nFlag = 0

'

End Sub

10.

401

'
Sub ShowPole(status As Integer)
Dim row As Integer, col As Integer
For row = 1 To MR
For col = 1 To MC
Call Kletka(row, col, status)
Next col
Next row
End Sub
'
Sub Kletka(row As Integer, col As Integer, status As Integer)
Dim X As Integer, Y As Integer

'
'

'
X = (col - 1) * W
Y = (row - 1) * H
If status = 0 Then '
'
Line (X, Y)-Step(W, H), frmSaper.BackColor, BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
Exit Sub
End If
' *** ***
If Pole(row, col) < 100 Then
Line (X, Y)-Step(W, H), frmSaper.BackColor, BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
' (status = 2)
' , ( )

II.

402

If (status = 2) And (Pole(row, col) = 9) Then _


frmSaper.PaintPicture bm2, X, Y '
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '
'
Exit Sub
End If
' *** ***
Line (X, Y)-Step(W, H), RGB(255, 255, 255), BF
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B
' ,
If (Pole(row, col) = 100) Then Exit Sub
' ,
If (Pole(row, col) >= 101) And (Pole(row, col) <= 108)
Then
frmSaper.CurrentX = X + 3
frmSaper.CurrentY = Y + 3
'
' Font ForeColor
Print Str(Int(Pole(row, col) - 100))
Exit Sub
End If
'
If (Pole(row, col) = 209) And (status = 2) Then
frmSaper.PaintPicture bm3, X, Y

' ,
'

Line (X, Y)-Step(W, H), RGB(0, 0, 0), B


End If

10.

403

'
If (Pole(row, col) >= 200) Then
frmSaper.PaintPicture bm1, X, Y

'

Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '


'
End If
'
If (Pole(row, col) = 109) Then
frmSaper.PaintPicture bm4, X, Y '
Line (X, Y)-Step(W, H), RGB(0, 0, 0), B '
'
End If
End Sub
'
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Dim row As Integer, col As Integer
If status = 2 Then Exit Sub

'

If status = 0 Then status = 1

'

'
row = Int(Y / H) + 1
col = Int(X / W) + 1
'
If Button = vbLeftButton Then
If Pole(row, col) = 9 Then

II.

404

' ,
Pole(row, col) = Pole(row, col) + 100
status = 2

'

Call ShowPole(status)

'

Else
'
If Pole(row, col) < 9 Then Call n_open(row, col)
End If
End If
'
If Button = vbRightButton Then
' ,
If Pole(row, col) >= 200 Then
nFlag = nFlag - 1
'
Pole(row, col) = Pole(row, col) - 200
Call Kletka(row, col, status)
Else ' ,
'
' , ,
' ,
If Pole(row, col) >= 100 Then Exit Sub
nFlag = nFlag + 1
Pole(row, col) = Pole(row, col) + 200

'
'

Call Kletka(row, col, status)


If Pole(row, col) = 209 Then
nMin = nMin + 1

'

10.

405

'
If (nMin = NM) And (nFlag = NM) Then
status = 2

'

Call ShowPole(status)

'

End If
End If
End If
End If
End Sub
'
' ,
Sub n_open(row As Integer, col As Integer)
If Pole(row, col) = 0 Then
Pole(row, col) = 100
Call Kletka(row, col, 1)
'
Call n_open(row, col - 1)
Call n_open(row - 1, col)
Call n_open(row, col + 1)
Call n_open(row + 1, col)
'
Call n_open(row - 1, col - 1)
Call n_open(row - 1, col + 1)
Call n_open(row + 1, col - 1)
Call n_open(row + 1, col + 1)
Else
If (Pole(row, col) < 100) And (Pole(row, col) <> -3)
Then
Pole(row, col) = Pole(row, col) + 100

II.

406

Call Kletka(row, col, 1)


End If
End If
End Sub
' Paint
Private Sub Form_Paint()
'
Call ShowPole(status)
End Sub
' ?
Private Sub about_Click()
frmAbout.Show vbModal, Me
End Sub
' C
Private Sub help_Click()
Shell "hh saper.chm", vbNormalFocus
End Sub
'
Private Sub new_game_Click()
Call NewGame

'

Call ShowPole(status)

'

End Sub

10.11.
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
String, _

10.

407

ByVal lpFile As String, ByVal lpParameters As _


String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) _
As Long
' Web- ( Label1)
Private Sub Label1_Click()
Dim r As Long
r = ShellExecute(Me.hwnd, "Open", "http:\\www.bhv.ru", _
"", "", 0)
End Sub
' OK
Private Sub Command1_Click()
Hide ' ()
End Sub

11

( Form) .
. 11.1.
11.1.

Name

Caption

Top

Left

Width

Height

ScaleWidth

,
. ,

III.

412

11.1 ()

ScaleHeight

() ,
.
,

ScaleMode

.
Width
Height,

BorderStyle

() ( ).
(Sizable),
(FixedSingle) (None).
FixedSingle,
,
( )
( ).
None,
.
. FixedDialog,
( ,
, )

Icon

BackColor

. ,
.

.

11.

413

11.1 ()

ForeColor

FillColor

FillStyle

() :

Solid (0) ;

Transparent (1) (

);

HorizontalLine (2) -

VerticalLine (3) .


FillColor
DrawMode

. , Blackness
(1), (
,
Print)

DrawWidth

DrawStyle

, :

Solid (0) ;

Dash (1) ;

Dot (2) ;

Dash-Dot (3) "-";

Dash-Dot-Dot (4) "--

";

Transparent (5) ""

III.

414

11.1 ()

Font

. , ,
(,
Print)

MaxButton

(True) (False)

MinButton

(True) (False)

CheckBox
CheckBox (. 11.1)
. . 11.2.

. 11.1. CheckBox

11.2. CheckBox

Name

11.

415

11.2 ()

Caption

Value

: Checked
( );
Unchecked ( )

Left

Top

Height

Width

( )

Font

Visible

(
False) ( True)

ComboBox
ComboBox (. 11.2)

. . 11.3.

. 11.2. ComboBox

III.

416

11.3. ComboBox

Name

Font

BackColor

.
,

ForeColor

List

ListCount

ListIndex

, .
,
1.

Style

() .
DropDownCombo (0),

(
, ).
SimpleCombo (1),
,
.
DropDownList (2),

Text

(,

)

11.

417

11.3 ()

Sorted


( True)

Locked

.
( )

Left

Top

Height

Width

Visible

(False) (True)

CommandButton
CommandButton (. 11.3) . . 11.4.

. 11.3. CommandButton

III.

418

11.4. CommandButton

Name

Caption

Left

Top

Height

Width

Enabled

.
True, .
False,
,

Visible

( False)
( True)

Style

: (Standard) "" (Graphical).


,

Picture

""
. , Style
Graphical

DisabledPicture

"" . ,
Style Graphical,
Enabled False

11.

419

11.4 ()

DownPicture

""
. , Style
Graphical

ToolTipText

CommonDialog
CommonDialog (. 11.4) , , , ,
.
. 11.5. , (. 11.6).
, Microsoft Common Dialog Control 6.0 (COMDLG32.OCX).

. 11.4. CommonDialog

11.5. CommonDialog

Name

III.

420

11.5 ()

DialogTitle

FileName

, . ,
Cancel,

Filter

. ,
() .
,

FilterIndex

. 1

Flags

HelpFile

help-,

11.6. CommonDialog

ShowOpen

ShowSave

ShowColor

ShowFont

ShowPrinter

ShowHelp

DirListBox
DirListBox (. 11.5) . . 11.7.

11.

421

. 11.5. DirListBox

11.7. DirListBox

Name

Font

BackColor

.
,

ForeColor

List

()
.

ListCount

ListIndex

,
. . , Dir1,
1.
(
),
2. 1

III.

422

11.7 ()

Path

Left

Top

Height

Width

Visible

( False) (
True)

DriveListBox
DriveListBox (. 11.6) , .
. 11.8.

. 11.6. DriveListBox

11.8. DriveListBox

Name

11.

423

11.8 ()

Font

BackColor

.
,

ForeColor

List

. (, :)

ListCount

ListIndex

, .
,
1.

Left

Top

Height

Width

Visible

( False) (
True)

FileListBox
FileListBox (. 11.7) . . 11.9.

III.

424

. 11.7. FileListBox

11.9. FileListBox

Name

Font

BackColor

.
,

ForeColor

List

( )
.
(.)

ListCount

ListIndex

, .

Path

Archive

,
""

Hidden

,
""

11.

425

11.9 ()

ReadOnly

,
" "

System

,
""

Normal

,
"",
" ",

Left

Top

Height

Width

Visible

( False) (
True)

Image
Image (. 11.8) .

. 11.8. Image

III.

426

PictureBox , ( ).
. 11.10.
11.10. Image

Name

Picture

( BitMap),
.
( LoadPicture)

BorderStyle

: FixedSingle (1)
; None (0)

Stretch

( )
. True ( ,
). False

Left

Top

Height

Width

Visible

( False) (
True)

11.

427

Label
Label (. 11.9)
. (. 11.11) .

. 11.9. Label

11.11. Label

Name

Caption

Left

Top

Height

Width

AutoSize

WordWrap

, ,
,

III.

428

11.11 ()

Alignment

.

LeftJustify (0), Center (2)
RightJustify (1)

Font

, .
Name Size

ForeColor

. ,

BackColor

.
,

BackStyle


. (Opaque) "" (Transparent). Opaque,

BackColor

Visible

( False)
( True)

Line
Line (. 11.10) "".
, . . 11.12.

11.

429

. 11.10. Line

11.12. Line

Name

BorderColor

BorderStyle

Solid (0) ;

Dash (1) ;

Dot (2) ;

Dash-Dot (3) "-";

Dash-Dot-Dot (4) "--";

Transparent (5)

DrawWidth

X1

Y1

X2

Y2

Visible

( False)
( True)

III.

430

ListBox
ListBox (. 11.11) , .
. 11.13.

. 11.11. ListBox

11.13. ListBox

Name

BackColor

.
,

ForeColor

List

ListCount

Sorted

( True)

ListIndex

(
)

11.

431

11.13 ()

MultiSelect


.
None (0), . , Simple (1), , , .
<>.
Extended (2),

<Shift> <Ctrl> ( <Shift> ,
)

Style

() .
CheckBox (1),
CheckBox.

. ,
Standard (0),

Left

Top

Height

Width

Font

Visible

( False) (
True)

III.

432

MMControl
MMControl (. 11.12 11.13) .
. 11.14.
, Microsoft Multimedia Control 6.0 (MCI32.OCX).

. 11.12. MMControl

. 11.13. MMControl

11.14. MMControl

Name

DeviceType

: CDAudio CD; WaveAudio WAV-; AVIVideo AVI- .

Command

TimeFormat

FileName

11.

433

11.14 ()

PlayEnabled

Play ( True) ( False).


PlayVisible

Play (
False) ( True).

Left

Top

Height

Width

Visible

( False)
( True)

OptionButton
OptionButton (. 11.14)
, . . 11.15.

. 11.14. OptionButton

III.

434

11.15. OptionButton

Name

Caption

Value

. , True, ,
False

Tag

Visual Basic .

Left

Top

Height

Width

( )

Font

Visible

(
False) ( True)

PictureBox
PictureBox (. 11.15)
. ()
. . 11.16.

11.

435

. 11.15. PictureBox

11.16. PictureBox

Name

Picture

( BitMap),
.

(
LoadPicture)

AutoSize

(True)
(False) ( ) ,

BorderStyle

. FixedSingle (1),
( ), None (0),

BackColor

. ,

Font

, Print

ForeColor

Print ,
()

III.

436

11.16 ()

FillColor

(),
( )

FillStyle

,
:

Solid (0) ;

Transparent (1) ""

HorizontalLine (2) -

VerticalLine (3) .


FillColor
DrawStyle

, :

Solid (0) ;

Dash (1) ;

Dot (2) ;

Dash-Dot (3) "-";

Dash-Dot-Dot (4) "--

";

DrawWidth
ScaleWidth

Transparent (5)


,
.
ScaleMode

11.

437

11.16 ()

ScaleHeight

,
. ScaleMode

ScaleMode


.

Width Height (
)

Left

Top

Height

Width

Visible

( False) (
True)

ProgressBar
ProgressBar (. 11.16) ,
, () , . .
ProgressBar . 11.17.
,
Microsoft Windows Common Controls 6.0 SP4
(MSCOMCTL.OCX).

III.

438

. 11.16. ProgressBar

11.17. ProgressBar

Value

, ( )
. (
)
Value.

Min

Value

Max

Value

Scrolling

.
(0
ccScrollingStandard) (1
ccScrollingSmooth)

Appearance

:
(0 ccFlat), 3D (1 cc3D)

Border

: (1 ccFixedSingle),
(0 ccNone)

Shape
Shape (. 11.17) (, (), ),

11.

439

.
,
. . 11.18.

. 11.17. Shape

11.18. Shape

Name

Shape

Rectangle (0) ;

Square (1) ;

Oval (2) ;

Circle (3) ;

RoundedRectangle (4)

RoundedSquare(5) -


BackColor

. ,

BackStyle

: Transparent (0) , Opaque (1)

III.

440

11.18 ()

BorderColor

(
)

BorderStyle

( ):

Solid (0) ;

Dash (1) ;

Dot (2) ;

Dash-Dot (3) "-";

Dash-Dot-Dot (4) "--";

Transparent (5)

DrawWidth

(
)

FillColor

( )

FillStyle

( ):

Solid (0) ;

Transparent (1) "" (

);

HorizontalLine (2) -

VerticalLine (3) .


FillColor
Left

Top

11.

441

11.18 ()

Height

Width

Visible

( False)
( True)

StatusBar
StatusBar (. 11.18)
.
,
Microsoft Windows Common Controls 6.0 SP4
(MSCOMCTL.OCX).

. 11.18. StatusBar

,
.
StatusBar (
Properties) Panels InsertPanel , . StatusBar . 11.19,
StatusBar . 11.20.

III.

442

11.19. StatusBar

Style

() .
(0 sbrNormal) ""
(1 sbrSimple).
,

SimpleText

, , (
Style sbrSimple)

11.20. ( StatusBarPanel)

Style

, . : (0 sbrText), (5
sbrTime), (6 sbrDate), (1 sbrCaps, 2 sbrNum, 3 sbrIns)

, (
Style sbrText)

Alignment

.
(0 sbrLeft),
(2 sbrRight) (1
sbrCenter)

Picture

AutoSize

. 2 (sbrContents), ( ).
1 (sbrSpring), , .
, ,

11.

443

TextBox
TextBox (. 11.19) /
.
. 11.21.

. 11.19. TextBox

11.21. TextBox

Name

.
, ,

Text

Left

Top

Height

Width

Font

Locked

.
False,

III.

444

11.21 ()

MultiLine

ScrollBars

Vertical -

Horizontal

Both -

Visible

None

(False)
(True)

Timer
Timer (. 11.20) Timer.
. 11.22.

. 11.20. Timer

11.22. Timer

Name

11.

445

11.22. Timer

Interval

Timer.

Enabled

(/).
( True) ( False) Timer

UpDown
UpDown (. 11.21) ,
( )
-. UpDown
Label TextBox
-. UpDown . 11.23.
,
Microsoft Windows Common Controls-2 6.0
(MSCOMCT2.OCX).

. 11.21. UpDown

11.23. UpDown

Name

III.

446

11.23 ()

Value

. Up ()
Down ()

Increment

Max

- Value

Min

- Value

BuddyControl

,
- (, Label TextBox)

BuddyProperty

,
BuddyControl,
- (Caption,
Label)

AutoBuddy

-, -.

Label,
BuddyProperty
Caption

SyncBuddy

(True)
Value

Orientation

( ) : OrientationVertical (0) (, ); OrientationHorizontal


(1) (, )

11.

447

11.23 ()

Wrap

False,
Value Up.
Down. True, , Value

Enabled

( True)
( False)

Left

Top

Height

Width

Visible

( False) ( True)

, PictureBox.

:
.
.

448

III.

, . , " "
.
. .

Circle
[.]Circle [Step] (x,y), Radius, [Color,Start,End,Aspect]

Circle , (
Aspect) . ForeColor , ( Color).
( ) DrawWidth DrawStyle ,
.
Step , .
Radius , Aspect, .
Color (
ForeColor ).
Start , End
. Start . .
: r = 2*p/(a/360), r
, a , p
(3,1415926).

11.

449

Aspect .
Aspect 1, ( 0, ).
Aspect 1, .
:
pi = 3.1415926 '
ScaleMode = 3 '
Circle (100, 50), 30 '
Circle (50, 50), 30, RGB(255, 0, 0)
Circle (150, 50), 30, , 0, pi '
Circle (150, 50), 30, , 0, pi / 2 '
Circle (150, 50), 30, RGB(255, 0, 0), pi / 2, 0 '
Circle (100, 120), 30, , , , 0.5 '
Circle (100, 120), 30, , , , 2

'

Line
[.]Line [Step] (x1, y1) [Step]-(x2, y2),[Color], [B][F]

Line ( B).
x1, y1 x2, y2
( B).
( )
ForeColor (
Color).

450

III.

DrawWidth
DrawStyle , .
Step , .
Color , B,
( ForeColor ).
B , .
F ,
, .
:
ScaleMode = 3 '
Line (10, 20)-(100, 20) '
Line (10,30)-(100,30), vbRed '
Line (10, 40)-(100, 50), vbBlack, B

'

Line (10, 80)-(100, 90), vbBlack, BF '

LoadPicture
.Picture = LoadPicture()

LoadPicture (BMP, GIF,


JPG) PictureBox Image .
:
Picture1.Picture = LoadPicture("D:\Images\image02.gif")

LoadResPicture
.Picture = LoadResPicture(, vbResBitmap)

11.

451

LoadResPicture PictureBox Image .


, .
:
Picture1.Picture = LoadResPicture(102, vbResBitmap)

PaintPicture
Pic1.PaintPicture
Pic2,x1,y1,[w1],[h1],[x2],[y2],[w2],[h2],[OpCode]

PaintPicture ( ) Pic2 ( Picture, Image StdPicture)


Pic1 ( Picture). x1, y1, w1,
h1 , , x2,
y2, w2, h2 .
:
Picture1.PaintPicture 0,0 Picture2
' Image1
' Picture1
Picture1.PaintPicture 0,0 Image1, 15,0,16,16
Dim aPicture As StdPicture
Set aPicture = LoadPicture("D:\Temp\image06.gif")
Picture1.PaintPicture aPicture, 0, 0

Print
[.]Print String

Print String
( -

452

III.

CurrentX CurrentY).
Font (, ),
, ForeColor
.
:
Font.Name = "Arial"
Font.Size = 12
ForeColor = RGB(0, 0, 255)
ScaleMode = 3 '
CurrentX = 10
CurrentY = 20
Print "Microsoft Visual Basic"

PSet
.PSet (x,y)

PSet .
ForeColor DrawWidth , .
:
Form1.Forecolor = RGB(56,176,222) ' " "
Form1.DrawWidth = 2
Form1.PSet(10,20)

RGB
RGB(r,g,b)

RGB . r, g b (r red), (g green) (b blue) . r, g, b 0 255.

11.

453

. 11.24 r, g, b
, .
11.24. RGB-
r

112

219

147

140

23

23

66

66

111

-,

127

255

173

234

234

112

219

219

143

188

143

140

120

83

-2

166

125

61

255

127

35

107

142

95

159

159

133

94

66

233

194

166

166

128

100

84

84

84

153

204

50

147

219

112

82

127

118

-,

74

118

110

III.

454

11.24 ()

66

111

66

219

219

112

234

234

174

205

127

50

78

47

47

217

217

243

142

35

35

255

127

50

205

50

166

42

42

181

166

66

35

142

35

153

50

205

()

228

120

51

184

115

51

35

142

104

89

89

171

50

153

204

255

110

199

156

-,

79

79

47

255

36

11.

455

11.24 ()
r

255

127

56

176

222

255

28

174

33

94

33

142

107

35

205

205

205

92

64

51

127

255

127

255

107

35

142

209

146

117

47

47

79

217

135

25

216

216

191

188

143

143

133

99

99

219

147

112

-,

235

199

158

-,

151

105

79

143

143

189

219

112

219

III.

456

11.24 ()
r

-,

147

112

219

168

168

168

192

217

217

230

232

250

192

192

192

159

95

159

234

173

234

111

66

66

50

50

205

107

142

35

50

205

153

207

181

59

112

147

219

142

35

107

47

79

47

92

64

51

135

31

120

47

79

79

35

35

142

204

50

153

-,

219

112

147

79

47

79

11.

457

11.24 ()

159

159

95

216

191

216

80

51

23

107

66

38

217

217

25


InputBox, MsgBox.

InputBox
InputBox(Prompt[,Title][,Default][,X][,Y][,HlpFile,Cnt])

InputBox ,
. .
Prompt - ,
.
Title .
, ,
.

458

III.

Default ( ) ,
( ).
,
.
X Y . . ,
.

MsgBox
MsgBox(Prompt[,MsgType [,Title][,HlpFile,Cnt])

MsgBox .
, .
Prompt ( ) .
MsgType ( ) , . MsgType : Msg + Btn, Msg , Btn
(), . : vbInformation (64) , vbCritical
(16) . (): vbOKOnly
(0) OK; vbOKCancel (1)
OK Cancel; vbYesNo (4) Yes
No. ,
OK.
Title . , , .
HlpFile , Cnt . -

11.

459

<F1>.


. 11.25 .
11.25.

Abs(n)

() n

Sqr(n)

Exp(n)

Sgn(n)

n. n , 1,
0,
0

Rnd

0 1.
Rnd

Randomize

Int(n)

.
"" . n , , n.
: Int(5.85)=5, Int(-5.85)=-6

Fix(n)


.
, N.
: Fix(5.85)=5, Fix(-5.85)=-5

III.

460

11.25 ()

IsNumeric(s)

, s . s ( ) ,
True. , False.
:
IsNumeric("5,85") True,
IsNumeric("5,8 5") True,
IsNumeric("hello") False

Log(n)

( ).
:
Log(n)/Log(10)

Sin()

Cos()

Tan()

Atn()

(Sin, Cos, Tan, Atn)


.

(g * 3.1415926)/180,

g , 3.1415926 .

11.

461


. 11.26
.
11.26.

CDbl(s)

s Double

CInt(s)

s Integer

CLng(s)

s Long

CSng(s)

s Single

CStr(n)

n .
,

Str(n)

n .


. 11.27 ,
.
11.27.

Chr(Code)

Chr ANSI-,
. Code
0 255

III.

462

11.27 ()

Asc(Ch)

Asc Ch

InStr([Start,]

InStr
.
Start .
.
, 0.

String1,String2
[,Compare])

Start
,
. ,
.
Sring1 , .
Sring2 ,
Sring1.
Compare
: TextCompare (1) , BinaryCompare (0)
.

,
. ,
InStr(1, "Hh", "h",
vbBinaryCompare) 2, InStr(1,
"Hh", "h", vbTextCompare) 1
InStrRev(String1,
String2
[, Start]
[, Compare])

InStrRev ( ) .

Start . () (
() ).
,
0.

11.

463

11.27 ()

Start
,
. ,
.
Sring1 , .
Sring2 (),
Sring1.
Compare
: TextCompare (1) , BinaryCompare (0)
.

, . ,
InStrRev(1, "HHt", "ht",
vbBinaryCompare) 0, InStr(1,
"Hht", "ht", vbTextCompare) 2

Len(S)

Len S
( )

LCase(S)

LCase S .

UCase(S)

UCase S .

Left(S, L)

Left (
, ) L
S. L , S,
S

III.

464

11.27 ()

Right(S, L)

Right ( , ) L S. L ,
S,
S

LTrim(S)

LTrim

RTrim(S)

RTrim

Trim(S)

Trim

Mid(Str,Start

Mid , Str. Start


, Len (
). , Mid("Ms
Visual Basic",4,6) Visual

[,Len])

Space(N)

String(N, Ch)

, N
Ch

StrReverse(S)

"" S. , StrReverse("Hello")
olleH

Val(S)

Val ,
S.
,
,
. . ,
,
- .

11.

465

11.27 ()

,
0.
: Val(123 45) = 12345;
Val(123,45) = 123;
Val(123.45) = 123.45; Val("Text") = 0


. 11.28
.
11.28.

Date

Time

Now

Year(Date)

Month(Date)

MonthName(Month
[, Abbreviate])

(3 ) ( Month
1
12;
Abbreviate True, , False )

III.

466

11.28 ()

Day(Date)

( 1 31)

Weekday(Date,

Date.
FirstDayOfWeek
: vbUseSystem (0) , Sunday (1) ,
Monday (2) . .

[FirstDayOfWeek])

WeekdayName(Weekday,
Abbreviate,
FirstDayOfWeek)

(2 )
.
Weekday 1 7; Abbreviate True,

, False
.
FirstDayOfWeek
: vbUseSystem (0) , Sunday (1) ,
Monday (2) . .

Hour(Time)


Time

Minute (Time)


Time

Second (Time)


Time

Timer

11.

467


. 11.29 ,
.
11.29.

Open PathName

Open /.

For Mode
[Access Am]
[Lock]
As #FileNumber
[Len = reclen]

PathName ,
.
Mode
: Input (),
Output (),
Binary / , Random /
.
Am , : Read
(), Write (), Read Write
(/).
FileNumber
( 1 511) .
reclen
( ),
(Binary)

Seek #FileNumber,
Position

Seek
/ ,
(Binary).

III.

468

11.29 ()

FileNumber .
Position
( ),

Seek( #FileNumber )

Seek /

FreeFile[(Range)]

FreeFile ,

( FileNumber) Open

Get #FileNumber,

Get : FileNumber () , RecNumber ( ,


Binary),

, VarName
,

[RecNumber],
VarName

Put #FileNumber,
[RecNumber],
VarName

Line Input #FileNumber,


VarName

Put :
FileNumber ()
, RecNumber (
, Binary),
, VarName ,
Line Input FileNumber
VarName.
,
" "
( 13)

11.

469

11.29 ()

Input #FileNumber,

Input
. FileNumber ,
VarList , .
: Input #1, a,b,c

VarList

Input(Number,
#FileNumber)

Input c
, Input Binary. Number
,
FileNumber .
: IDChar = Input(1, #1)

Print #FileNumber,
[OutputList]


FileNumber .
OutputList ( )
.
: Print #1,
"a="+Str(a),"b="+Str(b)

Write #FileNumber,
[OutputList]

.
OutputList
( ). .
: Write #1, a, b

FileLen(PathName)

FileLen
( )

LOF(FileNumber)

LOF
( )

EOF(FileNumber)

EOF /. True,
(
)

III.

470

11.29 ()

Dir[(Path

Dir
, ,
Path
Attributes. (),
, , "" (""). Path
(, c:\temp\*.bmp),
, .
,
, Dir
, . :

[,Attributes])]

fn = Dir("c:\temp\*.bmp")
fn = fn + Chr(13) + Dir
Attributes
() : Normal (0), ReadOnly (1), Hidden (2), System (4), Directory (16) .
:
Dir("e:\test.txt")
"test.txt", test.txt
e:;
Dir("e:\t\*.txt")
e:\t txt;
Dir("e:\",vbDirectory)
( ) e:
CurDir

CurDir ( ) ()
.

11.

471

11.29 ()

ChDir Path

ChDir ()

MkDir Path

MkDir .
Path
.

RmDir Path

RmDir . Path ( )
, . ,
, .

( Kill),

Kill PathName

Kill .
PathName ( )
, .
,
,

. : Kill
"c:\temp\*.tmp"

Environ(p)

. Windows, ,
. :
Environ("Windir") Windows; Environ("Homedrive") ,
; Environ("Homepath") ;
Environ("Temp")


A
Abs 459

ADO 276
Adodc 277
Asc 462
Atn 460

B
Bitmap 197

C
CD Player 245
CheckBox 87, 414
Chr 461
Circle 448
ComboBox 94, 415
Command 362
CommandButton 82, 417
CommonDialog 120, 419
Cos 460
CREATE TABLE 309
CurrentX 155
CurrentY 155

D
DataGrid 277
Date 465
Day 466
Dir 470

DirListBox 420
DriveListBox 422
DROP TABLE 311

E
Exp 459

F
FileListBox 423
Fix 459
Format 178
FreeFile 148

H
hh.exe 336
Hour 466

I
IExpress 342
Image 112, 425
Image Editor 64
Input 148, 469
InputBox 457
INSERT INTO 310
InStr 462
Int 459
Internet Explorer 396
IsNumeric 460

474

L
Label 70, 427
LCase 463
Left 463
Len 463
Line 428, 449
ListBox 430
LoadPicture 184, 450, 451
LoadResPicture 450
Log 460
LTrim 464

Option Explicit 51
OptionButton 91, 433

P
PaintPicture 197, 451
PictureBox 103, 434
PlaySound 221
Print 176, 451, 469
ProgressBar 131, 437
PSet 452

R
M
MenuEditor 140
MessageDlg 55
Microsoft Access 275
Microsoft HTML Help
Workshop 324
Microsoft Jet 277
Mid 464
midiOutSetVolume 263
Minute 466
MMControl 225, 432
Month 465
MonthName 465
MP3 Player 229
MSDN Library 7, 8
MsgBox 458

N
Now 465

O
Open 467

Resource Editor 214


RGB 157, 452
Right 464
Rnd 459
RTrim 464

S
Second 466
SELECT FROM 288
Sgn 459
Shape 438
Shell 336
ShellExecute 396
Sin 460
Space 464
SQL-:
CREATE TABLE 309
DROP TABLE 310
INSERT INTO 310
SELECT FROM 288
Sqr 459
StatusBar 126, 441
String 464

T
Tan 460

TextBox 78, 443


TextHeight 155
TextWidth 155
Time 465
Timer 100, 444
Trim 464

U
UCase 463
UpDown 135, 445

:
310
308
309
310
196
217
197
197

267
:
CD 245
MIDI 238
MP3 229
267
56

475

V
Val 464
Video Player 267

W
waveOutSetVolume 251
WeekdayName 466
Write 148

Y
Year 465

130
:
153
:
251

:
187
120
120
156, 168

:
40

476

:
Internet Explorer 396
336
:
MID 225
MP3 225
WAV 225
221
63
64

:
- 205
378
182
184
116
103, 112
:
53

:
470
471
470
471
361
12, 23
Adodc 277
CheckBox 87, 414
ComboBox 94, 415
CommandButton 82, 417
CommonDialog 120, 419
DataGrid 284

DirListBox 420
DriveListBox 422
FileListBox 423
Image 112, 425
Label 70, 427
Line 428
ListBox 430
MMControl 225, 432
OptionButton 91, 433
PictureBox 103, 434
ProgressBar 131, 437
Shape 438
StatusBar 126, 441
TextBox 78, 443
Timer 100, 444
UpDown 135, 445
119
154
156, 165
395
395

156, 157
158
158
158
158

139
:
Circle 156
Line 156
PaintPicture 197
Print 156

PSet 156
SetFocus 61
149
201

15
156, 165
:
178
178

:
114
114

361
18
CD 245
:
AVI 267

37
156, 161
162

:
MIDI 263
WAV, MP3 251

15
168

477

130
34
KeyPress 58
QueryUnload 35
Terminate 35
Unload 35
36
EXE- 56
:
HTML Help 1.x 315
MS Help 2.x 315
WinHelp 315
329
327
334

336
317
:
464
463
462
464
278
275

156, 176
156

:
154
154
:
Resource Editor 214

478

:
148
107
148
:
214
18
:
Command 362
Environ 471
Format 178
LoadPicture 184
midiOutSetVolume 263
PlaySound 221

RGB 157
Rnd 130
ShellExecute 396
waveOutSetVolume 251

:
158
157

156, 173