??????? ?? Visual Basic

Печать
Рейтинг пользователей: / 926
ХудшийЛучший 

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

1. ??????? ???????? ????? VB. ??????????? VB 6.0.

Visual Basic ???????? ??????????? ??????????? ???????? ????? BASIC (Beginner's all-purpose symbolic instruction code). ?????????? ???????? ?????? ????? ???????????? ??? ???????????? ?????????? ???? ???????????????? ??? ??????????. ?.?. ???? ????????????? ?????????????? ??? ?????????? ?????????????, ??? ???? ??? ???????? ????? ??????? ? ????????? ??????.

? ?????????? ??????? Windows ????? Microsoft ??????????? ??????????? ??????? ????? ??????. ? ???????? ???? ???? ?????????????? ??? ????????? ??????????, ?????????? ? ?????????? ?????? ? ?????????????, ?.?. ? ?????????? ??????. ??????? ??? ? ??????? Visual Basic (VB).

VB ???????????? ? ???????? ?????????? ?????????? ? ????? Microsoft. ??????????????? ??????????? ?????? ????? ??? ?????????? ??????? ????????? ?????????? - VBA - Visual Basic for Application, ?????????? ??? ?? ??? ???????? Microsoft Office, ??? ? ? ???????? ?????? ????. ????? ????, ????????? VBScript - ?????????? ??? ???????? web-??????.

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


2. ???????????? ? ?????????? VB.

??? ? ????? ?????? ???? ???????????????? VB ????? ???? ???????????? ? ???? ??????????. ?????? ? ???????????.

1. ???? ?????? ????????????? ?????????????? ??? ?????????? ?????????????, ??????? ????????? ???????? ?? ??????? ??????????? ?????????? ? ????????????? ????? (???????????), ? ????????? ????? ????? ??????? ?????, ??? ????????? ????? ??.

2. ?????? ?? ????? ???? ?????? ?????????, ?.?. ????????? ?? VB ???????? ?? ??????, ????????? ? ???????????? ?????????????? ??????????. ???????????? ?? ??, ??? ????????? ?? ??? ??????????? ????????????? ????????? ??-?? ????, ??? ???? ????????? ???????, ??????????? ?????????? ????????? ?????????? ???? ? ???????? ?????? ???? ??????.

3. VB ???????????? ??? ????????? ???????????? ???????????????? (if, while, for, ? ?.?.) ? ????? ? ???? ?? ???????? ??.

4. VB ??????????? ???????? ???????? ?????????? ??????? ??????????, ??????? ????????? ??????? ?????????? ??????????.

5. VBA ???????? ???????? ??????????? ????? VB, ??????? ??? ???? ???????? ? VB ????? ????????? ? ????????? ?????????? ? ???????? ??? ?????? ????????.

6. VB ????????? ????? ????????? ????????? ? ???????? ?????????? Active X. (??. ?????).

7. ??????????? VB ????? ??????????? ?? ???? ????????? ? ???????? Win32 API (?? ???? ????? ?????), ???????? ???????????? ?? VB ?????? ? Windows ???, ??? ????? ???? ??????? ?? ??.

8. VB ??????? (?? ?????????) ???????????? ????? ?????? ?????? ?????????? ??????? Windows - HTML Help, ? ?? ????? ??? ? ?????? ?????? ?????????? ??????????.

??????, ??? ?????? ??????, ? VB ???? ??? ???????????.

1. ? ??????????? VB ????? ??????? ???????????? ?????? ????????? ???. ? ?????????, ?? ????????? ??????????? ???????????? ???????, ??????????? ????????? ???????????? ????? ??++, ????????? ? ????????????? (???????????????, ?????????? ????????????? ?????? ????? ????????? ?????? ??????, ????????????? ????????????? ??????? ??? ??? ??????????). ??????, ???????? ?? ???????????, VB ????????? ?????? ????????-??????????????? ?????????.

2. ??-?? ????????????????? Win32 API ? ????? ?????? VB, ????? ?????? ?????? ???????? ? ?????????? API-?????????. ????? ??????????? ?????????? ? ????? ??????????, ? ?????? API-??????? ? ???? ???????? ? ?? ??????????.

3. VB ?? ????????? ??? ???????? ? ??????? ??????? DLL-??????????. ????????? VB, ?? ??????? ????????? ?????? Active X-DLL ??????????.

 


3. ?????? VB.

??? ??????? VB ?????????? ?????????? ???? new project, ??????? ????? 3 ???????:

1. New - ????????? ??????? ???? ?? ?????????? ????? ????????, ??????? ????? ???? ???????.

2. Existing - ???????????? ??????.

3. Recent - ???? ?? ??????? ???????????????? ????????.

 

??? ?????? ?????? ??????? ?? ????????? ?? ?????? ????????????? ???????:

1. ???????? ???????? exe-?????.

2. ActiveX.exe - ?????????, ??????? ???????????? ????? ?????? ?????????????, ?????????? ?????????? ???????, ??????? ????? ???????? ???? ?? ???? ??? ????? ?????? ? ?????? ?????????? (?????? - word).

3. ActiveX.dll (Dynamic Loading Library) - ????????? ?????????????, ??????? ?? ????? ???????? ???? ?? ????, ? ??????????? ? ?????? ??????-???? ????????.

4. ActiveX Control - ????????? ????????? ??????????? ???????? ??????????.

5. Data project - ?? ??? ?????? ????????? ?????????? ??? ?????? ? ?????? ??????.

6. VB Application Wizard - ?????? ???????? ??????????

7. ? ?.?.

 


4. ??????????????? ????? ?????????? (IDE - Integrated Development Environment)

????? ?????????? ??????? ?? 8-?? ?????????:

1. ?????? ?????????

2. ?????? ????

3. ??????????? ?????? ???????????? Tool Bar

4. ???? ???????????? Controls Tool Box. ? VB ????? ?????? ?????????, ??????? ????? ??????? ?? ??????. ???? Project/Components ???????? ??, ??? ????.

5. ?????? ?????

6. ???? ???????? ???????

7. ???? ??????? (???????? ???????? ???????)

8. ???? ???????????? ?????.

 

??? ???????? ?????????? ????????? ???????????? ????? ??????????? ????????, ??????? ???????? ?? ?????? ????????????:

1. Picture Box - "?????????" ??? ????????. ???????????? ??? ??????????? ??????????? ???????????.

2. Image - ?????? Picture Box, ?? ? ?????????? ?????????????

3. Label - ???????

4. Text Box - ???? ??????????????

5. Command Button - ????????? ??????

6. Check Box - ??????

7. Option Button - ????? ??????

8. List Box, Combo Box - ?????? ? ?????? ? ????? ??????????????

9. HscrollBar ? VscrollBar - ???????????? ? ?????????????? ?????? ?????????

10. Timer - ?????? ???????????? ??????? ? ???????????? ?????

11. DriveListBox, FileListBox, DirListBox - ?????? ??????, ?????? ? ??????????

12. Shape, Line - ?????????????? ??????, ?????

13. Data - ????????? ??????????? ????? ? ??

14. OLE - ???????????? ??????????? ? OLE-????????.

 

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

??????? - ??? ?????????, ??????? ????????? ??????? (??????? ?? ?????? - Click).

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

????? ??????? ?????????: Me.Label1.Caption = "????? ??????? ?????????"

?????? ?????????? - F5

 

?????? ???????:

*.frm - ????, ??????? ????????? ?????. ??????? ????????? ????, ? ??????? ?????? ???????????? ?????????? ? ???, ?????????????? ? ???? ?????.

*.bas - ????? ???????. ???????? ???????? ?????????? ????????, ????????? ?? ???? ???????: ??????????, ?????????, ???????.

*.frx - ???????? ?????, ??????? ???????? ???????, ????????????? ?????.

*.ctl - ????? ocx ?????????

*.cls - ????? ???????

*.vbp - ???? ???????, ??????? ? ????? ????????? ??????.

 

????? ??????? ????? ? ???????? ??????? ??????????? ????????? ??????????.

 


5. ???????? ??????????? ?????.

5.1. ??????? VB.

??????? VB ??????? ?? ????????? ???? (??? ????????, ??? ? ?????????), ????, ??????????? ???????? (??????, ?????????????, ? ??.).

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

Rem ??? ???????????

A = 0 ??? ???? ???????????

 

5.2. ??????????.

?????????? ?????????? ?????????????? ????????? ???????:

<???????????? ?????????> <??? ??????????> As <???>

<???????????? ?????????> ::= Dim | Private | Public | Static

<???> ::= Integer | Long | Single | Double | Currency | String | Byte | Boolean | Date | Object | Variant

???????? ????????? ? ????? ?????? ????????? ????????? ??????

?????? ?????????? ?????????? ????????? ????????.

??????? ?????????? ??????????:

Dim aaa As Integer

Public bbb As Date

Static ccc As Variant

 

?????????????? (?????) ?????????? ? VB ?????? ??????????????? ??????? ?????? ????:

1. ??? ?????? ?????????? ? ?????

2. ? ?????????? ????? ????? ????????? ?????, ?????, ???? ?????????????

3. ?????? ???????????? ? ????? ??????, ., :, ; ? ??.

4. ??? ?????? ???? ????????? ? ???????? ?? ?????????

5. ????? ?? 255 ????????

6. ??? ?? ?????? ????????? ? ????????? ???????

7. ??? ?????????? ?? ??????? ?? ???????? - Name = nAmE = name

8. ??? ?????????? ?????? ???? ????????????? ? ????????.

 

5.3. ???????????????? ???? (User Defined Types).

<???????????? ?????????> Type <??? ????>

<??? ????> As <???>

. . .

End Type

?????? ? ????? ?? ????? ?????????? ????????????????? ???? ?????????????? ????? ?????.

?????? ?????????? ????????????????? ???? ??????:

Public Type MyType

X As Long

Y As Byte

End Type

Dim Aaa As MyType

Aaa.X = 4.0

Aaa.Y = 245

 

5.4. ?????????.

[ Public | Private ] Const <??? ?????????> [As <???>] = <????????>

?????????? ? VB ????????? ?????? ?????????? ? vb. ????????? ????? ??????? vbCrLf, vbSizeWE...

?????? ?????????? ????????:

Public Const myConst As Integer = 255

 

5.5. ???????.

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

?????? ???????? ?? ????????? ?????????? ? 0. ???????? ?????? ?? ????????? ????? ??? ????? ?????? ????? ?????????? ????????? (? ?????? ??????!):

Option Base <?????>

<???????????? ?????????> <???> ( [<??????>] ) As <???>

<??????> ::= <?????> [To <?????>]

Dim iInt(30) As Integer

Dim iInt (1 To 30) As Integer

 

5.6. ?????????????? ?????????.

+, -, *, / - ??? ??????

\ - ????????????? ??????? (??????? ?? ???????)

mod - ??????? ?? ???????

^ - ?????????? ? ???????

5.7. ???????? ?????????? ?????.

??? ?????????? ????? ???????????? ?????? &, ???? ????? ???????????? +, ?? & ????????.

5.8. ?????????? ????? ?????????? ????????? (????????? ?????????).


If <???????> Then

???? ?

[ Else

???? ?

]

End If

 

 

 

 

 

If <???????1> Then

???? ?

ElseIf <???????2> Then

???? ?

ElseIf <???????3> Then

???? ?

. . .

Else

???? ?????

End If


Select Case <?????????>

Case <????????1>

???? 1

Case <????????2>

???? 2

. . .

Case Else

???? ?????

End Select

???????? ?????????? ???????? ???? Case Is < 0, Case Is>2+bbb, Case 1,2,3, Case 1 To 3 ? ??.

?????????? ?????????:

And - ?

Or - ???

XOr - ????. ???

Not - ??

?????????? ?????????: TRUE, FALSE

????????? ?????????: <,>,<>,>=,<=

 

5.9. ????????? ?????.

5.9?. ???? ? ????????.

? ????????????:

Do While <???????>

???? ??????? ???????, ??????????? ???? ?????

Loop

???? ?????????? ????????? ???? ????? ? ?????, ??? ????? Do While ???????????? ???????? Exit Do.

 

Do Until <???????>

???? ??????? ?????, ??????????? ???? ?????

Loop

 

? ????????????:

Do

???? ????? ??????????? 1 ??? + ???? ??????? ???????

Loop While <???????>

 

Do

???? ????? ??????????? 1 ??? + ???? ??????? ?????

Loop Until <???????>

 

5.9?. ???? ?? ?????????.

For <??? ??????????> = <????????1> To <????????2> [ Step <???> ]

???? ????? ??????????? ??? ?????????? ?????????? ??

???????? 1 ?? ???????? 2 ? ???????? ????? (??? ? ?????

1 ?? ?????????). ??? ????? ???? <0 ??? ???? ???????. ????? ?? ????? - ???????? Exit For

Next <??? ??????????>

For i=1 to 30 Step 2

Next i

5.10. ??????????? ???????? ????????.

?????:

GoTo ?????

 

5.11. ????????? ? ???????.

????????? (?????? ?? ??????????) ??????????? ????????? ????????:

<Public|Private|Static> Sub <??? ?????????> ( <?????????> )

???? ?????????

End Sub

???????? ????? Public|Private|Static ?????????? ??????? ????????? ? ??? ?????????. Public - ????????? ?????????? ??? ????? ???????. Private - ????????? ??????????? ?????? ?????? ?????. Static - ??? ?????????? ???? ????????? ???????????. ?? ???????? ?? ???????? ????? ?????? ?? ?????????.

??? ?????????? ?????? ?? ????????? ???????????? ???????? Exit Sub.

??????? ????????? ? ???? ????????? ????? ????????? ???????:

[<??? ?????>.]<??? ?????????> <???????? ???-??1>[,<???????? ???-??2> ...]

 

??????? (?????????? ?????-???? ????????) ??????????? ??????????:

<Public|Private|Static> Function <??? ???????> (<?????????>) As <??? ????????????? ????????>

???? ???????

??? ??????? = ...

End Function

????????? ????? - Exit Function.

??????? ???????? ??????? ? ???? ??????? - ???????????? ????? ??????? ???????? ?????????? ????????????.

????? ???????:

[<??? ?????>.]<??? ???????> ( <???????? ???-??1>[,<???????? ???-??2> ...] )

 

????????? ? ??????? ???? ????????? ????? ???????????? ??? ?? ??????, ??? ? ?? ????????. ??? ???????????? ? ???????? ?????????? ??????? ??? ????????? ???????????? ???????? ???? ByVal ? ByRef ????? ?????? ?????????. ?? ????????? ??? ????????? ?????????? ?? ??????.

?? ????????: ???????? ?????????? ? ?????????. ??? ???????? ??????????? ??? ??? ??????. ???????? ?? ??????????.

?? ??????: ?????? ?????????? ????? ??? ????????? ? ?????????. ???????? ??????????.

??? ??????? (ByVal sStr As String, ByRef iInt As Integer)


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

???? ??????.

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

??? ??????????

???????? ????????

?????????? ??????

???????? ?????????? ????????

Integer

????? ????? ????????? ????????

2 ?????

-32768 ... +32767

Long

????? ????? ??????? ????????

4 ?????

-2147493648 ... +2146483647

Single

?????????? ????? ? ????????? ?????? ????????? ????????

4 ?????

+(10-45 ... 3*1038)

-(10-45 ... 3*1038)

Double

?????? float. ?????????? ????? ? ????????? ?????? ??????? ????????

8 ????

+(5*10-324 ... 1.8*10308)

-(5*10-324 ... 1.8*10308)

Currency

?????????? ????? ? ????????????? ??????. ????? ????? - 15 ????, ??????? - 4 ?????.

8 ????

-9*1014 ... +9*1014

 

String

?????? ??????

1 ???? ?? ?????? (??? 2 ????? ??? Unicode)

?? 65400 ???????? ??? ????? ? ????????????? ?????? ? ?? 2 ????. ???????? ??? ???????????? ?????

Byte

????? ?????

1 ????

0 ... 255

Boolean

?????????? ????????

2 ?????

True ??? False

Date

????/?????

8 ????

1/1/100 ... 12/31/9999

Object

????????? ??????; OLE-??????

4 ?????

----

Variant

????? ?? ?????????????????. ????? ????????? ????? ???.

16 ???? + (???? ??????) 1 ???? ?? ?????? (??? 2)

----

????? ???? ??????????? ????? ????? ???????? ???????????????? ???? ??????. ?????????? ?????????? ????????????????? ???? ?????????????? ?????????? ?????????? ?????????? ???????????? ????.

 


2. ?????????? ? ?????????, ?? ??????? ?????????.

2.1. ????? ? ??????? ?????????? ??????????.

????? ?????????? ?????????? ????????, ??? ? ????????? ??? ???????? ???? ?????????? ????? ?????????????? ??????????? As <???>.

??????:

Dim first As Integer

Public second As String

??????? ?????????? - ??????????? ???? ?????????? ?? ?? ????? (??????, ?? ???????? ?????) ??? ????????????? ????????? ????? As. ??????? ??????? ?? ?????? ???????, ???????????? ????? ?????????? ? ?????? ???????????? ? ????????? ???????:

??? ??????????

???????

Integer

%

Long

&

Single

!

Double

#

Currency

@

String

$

Variant

??? ????????

???? ? ?????? ? ??????? ?????????? ?????????? ??? ??????????? Option Explicit, ?? ?????????? ????? ?? ?????????. ??? ????? ??????????? ??? ?????? ????????????? ? ??????? ???????? ??????????. !!!!!!!!!!! (Option Explicit ? ????????? - ???????????)

?????? ????????????? ???????? ??????????:

Inta% = 6 `??????? ?????????? ???? Integer ? ??????????? ?? ???????? 6

Str1$ = "string1" `??????? ?????????? ???? String ? ??????????? ?? ????????

Pi# = 3.1415926 `??????? ?????????? ???? Double ? ??????????? ?? ????????

Varvar = 5 `??????? ?????????? ???? Variant ? ??????????? ?? ???????? 5

???? ?? ? ?????? ?????????? ??????????? Option Explicit, ?? ?????????? ????? ?????????????? ?????????? ????????. ?????? ? ????? ????? ?????????? ? ???????? ????????.

??????:

Dim Inta%

Dim Str1$

Dim Pi#

Dim Varvar

 

2.2. ?????? ?????????? ? ????????????? ?????.

??????????? ?????, ? ???????? ?????????? ????? ???? ? ??????????, ???????? ?.?. ???????? ?????????? ?????. ????????? ?????????? ??????? ???? ????? ????? ????? ?? 2 ????? (2 ????. ????????). ?????? VB ??? ????????? ?? ?????????????? ? ????????? ??????, ????????? ??? ????? ??????????.

?????? ? VB ???????????? ? ?????? ????????? ??? ?????? - ?????? ????????????? ?????. ????? ????? ?????????? ?????? ?????????, ??? ??????????? ?? ????????. ???? ????? ??????, ?????????? ? ????????? ?????????? ????????????? ????? ??????, ??? ?????? ????????? ??????????, ?? ?????????? ????? ??????????? ?????????. ???? ?? ????? ???????? ?????? ??????, ?? ?????? ????? ?????????? ?? ????? ??????????!

????????? ?????????? ????????????? ????? ??????????? ????????? ???????:

<???????????? ?????????> <??? ??????????> As String * <?????>

??????:

Dim Strstr1 As String * 25

Public Strstr2 As String * 255

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

 

2.3. ????????????? ????????? ? ??????? ????????? ??????????.

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

?????????? ??? ???? ????????? ??????????:

? ?????? ???????? ?????, ?????????????? ??? ??????? ??????? ????????? (????????????? ?????????):

? ??????????? ?? ?????????? ????????? ?????????? ?????????? (? ????????? ??? ??????) ??? ????? ????????? ???? ?????????:

???????????? ?????????

?????????? ? ????????? ??? ???????

?????????? ? ?????? (? ?????????? ??????? ????????)

Dim

????????? ?????? ? ?????????

????????? ? ?????? ? ???? ???????? ? ?????????? ??????

Private

?? ????????????

????????? ? ?????? ? ???? ???????? ? ?????????? ??????

Public

?? ????????????

????????? ?? ???? ???????

Static

????????? ?????? ? ?????????, ?????????? ?????????? ???????????

?? ????????????

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

 

2.4. ????????????? ????????? ? ??????? ????????? ???????? ? ???????.

??? ??????? ? ???????? ???? ?????????? ???? ??????? ?????????.

?????????? ??? ???? ????????? ???????? ? ???????:

? ??? ???????? ?????, ?????????????? ??? ??????? ??????? ????????? (????????????? ?????????):

? ??????????? ?? ?????????? ????????? ?????????? ??????? ??? ????????? (? ????? ??? ??????) ??? ????? ????????? ???? ?????????:

???????????? ?????????

?????????? ? ?????

?????????? ? ??????

Private

????????? ?????? ? ?????

????????? ?????? ? ??????

Public

????????? ?? ???? ???????

????????? ?? ???? ???????

???? ??????? ???????? ????? Static, ?? ??? ??????????, ??????????? ? ???? ????????? ??? ??????? ?????????? ????????????.

?????? ? ?????????? ? ????????/??????????, ???????????? ? ????? ? ??????? ?? ???? ??????? ?????????????? ????? ??? ?????, ????? ? ??? ?????????? ??? ?????????/???????. ??? ??????????, ???????????? ? ??????, ??? ?????? ????????? ?? ????, ???? ??? ?????????? Public ?????????? ? ?????? ???????.

 


3. ?????????? ???????? ? ?????? ? ????.

? VB ???????????? ??? ???? ????????:

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

????? ???????? ??????, ???????????? ????????? ???????????:

<???????????? ?????????> <??? ??????????> (<???????????> [,<???????????> , ... ] ) As <??? ??????>

<???????????> ::= <?????> [To <?????>]

??? ??????? ? ???????? ??????????? ?????? ?????? ?????, ?????? ??????? ????????? ???????? ?? 0 (?????????? ???????? ?? ?????????) ?? ????? ?????? ????? ????????????. ???????? ????????? ???????? ?? ????????? ????? ???????? ? ?????? ?????? ???????? ????? Option Base <?????>.

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

??????????: ? ???????? ??????????? ??????? ?????? ???????????? ??????????!

??????? ?????????? ????????:

Dim aaa (10,5) As Integer

Dim bbb () As Long

Dim ccc (-1 To 6, 1 To 5) As Long

?????? ? ????????? ??????? ?????????????? ?????????? (????? ??????).

????????? ??????????? ????????????? ??????? ????????? ??? ?????????? ????????? ReDim:

ReDim [Preserve] <??? ???????> ( <????? ???????????> )

???? ??????? ???????? ????? Preserve, ?? ??? ????????? ??????????? ??????? VB ??????????? ????????? ???????? ????????????? ????? ?????????. ???? ??? ???????? ????? ?? ???????, ?? ???????? ????????? ??????? ????????.

?????? ????????????? ReDim:

ReDim bbb (5)

ReDim bbb (5 To 10)

?????????? ??? ???????, ??????????? ?????? ??????? ??????? ???????:

UBound (<??? ???????> [, <??????>])

LBound (<??? ???????> [, <??????>])

?????? ????????? ??? ????? ??????????? ???????????? ??????? ?????????? ??????? ?? ??? ???? ???????.

?????? ?????????????:

UBound (aaa,1) ????????? 10 (??????? ?????? ?? ?????? ???????????)

LBound (???,2) ????????? 1 (?????? ?????? ?? ?????? ???????????)


???????? ????

 

?????????? ??? ???? ????:

1. ??????????? ???? (??????????? ??????????);

2. ??????????? ????.

 


1. ???????? ???????????? ????

??????????? ???? ????????? ? ??????? ??????????? MenuEditor (????????? ? ?????? ???? Tools).

Caption: ?????, ??????? ???????????? ? ???????? ????. ???? ?????????? ??????? ??????? ???????? ???????, ????? ?????? ???? ????????? ???? &. ????????: &File.

Name: ???????????? ??? ????????????? ???????? ???? ? ???? ????????? (???????????? ????).

Index: ???? ??????? ???????? ?????? ???????, Index ?????????? ??? ?????????? ????????????? ? ???? ???????.

Shortcut: ?????????? ??????? ??????, ??????? ????????? ???????? ?????? ??????? ???????? ???? ? ??? ??????, ???? ???? ?? ??????????????.

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

NegotiatePosition: ???? ? ??????????????? ?????????? ?????????? ????????? ??? OLE-???????, ?? ?????? ???????? ?????????? ?????? ??????????? ???? ?? ??????, ????? ???? ?? ???? ????????? ???????.

Checked: ????? ?? ????? ???? ??????? ????????.

Enabled: ???????? ?? ????? ????.

Visible: ??????? ?? ??????.

WindowList: ?????? ????? ????????????? ??? ??????????, ????????????? ? ?????????????? MDI-?????????? (?????????????????). ????????? ??????? ?????? ??????? ? ???, ??? ????? ????????????? ?????? ???????? ????. (MDI-????????? - ??. ?????).

???? ?????? ???? ???????? ? ???? ??????????? ????????? ??? ?????? ?????? Next, Insert, Delete. ???????? ???????? ??????? ???? ????????? ?????? ? ???????????? ???????.

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

 


2. ???????? ??????????-?????????? ????

??????????-????????? ???? ?????????? ??? ??????? ?????? ??????? ???? ?? ?????-???? ???????? ??????????.

??? ????? ??? ??????? MouseDown. ??? ????????????? ??????? MouseDown, ?????????? ????????, ????? ??????? ?????? (???????? ???????). ? ??? ??????, ???? ?????? ?????? ?????? ????, ?? ?????????? ??????? ??????? PopupMenu ? ????????? ?????? ???? ???????? ??????, ??????? ?????????? ???????.

????????:

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

If Button = 2 Then

PopupMenu mnuFile

End If

End Sub

Button - ?????????? ????? ?????, ??????? ??????????, ????? ?????? ???? ???? ??????;

Shift - ?????????? ????????? ?????? SHIFT, CTRL, ? ALT ??? ??????? ?? ?????? ????;

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

?????? ?4: MDI-?????????.

1. ??????? MDI-??????????.

??????????? ??????????? ? VB ?????????? ??????? ?? ??????????? ????. ?????? ?? ???? ???? ????????? ?? ????? ???????? ?? ?????? ? ??? ?? ?????????? ?? ?????? ????? ????????????, ??????????????? ? ?????????????. ? ?????????? ?????? ???? ?????? ???????????? ????? ? ???????? ? ???? ??? ? ???????. ???? ??? ?????????? ?????????? SDI-????????? (Single Document Interface).
???????????? ???????????? ?????????? - ???????????????? ?????????, ??? MDI-????????? (Multiple Document Interface). ? ?????????? ????? ???? ???? ???? ???????????? ?????. ????????? ????? ????? ???? ?????????, ?.?. ??????????? ?????? ????????????. ???????????? ????? ???????????? ????? ????????? ??? ???? ???????? ???? ??????????. ??????? MDI-?????????? - Excel, Word ? ?.?. ? ??? ????? ??????? ????????? ????, ???????????? ????? ???? ? ??????? ???? ? ?????????????? ??? ????????? ???????????? ????? ??????? ????.
???????? MDI ????????? ???????????????? ????????? ? ???? ????????????:
1. ??????????? ???????????? ????? ??????-???????????, ??????? ?????? ??????? ????? ??????????;
2. ??????????? ???????????? ???????? ? ??????????? ???????????.
MDI-?????????? ????????? ???????????? ????????? ??????????? ????? ? ??? ?? ?????, ??? ??????????? ?????????????????? ? ???????? ????????. ????? ????, ????????? ????????? ????? ????? ??????????, ????????? ??????????? ? ??? ????? ?? ????? ?????????? ?? ????? ??????.

?????????????? ???????????? MDI-????:


?????????????? ???????? MDI-????:


2. ???????? ??????? ????????? ? MDI-???????????.
1. ??????? ????? ?????? - File\New Project.
2. ????? ???????? ???????, ?????????? ???????? ? ???? ???????????? MDI-?????. ??? ????? ?????????? ??????? ???? Project\Add MDI Form, ??? ??????????????? ???????? MDI Form ?? ??????????????? ???? ?????? Add Form.
3. ? ???????? ??????? MDI-????? ????? ?????????? ? ????? Forms, ??? ? ??????? ?????, ?????? ????? ????? ?????? ???????????.
4. ????? ????, ??? ??????? ????? ?????, ?????????? ?????? ?? ???????? ??? ? ?????????? ???????? ??????, ??????????? ???????. ??????????? ??????? MDI-????? ?????????? ????????? ??????????? ?????. ???? ?????? ??? ??????????? ?????? ??? ??? ???????? - AutoShowChildren ? ScrollBars. ???????? AutoShowChildren ??????, ???????? ?? ???????? ????? ????????????? ??? ???????? ????????????, ??? ???. ?? ????????? ??????????? ???????? TRUE. ???????? ScrollBars ??????????, ????? ?? ???????????? ?? ????????????? ?????? ?????????. ?? ????????? ??????????? ???????? TRUE. ??? ???? ????????, ?? ??????? ????? ???????? ???????? - Picture, ??????????? ????????? ?? ?????? ??? ????? ?????-???? ??????? ???????????.
5. ?????? ?????????? ???????? ???????? ?????. ???????? ????? - ??? ??????? ??????????? ?????, ?????? ???????? ???????? MDIChild ? ??? ??????????? True. ??? ?????????? ???????? ????? ?????????? ??????? ??????????? ????? (??????? ????????? ????????????? ??? ???????? ???????) ? ???????? ???????, ? ????? ? ???? ??????? ?????????? ???????? MDIChild=True. ? ???? ???????? ??????? ? ????? ????????? ???????????.
6. ????? ????? ?????????? ?????????? ? ???????? ????? ??????????? ???????? ??????????.
7. ??? ???? ????? ??? ?????? ?????????? ????????? ?????? ???????????? ?????, ?????????? ?????????? ????????? ????? ????? ????? ???? Project\Project Properties, ???? Startup Object.
?????? ???????? ????? ??? ?? ?????? ????????? ?? ????? ?????????? ?????????? ?? ???????, ????????? ? ???????? ??????????. ??? ?????????? ??????, ??? Windows ???? ?? ????????? ?????? ???????????? ??????? ? ????? ???????????? ???? ????????? ?? ????? ???????? ??????. ????? ????????? ???????? ????? ??????????? ? ?????? ???????, ?????????? ???????? ?????????? ??????? Load ??? ???????? ?????, ??? ?????????? ?????? ??????????? ??????? ? ???????????? ???????????? ?????? - ???????? ???? ??????? ??????? ???????????? ?????. ??????? ?????????? ????????? ?????????? ?????? ???????? ????? ? ?????? ??????????, ? ????? ?????????? ???????? ??????? Height ? Width ?????????? ??????????. ????????:
Private Sub Form_Load()
Me.Height=2745
Me.Width=3690
Me.Top=(mdiMain.ScaleHeight - Me.Height) / 2
Me.Left=(mdiMain.ScaleWidth - Me.Width) / 2
End Sub
????? ???? ??? ?????? ?????? ???????? ?????, ????????? ?????????? ??? ???????? ??????????? ???? ????? ?? ????? ?????????? ????????? ? ?????? ?? ?? ????? MDI-??????????. ??? ???????? ? ??????? ???? ????? ???????????? ????:
Dim NewFrm As New ???_????????_?????
NewFrm.Show
????????, ?????? ??????????? ??? ????????? ? ??????? ????????? ??????? ??? ?????? ?????? ?? ??????? ???? (????????, New). ???? ???????? ??????????? ??? ?????? ? ???????? ????????? ???????, ????? ??????? ???????, ??? ?????? ?????? ???? New ????????? ????? ???????? ?????.
??? ?????? ? MDI-???????????? ?????? ???????????? ??? ?????? ???????? ????? - Me ? ActiveForm. ??? ????? ????????? ??????? ?????????, ??????? ????? ???????? ?? ????? ???????????? ????????? ???????.
???????? ????? Me ???????????? ? ????? ????? ??? ?????? ?? ??? ????. ????? ???????, ???? ??????????? ??? ? ???????? ????? ??????? ? ?????????????? ????????? ????? Me, ?? ????? ???????? ? ????? ???????? ?? ?????? ?????? ?????????? ???????? ?????.
???????? ???????????? ????? ActiveForm ??????? ?? ?????????? Me. ? ???????? ActiveForm ???????? ?????? ?? ???????? ? ?????? ?????? ???????? ?????. ?.?. ? ??????? ???????? ActiveForm ?? ?????? ????????? ?? ????? ????????, ????? ??? ??????? ???????? ? ????????? ?????? ???????? ?????, ???? ?? ???? ?? ?????.
????????, ????? ??????? ????? ????? ???????? ?????. ?????? ???? ?? ?????? ???????????? ???????????? ?????, ???????? ? ????, ??? ? ???????? ???????? ????? ????? ??????? ????? ?????.
MdiMain.ActiveForm.Print ??? ????? ?????? ???????
???? ?????????? ??????? ??????????? ???, ??????? ?????? ???????? ? ?????? ???????? ???????? ?????, ??? ???? ????????? ? ??????? Activate ??? ???????? ?????. ??? ??????? ????????? ?? ??????? Load.

3. ?????? ? ????.
MDI-????? ????? ????? ????? ????, ??????? ????????? ?????????? ??????????? ??????, - ? ??????? ????????? ???? (??????????? ???? Menu Editor). ? ??????? ???? ???????????? ????? ???????????? ?????? ???????? ?????? ?? ???? ???????? ????????????????? ??????????.
? MDI-??????????? ???????? ????? ????? ????? ????? ????. ??? ? ???? ???????????? ?????, ??? ????????? ? ??????? ????????? ????. ??????, ??? ?????? ?? ????? ???????? ?????, ?????????? ????, ??? ???????????? ?? ??? ????? ???????? ?????, ? ???????? ???? ????????????. ???????, ??-?? ????, ??? ???? ???????? ???????? ????? ? ???????????????? ????????????? ? ???????????? MDI-?????, ????? ?????????? ????????? ????????, ? ??????: ????? ??????? ?????-?? ???????? ?????, ???????????? ?? ????? ??????? ? ???? ???????????? MDI-?????.
?????????? ??? ??????? ?????????? ????????, ????????? ? ??????? ????. ???? ?? ??? ??????????? ? ???????????? ???? ??????? ???????? ???? ? ???? ???????? ?????, ??????, ???? ?????? ?????????????? ? ??? ??????, ???? ? ?????????? ????????? ???????? ????, ??????? ??????????? ????, ??-?? ??????????? ??????????? ????????? ????????.
?????? ??????? - ???????? ? ???? ???????????? ????? ??? ??????, ??????????? ???????? ?????? ? ???????? ????????? ??? ????. ??? ??????????? ?????? ??????? ???? ??????? ???????????? ??????? Activate ? Deactivate, ? ????? ??????? Unload (??? ???????? ????????? ????).
???????????, ?????????? ???????? ????? ???? Edit ??? ????????? ????. ?????????? ??? ???????? ???? ?????? ??? ?????? Edit ???????? Visible False. ???????????, ??? ?????? ???? mnuEdit. ??????????:

1. ? ??????????? ??????? Activate ????????? ???? ???????? ????????? ???: ???_MDI_?????.mnuEdit.Visible = True
2. ? ??????????? Deactivate ????????? ???? ???????? ???: ???_MDI_?????.mnuEdit.Visible = False
3. ? ??????????? Unload ????????? ???? ???????? ???: ???_MDI_?????.mnuEdit.Visible = False


4. ?????? ? ????????? ???????.
??? ???? ???????????? MDI-?????????? ??????? ? ???, ??? ? ????????? ????? ????? ????????? ????????? ???????. ? Visual Basic ????????????? ????????, ?????????? ?????? ???????????? ? ???????? ?????, ???????? ? MDI-?????. ? ????? ????????? ????? ????? ????????????? ???????? ??????????????? ?????????????? ???????? ????. ????? ????? ??????? ????, ? ??????? ????? ?????????? ?????? ???? ???????? ???????? ????.
???? ?? ??????? ??????????? ???????? ??????? ?? ???? ??????????? ?? ?????? ?????? - ?????? ?????? ?? ?????????? ?? ??????. ??? ????????? ???????????? ?????????? ? ????? ????? ? ??????? ?????? ????. ??? ?????????? ?????????????? ???????? ???? ?????? ???????????? ???????????? ????? MDI-????? Arrange, ??????? ????? ???? ???????? - ?????????, ??????????? ????? ???????? ?????????? ??????????? ???????? ????.
MdiMain.Arrange vbCascade
???????? ????????:
1. vbCascade - ???????????? ???????? - ?????? ?????????????????? ????? ??????? ????????? ??-?? ??????????.
2. vbTileVertical - ?????? ?????????????????? ????? ????????? ?????? ????????????, ? ??? ?????? ???????? ?????? ????????????. ???? ???????? ???? ????? ?????, ??? ????? ????????????? ? ????????? ?????.
3. vbTileHorizontal - ??????????, ?? ?? ???????????.
4. vbArrangeIcons - ??????????? ???? ???????????????? ???? ????????????? ?? ??????? ???? ???????????? ?????.
?????? ????? ???????????? ???? ?????????? ? ???? Window MDI-?????. ?????? ????? ????????????, ??????? ?????????????? ? ?????????, ???????? ? ????????? ????? ????.
??? ???? ?????? ?????????? ??????? ? ???????? ????? ?????????? - ???????? ?????? ???????? ???????? ????. ?????????????? ????????? ?????? ???????? ???? ?????????? ?? ????? ???????? ???? ???????????? MDI-?????. ??? ???????? ?????????? ???????? ?????? ???? WindowList ? True (????????).

5. ??????????? MDI-??????????.
1. ?????? ??????????? ???????? ???? ???????? ????????? ????? ??????????? ??????. ???? ?????????? ????????? ????, ?? ???? ?????? ? ???????? ?????????? ????????? ?????????? ? ??????????? ???.
2. ???? ???????? ? ???????????? ???? ????? ???? ??????? ????, ?????????? ??????? ??? ?? ????????? ? ???????????? ?????. ??? ???? ???????? ??????? Private ?? Public. ????? ??? ????? ??????? ????? ???????????? ??? ????????????, ??? ? ???????? ????.
3. ???????? ??? ????????? ???????? ?????????? ? ???????????? MDI-?????. ??? ???????? ???????? ????? ????????? ???????????? ????????? ???????? ??????????, ?? ??????? ?????????????? ??????????? ??????????? ??????.

6. ??????????????? ??????: ???????? MDI-??????????.
???????: ??????? MDI-?????????? - ?????????? ????????? ???????? (? ??????? ???????? TextBox), ????????????? ????????? ? ???? ??? ??????????? ???????? ????, ?????? ???????? ????, ?????????????? (????????? ?????????) ???????? ???? ????? ???? ????????????? ????, ?????????????? ????????? ???????? TextBox? ????? ?? ?????????? ???????? ????????? ????. ?????? ???? - File (New, *Close, Exit), *Edit (Change caption), *Window. ?????????? ?????????? ?????? ???? ?????? ????????? ??? ?????????? ? ??????????? ?? ??????? ????????? ????. Change Caption ?????? ????????? ???????? ????? ????? ????????? ??-MDI ??????, ? ??????? ????????? ????????????? ? EditBox?. ????????? ??? ?????? ??? ?????????? ????????????.

?????????? ?????????? Drag&Drop ?????????? VB

 

?????? ???, ??????? ? Windows, ?? ???????????? ? ??????????? Drag&Drop (?????????? ? ????????). ???????????? ????? ? ?????, ??????, ??????, ??????????? ?? ???????? ? Drag&Drop. ????? ???????, ??? ?? ???? ?????????? ????????? ?????? ? Windows.

??????? Drag&Drop ??????????? ? ???????? ??? ????????? ?????? ???????????? ? ???????? ???????? ?????? ? ?????? ?????????? ? ?????? ??? ? ???????? ?????? ??????????. ???? ??? ????????? ?????????? Drag&Drop, ????????, ??????????? ? ??????????? ?????? ? ?????????? Windows ??? ???????? ?????? ?????????? ????? ??????????? ????? ?? ???? ??????????.

 


1. ??????? Drag&Drop

? ???????? Drag&Drop ????????? ??? ???????: ??????-???????? ? ??????-????????. ??? ??????? ?????????, ? ?????? ?????????? ?????? ????????, ??? ???? ???? ?????? ?????? ????. ? ?????????? ???? ?????? ??????????? ? ??????? ?????????, ??? ???? ??????? ????????? ?????? ????.

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

 


2. ??????? Drag&Drop

??????? ??????????????, ??? ???????, ?????????????? ? ????????? ????????? ??????? MouseDown. ????? "?????????" ????????? ?????? ? ??????? ??????? ????, ???????????? ????? Drag. ????? ????? ?????? ?????????? "???????????" ? ??????? ????, ???? ?????? ???? ?? ????? ????????.

 

??????: ??????? ?????????????? ??? ???????? ?????????? FileListBox

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

If Button = vbLeftButton Then

Filel.Drag vbBeginDrag

End If

End Sub

 

????? Drag ????? ???? ?????????????? ???????? Action, ??????? ????? ????????? ???????? vbCancel = 0, vbBeginDrag = 1 (?? ?????????) ? vbEndDrag = 2.

????? ??????????? ?????? ???????? ? ??????-????????, ??? ??????? ??? ????????. ??? ?????? ??????????? ????? ?????????? ?????? ???? (??????? MouseUp). ?????? ????? ??????????, ??? ?????? ??????? MouseUp ? ?????? ?????????????? ????? ??????????? ??????? DragDrop (??? ?????????? ???????????????? ??????? ??? ???????? ???????????).

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

 

??????: ??????????? ??????? (ListBox) ?????????? ???????? FileName ?????????? ??????? FileListBox, ???????? ???????? ????? ???????? ? ??????

Private Sub Listi DragDrop(Source As Control, X As Single, Y As Single)

Listl.Add.Item Filel. FileName

End Sub

????? ???????? ??????????? ??????? ??????? ??????????, ???????????? ??? ??????? ?? ??? ??????????????? ??? ??????? ????. ????????, ?????? "+" ??? ???????? ???? ????????? ??????????, ??? ???? ? ?????? ????? ??????????. ? Visual Basic ????? ????????? ????? ??????? ???? ?? ????? ???????? ??????????????. ??? ?????, ????? ??????? MousePointer ? Mouselcon, ?????????? ??????????? ???????? DragIcon. ??? ???????? ????? ????????? ???????????, ??????? ????? ?????????, ???????????????? ???????? LoadPicture.

???????, ??? ????????? ???????? ??????? ???????? ?????? ????, ????????? ??? ??????????? ??????? ???????. ??? ??????? ????? ???????? ? ???????? MouseMove ? ?????????? DragOver (??? ?????????????? ??????? ??? ???????? ???????????). ????????? ????????? ????? ??????? ?????????? ?????? ?????????. ???????? Source ???????? ????????? ?? ??????????? ??????. ???????? State ?????????? ????????? ??????? ???? ?? ????????? ? ??????? ? ????? ????????? ???????? vbEnter, vbLeave ??? vbOver. ????????? X ? Y ???????? ??????? ?????????????? ? ???????????? ??????? ??????? ????

 


3. ?????????????? ??????????????

????? ? ??????? ???????? ? VB ???? ???????? DragMode, ??????? ?????????, ????? ??????? ??????? ????? "???????????????": ????????????? ??? ??????? (vbManual ??? vbAutomatic). ??? ?????? ?????? ??????? ????? "?????????" ??????????? ? Drag&Drop. ??? ?????????? ?????????????? ?????????????? ??????? ??????????? ?????? ???? ????? ??? ???-?????? ?????????. ?????????????? ?????????????? ?? ?????? ????? ???????????? ????? ??????, ??????? ??????? ???????? ? ?????? ?????? ? ?????????????? ?????? Drag.

 


4. ?????????????? ? ?????????????? OLE

????? ????, ???????? ??????????? Drag&Drop ????? ????????????, ????????, ????? Explorer ? ????? ???????????. ?????? ??? Drag&Drop'? ?????????? OLE Drag&Drop. ?????????????? ? ?????????????? OLE-?????????? ?????????? ?? ?? ?????? ???????? ????????? ? ?????????, ??? ? ??????????????, ??????????? ?????????. ?????? ? ?????? ?????????????? ? ?????????????? ????????? OLE ???????????? ?? ??????? ??????????, ? ?????? ??????, ??? ????????? ??????????? ????? ??????? ? ?????? ????????????, ????????? OLE-????????? Windows.

??? ????????????? ?????????? OLE Drag&Drop ? Visual Basic ????? ???????????? ???? ?????????????? ?????????????? ????? ?????????? ?????????? ??? ????????????, ???? ???????????????.


5. ?????????????? ?????????????? ? ?????????????? OLE

???????????? ?????????????? OLE-?????????????? ?????????? ??????. ???? ??????? ???????? ??? ????? ???????? ?????????? ?????? ???????? ?????????????, ?? ???????? OLEDragMode ????????????? ???????? vbOLEDragAutomatic. ? ??????? ???????? OLEDropMode ????? ?????? ????? ?????? ??? ???????-?????????.

???????? ??????? OLEDragMode ? OLEDropMode ????? ?????? ??? ??? ?????????? (???? ???????), ??? ? ??? ?????????? ??????????:

 

??????: ??? ?????????? ?????????????? ????? OLEDragMode ? OLEDropMode ??? ???????? ?????????? TextBox. ? ?????????? ????? ????????? ?????????? ? ????????? ???? Textl ?????? ?????? ????? ?????????? ? ??????? ???? (????????, ? ?????? ????????? ????).

Private Sub Form_Load()

Text1.OLEDragMode = vbOLEDragAutomatic

Textl.OLEDropMode = vbOLEDropAutomatic

End Sub

?????? ?????????????? OLE-?????????????? ???????????? ?? ??? ???????? ??????????. ????? ??????, ???????????? ?? ?????? ??????? ?????????? ?????????????? OLE-??????????????, ??????? ?????????? ? ???? ???????, ???????????? ?? ? ?????? ????????? ???????? ??? ??????? OLEDragMode ? OLEDropMode ???????? Automatic.

??????? ???????? ??????? ????????? ? ???????????? ? ?????????? ?????????, ? ??????????? ?? ???? ???????? ??????????. ???? ?????????????? ?????????????? ?????? ??? ??????? ?????? ????, ?? ?????????, ??? ?????? ???????????? ?? ???????-????????? ? ??????-???????? ? ?? ?????????? ???????? ???????????? ?????? ? ????????? ??????? ???????. ???? ?????????????? ??????????? ??? ??????? ??????? [Ctrl], ?? ?????? ?????? ??????????.

 


5. ??????????????? ?????????????? ? ?????????????? OLE

???? ??????? ??????? OLE-?????????????? ?????????? ?????-???? ??????? ?????????????????, ?? ?????????????? ???????? ??????? ?????????????????. ??? ????? ?????????? ? ??? ??????, ???? ?? ????????? ? ?????????? ??????????, ??????? ?? ???????????? ?????????????? OLE-?????????????? (CommandButton, Label, Checkbox, OptionButton, Frame, DriveListBox).

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

????????:

OLEDragMode ???????????? ??????? ?????????? ? ???????? ???????-?????????.

OLEDropMode ???????????? ??????? ?????????? ? ???????? ???????-?????????.

??????:

OLEDrag ???????? ??????? ??????????????.

???????:

OLEDragDrop ?????????? ??? ?????????????? ???????-?????????

OLEDragOver ??????????, ????? ???? ????????? ?????????? ??? ??????.

OLEGiveFeedback ?????????? ????? ??????? ??????? OLEDragOver ? ???????????? ?????????? ???????? ????? (????????, ????????? ??????? ????).

OLEStartDrag ?????????? ??? ?????????? ?????? OLEDrag ??? ??? ????????????? ??????????????? OLE-??????????????.

OLECompleteDrag ?????????? ????? ??????????? ???????-????????? ? ??????-???????? ??? ?????????????? ????????? ? ?????????? ??? ??????

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

 

??????-????????

??? ? ??? ??????? ??????????????, ??????? OLE-?????????????? ?????????? ??????? ?????? OLEDrag:

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

If Button = vbLeftButton Then

Textl.OLEDrag

End If

End Sub

????? OLEDrag ?? ????? ?????????? ? ?? ????????? ??????????????? ????? ??????, ? ?????? ???????? ??????? ??????????????.

 

 

??????-????????

?? ??????????? ??????? ???????? OLEDropMode ?????? ????? ???????? vbOLEDropManual. ????? ?????? ???????????, ??? ????????? ?????????? ??????? OLEDragDrop. ????? ????, ?????????? ???????? ?????????? ??????? OLEDragOver, ? ??????? ??????? ????????? ??? ??????????????? ?????????? ? ??????? ???????? (????????, ??? ?????? ??? ????? ???? ??????????? ??? ???????????).

????????? ??? ??????????????? ?????????? ????? ? ??????? ?????? GetFormat ??????? Data, ??????? ???????? ?????????? ??????? OLEDragOver.

 

?????? ????????:

If Data.GetFormat (vbCFFiles) Then ...

?.?. ???????? ?????????????? ???????????? ??????????????? ????????? ? ????? GetFormat ? ????????? ?????????? ? True. ????? ???????????? ????????? ???? ????????:

vbCFText - ???? ??? ????????? ????????? (*.txt) ??????.

vbCFBitmap - ???? ??? ????????? bmp-??????.

vbCFMetafile - ???? ??? ????????? wmf-??????.

vbCFFiles - ???? ??? ????????? ?????? (?????).

vbCFRTF - ???? ??? ????????? RTF-??????.

 

????? ???????? ?????????? ????????? ???????? ? ??????? ????????? ????????? ??????? OLEDragOver Effect.

????????? ?????????:

vbDragEffectNone - ?????? ?? ?????????? (???????????? ??? ?????? ?????-???? ???????? ??? ???????? ??????? ??????????????? ??????).

vbDragEffectCopy - ???????? ??????? ?? ????????? ? ????????.

vbDragEffectMove - ?????????? ??????? ?? ????????? ? ????????.

? ??????????? ?? ???????? ????????? Effect ????? ???????????? ????????? ??????? ????.

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

??? ????????? ??????? ????? ?? ??????????????? ?????????? ???????? ? ??????? ????? For Each ?? ????????? Files ??????? Data (Data - ???????? ??????? OLEDragDrop).

?????? (?????? ??????? ? ?????? ????? ??????? ?? ??????):

For Each fff In Data.Files

lstList1.AddItem fff

Next fff

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

 

?????? ???????????????? ?LE-??????????????: ?? ????? ?????????? textBox. ??? ??????????? ?????????? ?????? ?? ??????????, ????? ??????????? ? TextBoxe

 

'1.???????? ?? ????? TextBox. ?????????? ??? ???????? OLEDropMode ? "Manual", ???????? "MultiLine" ? "True".

'

'2.???????? ???????? ?????? ??????

Sub DropFile(ByVal txt As TextBox, ByVal strFN$)

Dim iFile As Integer

iFile = FreeFile

Open strFN For Input Access Read Lock Read _

Write As #iFile

Dim Str$, strLine$

While Not EOF(iFile) And Len(Str) <= 32000

Line Input #iFile, strLine$

If Str <> "" Then Str = Str & vbCrLf

Str = Str & strLine

Wend

Close #iFile

txt.SelStart = Len(txt)

txt.SelLength = 0

txt.SelText = Str

End Sub

 

'3.???????? ???????? ? ??????? OLEDragOver.

Private Sub Text1_OLEDragOver(Data As _

DataObject, Effect As Long, Button As Integer, _

Shift As Integer, X As Single, Y As Single, State _

As Integer)

If Data.GetFormat(vbCFFiles) Then

Effect = vbDropEffectCopy And Effect

Exit Sub

End If

Effect = vbDropEffectNone

End Sub

 

'4.???????? ???????? ? ??????? OLEDragDrop.

Private Sub Text1_OLEDragDrop(Data As _

DataObject, Effect As Long, Button As Integer, _

Shift As Integer, X As Single, Y As Single)

If Data.GetFormat(vbCFFiles) Then

Dim vFN

For Each vFN In Data.Files

DropFile Text1, vFN

Next vFN

End If

End Sub

 

'?????? ????????? ??????????, ???????? ?????????, ???????? ????????? ????????? ?????? ? "??????????" ?? ? TextBox. ?????? ?? ?????? ????? ?????? ? ????????? ????.


?????? ? ???????? ? Visual Basic.

 

?????? ? VB.

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

?????? - ??? ????????? ??????.

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

 

????????? ???:

1. ???????????? (???????? ??????????). ???????, ????????? ?? ???? ?????? ???????? ????? ????? ??????. ???????????? ????????? ???????????? ??????? ???????? ?????????? ???????? ????????????????, ?? ???????? ??????? ?? ????????????? ???????;

2. ????????????. ????? ?????? ????????? ?? ???? ????????????? ? ????? ????????? ??? ???????? ? ??????. ? ?? ?? ?????, ?????? ??????? ????? ????????? ???????? ? ??????. ???????????? ?????? ??? ?????????? ???????????? ????.

3. ???????????. ??????????? ???????? ???????????? ??????????? ??????, ??????? ????? ????????? ????????? ???????? ? ?????? ????????. ????????, ? VB ???????? + ????? ?????????????? ??? ??? ???????? ?????, ??? ? ???? ???????????? ?????.

4. ???????????????. ??? ??????????????? ???????? ???????? ?????????????? ?? ?????????, ????????????? ??? ????????????????. ??????? ?????????? ??????????????? ??? ????, ????? ????? ????????? ??????? ??????? ?????????? ?????.

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

 

?????????? ?????? ? VB ????????? ? ??????? ?????? ???????. ?????? ??????? ????? ????????? ????????? ????? ?????????:

?????? ??????? ???????? 2 ??????????? ???????:

??? ??????? ???????? ????????? ???????????? ? ???????????.

? ??????? VB ?????? ?????? ????????????? ??????????? ????????? ????????? ??????????? ?????? ? ????? ????? ?????????, ?? ????????? ?????????? ??????????.

?????????? ?????? ?????????????? ????? ???? Project/Add/|Class Module. ??? ???????? ?????? ?????? ?? ?????? ????????? ??? ???????? ?????????? ??? (???? Name), ?.?. ?? ??????? ?????? ???????????? ??? ??? ? ??????????? ???? ??? ???????? ???????? ??????. ???? ?? ???????? ?????????? ???????, ?? ? ???????? ???????? ????? ?????? ?????? ????????????? ???????????? cls.

??? ???????? ???????? ???? Active X ? ??????????? ?????????? ?? ? dll ??? exe ?????, ???????? ????? ???????????? ????? ?????? ??????????.

??????? Active X dll ? exe ?? ??????? ?????? ??????????? ? ???, ??? ?????????? Active X ????? ????????? ??? ??????? ?????????????, ?.?. ?????????????? ???? ??????? ??? ????????????? ? ?????? ???????????. (??????? Active X ?????????? - ??? ??????? ???????: Word, Exel,...)


1.1. ?????????? ? ????? ???????.

?????????? ???? ???????? ??????? - ?????????? ?????????? ?????????? ??? ????????? ?? ? ?????? ?????????? ?????? ??????.

? ?????? ?????? cls1: Public Prop1 As String

? ?????: Dim a as new cls1

a.Prop1="1"

??????, ? ?????? ?????? ?????????? ?????????? - ??? ?????????? ?? ???????? ?????????? ????????? ???????? ?? ????????????, ??? ?????-???? ?????? ???. ??? ????? ??????? ???????, ????? ????? ?? ????? ?????????? ?? UDT (????, ????????? ?????????????). ??????? ???????? ???????????????? ???????? ?????? ??????, ??????? ??????????? ? ????????????? ???????? ???????. ??? ????????? ????????? ????? ??????????? ??? ?? ????? ??????????.

??? ????? ????? ????? ???????????? Class Builder - ??????, ?????????? ? ????? ?????????? Visual Basic, ??????????? ??? ????? ?????? ??????, ???????? ? ??????? ??????.

??????? ??? ????? ????????? ??????? - Project/Add Class Module/VB Class Builder. ????? ?????? ???????? ???? Class Builder'?.

????????? ???? File/New/Class ??? ?????? Add New Class ?? ?????? ???????????? Class Builder'?, ???????? ????? ????? ? ???????. ??? ????? ?????????? ??????? ??? ??????, ? ?????? Based On ????? ??????? ??? ??????, ?? ??????? ??????? ??????????? ?????. ?? ??????? Attributes ????? ?????? ???????? ?????? ?????? (???????????), ? ????? ??? ??????????? ????? ??? ??????? ??????.

????? ????? ????????? File/New/Property, Method ??? Event ????? ????? ???????? ????????, ????? ??? ??????? ? ?????????? ??????. ????? ????? ???????????? ??????????? ?????? ?? ?????? ????????????.

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

v Public Property (Let, Get, Set) - ????????? Private ?????????? ????????? ???? ? ??? ??? ??????????? Public ???????? ? ???????? ????? Get, Let ??? Set.

? Let - ?????????, ??????? ??????????? ???????? ????????. ????????????? ???????? ??? ??????? Private-??????????, ?.?. ??? ???????????? ????? ???????? ??????-???? ???????? ??????????? ??????????? ???, ? ??????? ?? ????????? ?????????? ???????? ?????? ????????????? Private-??????????. ????????????? ????????? ????? Let ???????????, ??? ??? ? ???? ?????? ??? ?????????, ??? ?????? ????????? ???????? ?????????? ??????? ???????? ????????.

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

? Set - ?????????, ??????? ????????????? ???????? ??? ??????-???? ???????. ????????? Set ???????????? ?????????? Let, ?? ???????? ?? ???????? ????????, ? ?????? ?? ??????.

?????? ? ???? ???? ???????? Let, Get, Set ???????? ???????? ????? ??????? ????????? ??? ????????.

v Friend Property (Let, Get, Set) - ??????? ????????, ????????????? ?????? ???????? ??????? ???????. ??? ???????? ????? ???????????? ?????? ?????? ?????? ????? ???????.

v Public Variable - ?????? ??????? Public ?????????? ??? ???????? ??????? Let, Get ??? Set ??? ???.

v Default Property - ???????? ?? ?????????. (? Label - Caption, ? TextBox - Text). ?????? ??????? ?????????? ????? ????? ????????, ??????? ?????? ???????????? Visual Basic, ???? ??? ???????? ? ???? ???? ?? ???????.

Textl = "Hello" '(??????????? Textl.Text = "Hello")

???????? ?????-?????? ???????? Public Property (Let, Get, Set). ???????? Class Builder, ?? ?????? Update... ???????? ??.

? ???????? ??????? ???????? ????? ????? Class Modules ? ? ??? ??? ?????? ??? ????????? ?????? ??????. ???????? ???? ?????? ?????? ??????? ?????? ?? ?????.

? ?????? ?????? ?? ??????? ?????????? ?????? ???????? ? ??? ??????????? ?????? - Let ? Get. ?? ?????? ????? ???????? ??? ???? ???????? ??? ????????? ??? ??? ???? ????????. ????????????? ???? ???????? ????????? ??????????? ???????????? ? ??????? VB.


1.2. ?????????? ? ????? ???????.

??????????, ????????? Class Builder, ????? ??????? ??????. ? ???? Name ??????? ??????? ??? ??????, ? ???? Return Data Type - ??? ?????? ????????????? ???????? (???? ????? ?????? ?????????? ??????). ???? ???? Return Data Type ???????? ??????, ????? ??????? ????????? Sub. ???? ??????? ??? ??????, ????? ??????? ????????? Function. ? ?????? Arguments ??????????? ?????? ?? ?????? + ????? ???????? ???????? ?????? ? ????????? ??? ????? ? ???? ??????. ???? ??? ???? ?????????? ?????? ByVal, ???????? ????? ???????????? ??? ???????? (ByVal).

Class Builder ????????? ?????????????? ???????? ???????, ?????? ?? ??????? ?????? Public ??????. ????? ??????? Private (?.?. ??????????) ?????, ???????? ??? ? ??????? Class Builder ? ???????? ???????????? ????????? ? Public ?? Private. ??? ???????? ??????? ? ????? ??????????? ????????? ??? ???????.


1.3.?????????? ? ????? ???????.

??? ??????? ?????????? ????? ???????????? ??????? ? ?????, ? ??????? ?? ?????????, ??? ? ??????, ????????? ?? ?????? ?????? ??????, ???????? ????????? ??????? ? ????? ??? ??????, ? ??????? ?? ????????. ??? ???? ??? ?????? ?? ?????? ???????? ??? ???? ??? ????? ??????? ??? ??????????. ??? ??????? ?????????????? ? ????? ?????? - Initialize ? Terminate. ?????????????? ??? ????????? ??? ???????? ? ??????????? ??????? ??????.

????????? Class Builder, ????? ???????? ? ????? ??????? ? ?? ?????????. ??? ????? ?????????? ???????? ??????? ? ?????? Class/New/Event. ???????? ?? ??? ???? ??????? ????? ?????? ?? ?????? ????? ?? ?????? ? ??????? ????????? RaiseEvent. ????????: RaiseEvent FindWindStatus(?????????)

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

??? ????????????? ??????? ????????? ?????????? ?????? ???? ????????? ? ?????????????? WithEvents (??. ???? ???????? ???????? ??????) ? ??? ????????????? ????????? ????? New ? ??????????.

Dim WithEvents obj1 As cls1


1.4.?????????? ? ????????????? ????????.

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

?????????? ??? ??????? ?????????? ???????? ??????:

- ?????? ????????

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

<??????? ?????????> [WithEvents] <??? ????????? ??????????> As <??? ??????>

??????? ????????? ?????????? ?????? ???????? ????????? ?????? ??? ?????????????, ?.?. ??????????? ?? Nothing. ????? ??????? ??????? ?????? ?????????? ???????????? Set <??? ????????? ??????????> = New <??? ??????>. ????? ????? ??????? ?????? ??? ?????????? ????????? ?????????? ?????????:

<??????? ?????????> [WithEvents] <??? ????????? ??????????> As New <??? ??????>

WithEvents ???????????? ?????, ????? ? ?????? ???? ??????? ? ?? ?????? ?? ????????????. ???? ?? ?? ?????? ???????????? ??????, ???????? ????? WithEvents ????? ????????.

??????:

Dim clsOne As COne

Set clsOne = New COne

? ?????? ??????, ????? ??????? ?????????????? ? ??????? ????????? Set.

??? ?????

Dim clsOne As New COne

? ?????? ??????, ????????? ?? ?????? ????? ?????? ?????????? ? ????????? ?????????? clsOne. ????????? ?????? ????????? ? ?????? ??????? ?????????. (?????? ???????? ??? ??????).

 

- ??????? ????????

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

??????:

Dim clsOne As Object

Set clsOne = New COne

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


1.5. ???????? ??????? ??????.

??? ???????? ?????????? ?????? ?????????? ????????? ????????? ??????????, ??????????? ?? ???? ???????? Nothing. ??? ???? ????????????? ??? ????????? ? ??? ???????, ? ????? ?????????? ??????? Terminate.

 


2. ??????????????? ?????? - ????????? ?????? Splitter.

??? ???????????? ??????? ?????, ??????????? ???????????? ??????????? ????? ??????-???? ?????????? ?????????? ?? ?????. ??? ?????????? ????????? ???? ????? ????? ?????????? ??????????, ?????? ???? ????????????? ? ??????????????? ?????????????? ??????? (???? ?? ??????????? ????????) ? ??? ??????? ?? ????? ?????? ???? ????????? ??????????? ??????????? ????? ? ??????, ????? ?????????????? ??????? ????????? ??????????. ????? ????? ????? SplitMe ? ???????????:

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

?????????, ??????????? ?????? ????? ????????? ?? ??????? ?????: P:\PREP\System Program|VB|Sample\Splitter|Splitter1.

??? ?????????? ?????????? ???? ?????, ??????? ? ???? ??????? onLeftBound ? onRightBound, ?????????? ??????? ?????, ????? ??????? ?????? ??? ??????? ???????? ?????????? ?????????? ?????? ?????-???? ??????????? ????????. ? ??????? ??? ??????? ?????????????? ?????? ?????? ? ??????????? ??????? MouseMove. ??? ???????????? ?????????? ??? ??????? ? ???????? ????? ??????? onLeftBound ? onRightBound, ??????? ?? ????????? ?????, ? ????? ???????? ??????????? ???? ??????? ? ????? (????????, ??????????? ??????????? ?? ???????? ????? ???? ???????? ? ??????? ???????????????? ?????? (??. ????).

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

??????????: ????? ? ???? ?????????? ??? ?????? ?? ? ??????? Class Builder, ??????? ?? ?? ??????? ???????????? ??? ??? ?????????? ????? ???????. ??????? ????? ???, ??? ???????? ?????? ??? ???? ????????, ???????? ??????? ????? ? ??????? Class Builder'? ? ??????????, ??? ??????? ????????, ?????? ? ??????? ???????.


?????????? OLE.

 

 

?????? OLE ??? ?????????? ?? Object Linking and Embedding (?????????? ? ????????? ????????). OLE - ??? ?????, ??????????? ????????????? ?????? ?? ?????? ?????????? ? ?????? ??? ?????????? ?? ? ?????? ??????????. ??? ?????? ?????????? ??????????? ????????? ????????? Microsoft Office. ????????, ????????? OLE ????? ????? ???????? ??????? Excel ? ???????? Word. ??????????, ?????????????? ?????????? OLE, ????????? ???????????? ???????? ???? ?????????? ?? ???????, ?? ?????? ?? ????????? ?????????? ???????? ?????????.

??????????? ????????????? OLE ??????????:

1. ??????????? ????????????? ????????? ???? ???????? ?? ??????? ????????????????? ??????????.

2. ???????? ???????????????? ???????. VB ????????? ???????????? ????????? ?????? ???????????? ??? Word ? Excel, ??? ????? ???????????? ? ????? ?????????.

3. ?????????????? ???????? ??????????. ????????? ????? ????????? ??????????????? ?? ???????????? ???? VB.

4. ?????? ? ??????????. OLE-??????? ????? ???????????? ? VB ??? ??????? ? ??????????, ??????????? ? ???????????? ??????.

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

 

???? ?????? ???????

?????? ?????? ????? ??? ????????? ???? ??????: ?????? ????????????? (Presentation Data, PD) ? ???????????? ?????? (Native Data, ND). ?????? ????????????? ?????? ??? ????????????? ?????????? ???, ??? ??? ???????????? ? ???????????? ??????????. ????????, ??????? Excel ??? ?????? ?????? ???? ???????????? ? ????????? ?????. ???????????? ?????? - ??? ?????????? ??????????, ?.?. ?????????? ???????.

??????????

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

?????????

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

 


1. ??????? ?????????? OLE Container

???????? ??????? ?????? ????????????? OLE ? ????? ?????????? - ??? ?????????? ???????? ?????????? OLE Container ??? ?????? OLE. ???? ??????? ?????????? ????????? ?????????? ??? ????????? OLE-??????? ? ???? ?????????.

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

 

???????. ?????? ??????? OLE Container .

?????

???????? Action

????????

CreateEmbed

0

??????? ?????????? ??????

CreateLink

1

??????? ????????? ??????

Copy

4

???????? ?????? ? ????? ??????

Paste

5

????????? ?????? ?? ?????? ??????

Update

6

??????????????? ??????? ?????? ?????????? ???????

DoVerb

7

????????? ?????? ??? ???????????? ???????? (????????, ??? ??????????????)

Close

9

????????? ??????

Delete

10

??????? ???????????? ? ?????????? ??????

SaveToFile

11

????????? ?????? ? ?????

ReadFromFile

12

????????? ?????? ?? ?????

InsertObjDIg

14

?????????? ?????????? ???? Insert Object Dialog

PasteSpecialDIg

15

?????????? ?????????? ???? Paste Special Dialog

SaveToOlelFile

18

????????? ?????? ? ??????? OLE 1.0

???????????? ??????? ???????? OLEDropAllowed. ???? ??? ????? ???????? True, ?????? ????? ?????? ????? ?? ??????? ?????????? ? ??????????? ? ?????? ????? ? ??????? ?????????????? (Drag & Drop). ????? ???????? ?????, ????????, ????????? ??????????? ?? ?????????? ? ??????? ?????????? OLE Container.

 

???????? ??????????? ??????? ???????????? ????? CreateEmbed.

CreateEmbed sourcedoc, class

??? ?????? ????? ?????? ?????????? ??????? ??? ?????? ??????????? ???????:

OLE1.CreateEmbed " ", "Word.Document"

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

CreateLink sourcedoc, sourceitem

????? ????, ???????? sourceitem ?????? ????????? ?????? ?? ??????? ? ???????, ???????? ?? ??????????? ??????:

OLE1.CreateLink "D:\EXCEL\TERMIN.XLS", "C1R1"

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

fh = FreeFile

Open "?:\DATA.OLE" For Binary As fh

OLE1.SaveToFile fh

Close #fh

???????? ???????? ???????????? ??????????? ??????? ??? ?????? ?????? ReadFromFile.

Open "?:\DATA.OLE" For Binary As fh

OLE1.ReadFromFile fh

Close #fh

 


2. ??????? OLE ??? ???????? ??????????

?????? ????????????? ???????? ?????????? OLE Container Visual Basic ????????? ???????? ????? ??????, ?????????? OLE-?????????????, ??????? ??? ?? ?????? ???????????? ? ???????????? ??? ??????? ??????????. ??? ?????????? ????? ????????? ?????????? ??????? ????????? ??????? Components ???? Project, ? ????? ?? ??????? Insertable Objects ??????????? ???? Components ??????? ??? ??????????? ???????. ????? ?????????? ??????? ??? ?????? ?????????? ?? ?????? ???????????? Visual Basic, ? ??????? ??????? ?????? ????? ???? ??????? ? ????? ??? ??????? ??????? ??????????


3. OLE Automation

????????? ??????????? ????????????? ???????? OLE ??? ????????? ??????????, ????????? ??????????? ????????????? ?????????? OLE Automation. ??? ?????????? ????????? ???????? ? ?????????? ????????? ??? ? ?????????? ??????????. ???, ?? ?????? ???????? ? Visual Basic ? ?????????? Word ??? Windows ????? ??? ? ????????? TextBox. ????????? OLE Automation, ????? ??????????? ?????????? ????????? ??? ?????? ??????.

 


4. ???????? ??????? OLE

?????? OLE ????????? ? ??? OLE Automation. ?? ? ???? ?????? ?? ????? ??????? ?????????? OLE Container. ????? ?????? ??????? ????????? ?????????? ? ????????? ?? ?????? ?? ??????. ??? ????? ? ??????? ??????? References ???? Project ?????????? ???????? ??????? ?????????? ??????? ???????? ? ?????????? Visual Basic, ????? ???? ??????? ??????? ?????????? ?????? ?????????? ? ????? ????.

Dim ww As New Word.Application

OLE-?????? ????? ?????????? ?? ?????? ?? ??????????, ?? ????? ?? ????? (????????, *.DOC, *.XLS). ??? ????? ????????????? ??????? Get0bject, ??????? ?????????? ?????? ?? ?????? ?? ?????:

Set variable = GetObject([filename][, class])

Dim DB As Object

Set DB = GetObject("C:\TEXT\ACCOUNT.DOC", "Word.Document")


5. ????????????? ??????? OLE

????? ???? ??? ?????? ??????, ? ??? ????? ????????. ??? ????? ?????? ?????????? ???? ???????? ?????????? ????? ???????. ? ??????????? ??????? ??????????? ???????? Word, ? ??????? ????? ??????????? ?????? "Hello World":

Private Sub Commandl_Click()

Dim ww As New Word.Application

ww.Visible = True 'Word ?????????? ???????

ww.Documents.Add '??????????? ????????

ww.Selection.TypeText "Hello World"

End Sub

??? ?? ?????? ?????????, ????? ???????????? ??????? VBA ??? Word.

 


6. ?????? ? ????????? Word

????? ???????????? ??????? Word ? VB, ?????????? ?????????? ? ??????? ?????????? Microsoft Word Object Library ????? ?????????? ???? References. ??? ????? ?????? ??????? Word - Word.Application ? Word.Document ???????????? ?????? ? ?????????? ?????????? ? ?????????? Word.

??? ??????? Word ?? VB, ?????????? ??????? ????????? ??????? Word.Application. ????? ?????????? ??????? ???? ?????? ??????? ? ??????? ????? ???????? Word (??. ?????????? ??????).

?????????? ?????????: objDoc.SaveAs "C:\temp\myDoc.doc" ???, ???? ???????? ??? ????? if objDoc.Saved=False then objDoc.Save.

???????? ?????????: Set objDoc = objWord.Documents.Open ("C:\temp\myDoc.doc")

??????: objDoc.PrintOut

??????????????? ????????: objDoc.PrintPreview

??? ?????? ? ??????? ????? ???????????? ????????? Words, Sentences ? Paragraphs. ????????, ???????? ????? ? ????????? ?????, ???????? ????????? ???????? ???????? Text. ObjDoc.Words(number).Text.

????? ????, ??? ????? ?????? ????? ????? ???????????? ?????? InsertAfter ? InsertParagraphAfter.


???????? ????????? ?????????? Active X.

ActiveX ?????????? ?? ????????? ?????? ??????????? (Component Object Model, ???) Microsoft. ??? ?????????? ???????? ???????? ???????? ???????? ?????????? ??????????? ?????????? ? ???????????? ?????????????? ??????????? ???????????? ??????????? ????? ??????? ?????????? ????????????. ?????????? ActiveX ????????? ????????? ???????, ??????? ?????? ???????????? ????? ???????????? ??? ???????? ??????????? ??????????.

 

1. ???????? ActiveX ?????????

??? ???????? ?????? ??????? ????? ???????, ??? ??????????? ?????? ????? ?????????? ??? ??????????? ????????? ActiveX.EXE, ???? ??? ?????????? ActiveX.dll, ???? ??? ??????? ?????????? ActiveX.

????? ???????? ActiveX ?????????? ????????? ????????? ? ????????? ????? ? ??????????, ??? ??????? ????????????????. ??? ??????, ??? ? ?????? Windows ?????? ???? ??????? ???????????? ??????????. ????????? ActiveX ??????? ???????????????? ? ??????? ??????? RegSvr32.exe. ????? ??????????? ?????? ?????????? ????? ????????????? ?????? ActiveX ?????????.

???????????: RegSvr32.exe <??? ??????????>

?????????????????: RegSvr32.exe <??? ??????????> /u (/u ???????? unregister)

2. ???????? ????? ???????????? ActiveX ? ????????????? ???????????? ActiveX

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

????????, ???????????? ?????????? ActiveX ??????????? ? ??????? ?????? ??????????? ?? ???????, ? ?????? ?????? ?????? ????????? ??????????? ????? ??????????. ??? ??????, ??? ???????????? ?????????? ActiveX ?????? ???????? ??????????? ???????, ??? ??????????? ActiveX.

??? ???????? ??????? ?????????? ???????????? ?????????? ActiveX ??????? ??????????????? ???????? New Project ???? File ? ??????? ? ?????????? ???? New Project ????? ActiveX DLL.

????????, ? ?????? ActiveX DLL ????? ???????? ????????? ???? ????? ? ??????????????, ????? ????????? ??????????? ????????????? ??????? ?????? ?? ?????? ???????????.

 

3. ???????? ?????????? ActiveX

????????? ActiveX ????? ????? ????????? ???? ??? ??????????? ??????????, ???? ??? ???????????? ??????????. ??? ???????? ??????? ????? ??????? ???? ?? ?????: ???? ActiveX Document DLL ???? ActiveX Document EXE. ? ????? ??????? ????????? ?????? ? ????? ??????????? UserDocument. ?? ??????????? ? ????? ? ??????????? DOB.

? ???????? UserDocument - ?? ?? ?????, ??? ?????, ?????? ? ??? ??????????? ????????? ????????, ???????? ?????????. ???? ???????? ???????????? ??? ?????????? ? ???????????-???????????, ? ??????? ?????????, ? ??? ????? ? Microsoft Internet Explorer. ? ???? ? ??????????? ???????? ??????? ?????????? ActiveX ?? ??????? ????????. ???????? ActiveX - ??? ??????????, ??????? ??????????? ? ????????? ??????????.

????????? ActiveX ???????? ????????? ??????, ?? ?????? ? ??? ??? ????????? ? ?????????????? ?????????? ????? ???????????? ?????????.

???? ????????? ??? ?????????????? ????? ??????, Visual Basic, ????? ??? ??? DLL ?????, ??????? ???? ? ??????????? .VBD (Visual Basic Document). ???? ???? ????? ???????? ? ???? ????? ? Internet Explorer. ? ???? ?????? Internet Explorer ???????? ??? ??????????-????????? ? ?????? ???????? ? ??????? HTML ?????????? UserDocument. ?????? ?????????? Visual Basic ???????? ? Internet Explorer.

??? ???????, ????????? ActiveX ???????? ????? ???, ??? ???????? "???????????" ??????? Visual Basic. ????? ???????????? ??????? ? ActiveX ???????? ??????????, ???? ? ?????????????? ?????. ??? ?? ?????, ??????? ???????, ??? ???????? ActiveX ?????? ???????? ? ??????????-?????????? ? ??????? ????????? ??? ?????????????.

? ????? ?????????? ????? ???????????? ????????? ???????????????? ?????????? (UserDocument). ?? ? ??????? ?? ????, ??? ?? ???????????? ??????? Show, ? ?????? ?????????? ?? ????? ?????????? ????????? ??????????-??????????: ??? ??, ??? ? Internet ?????????? ??????????? ? ????? ???????? ?? ?????? ? ??????? ???????????. ?????????? ??? ????? ? Visual Basic ??????? ?????? Hyperlink, ? ??????? ???????? ????? ????????? ????? ????????.

Private Sub Command2_Click()

Hyperlink.NavigateTo "doc2.vbd"

End Sub

????? NavigateTo ?????????? ??????? ? ?????? ???????????. ??? ????? ???? URL ??? ????, ????? ??, ??? ???????????????? ????????.

4. ???????? ?????????? ActiveX

Visual Basic ????????????? ???????????? ??????????? ????????? ??????????? ???????? ?????????? ActiveX - Custom Controls. ??? ????? ???? ??? ?????????? ????? ???????? ??????????, ??? ? ???????????? ?? ??? ???????????? ????????? ? ??????????? ?? ?????????????? ???????????. ????? ???????? ????? ???????????? ??? ? ???????? Visual Basic, ??? ? ? ?????? ???????? ????????????????, ??????? ???????????? ?????????? ActiveX. ? ??? ?????????, ????????, Microsoft Internet Explorer ??? Netscape Navigator

 


???????? ????????? ?????????? ActiveX

?????????? ??? ??????? ? ???????? ????????? ?????????? ActiveX:

1. ???????????? ???? ??????? ?????????? ?? ???????????? ??????????? ?????????. ????????, ???????????? ???? ?? ??????? ? ????????? ????, ??????? ??????? ????, ????? ????????? ?? ????????????????? ??????????? ???????.

2. ?????????? ???????????? ??????? ??????????. ???????????? ??????? ?????????? ??????? ?? ????????? ?????, ? ??? ?????? ???????????? ?? ??????????? ??? ???????. ????????, ? ???????? ?????????? ???? ??????????? ????????, ??????? ????????????? ?????????? ????????? ????? ?????????? ???????.

3. ??????? ???????????? ??????? ??????????. ??????? ??? ???????? ????????? ? ?????????????? ??????????? ???????. ?????? ?????? ????????? ??????????? ?????????? ????? ???????????????? ?????????.

 

1. ???????? ???????? ?????????? ?? ???????????? ??????????? ?????????

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

??? ???????? ???????? ?????????? ?? ???????????? ??????????? ?????????, ?????????? ??????? ?????? ActiveX Control. ?????? ActiveX Control - ??? ?????? ?????. ????? ???? ?????????? ???????? ? ?????, ??????? ?????????? UserControl, ??????????? ???????? ??????????. ????? ?????????? ????????? ??????????? ???????? ??????? ? ????????? ??????????. ???????? ????? ????????? ? ??????? ??????? PropertyGet ? PropertyLet. ????? ?????????? ??????? ???????????????? ?????????. ?????????? ??????? ??? ?????? File/Make/??????????.ocx.

?????? ???????? ??? ?????????? ??????? ??????? ????????? ???????? ?????? ???????? ??????????. ??????? ??????? ???????? ??????????, ??????????, ????? ??? ???????????? ??? ???????? ?? ???? ??????. ????????? ???????? ????????? ?????????????? ??????????, ????? ????????? ???????? ??????? Width ? Height.

??? ???? ????? ???????? ??????? ?????????? ?? ?????? ??????????, ?????????? ??????, ?????????? ?? ?? ?????????? VB. ???? VB ??????????, ?? ??? ????, ????? ???????? ?????????? ?????????? ??????????? ?????????? ? ????? Windows/SYS ? ????????? RegSvr32.exe <?????? ??? ?????>. ???????? VB ????? ???????, ??? ? ??????? ??????????? ???????? ????? ??????????.

???? ?? VB ?? ??????????, ?.?. ??? ??????????? ?????????, ?????????? ??????? ??????????? ? Package & Deployment Wizard. ???? *.ocx ???????????????? ? ??????? ??????????, ?? ????? ??????? ??????????? ????? ??????????.

????? ?????????? ???????? ?????????? ? ??? ????? ???????? ??? ? ????? ?????? ????????? ??????????. ??? ?????????? ???????? ?????????? ? ?????, ?????????? ???????? ?????? ??????? ???? ?? ?????? ????????? ??????????, ??????? ????? ???? Components, ? ????? ??????? ??????????? ??????? ?????????? ActiveX.

2. ????????? ????????????? ???????? ??????????

??? ????????? ????????????? ???????? ?????????? ?????????? ?????????????? ??????????? ??? ????????????? ???????? ??????????, ?.?. ??????????? ????? ????????, ?????? ? ???????. ? ?????? ?????? ????? ????????? ?????? ActiveXControl. ??? ????????? ???????? ??????? ???????? ?????????? ??????? ???????????? ????? PropertyChanged.

??????????? ?????? PropertyBag ????????? ???????? ?????????? ActiveX ??????? ??????????? ??????????????. ????? PropertyChanged ???????????, ??? ???????????? ??????? ???????? ????????, ????? ???? VB ????????????? ?????????? ??????? WriteProrerties ? ReadProperties.

3. ???????? ????????????? ???????? ?????????? ActiveX

? ?????? ??????, ????????? ???????? ?????????? ????????? ? ??????? ??????????? ???????. ?????, ?????????? ??????? ?????? ActiveXControl ? ?????????? ???????? ???? ??????? ? ???????? ??????????.

??? ?????????? ???????? ?????????? ?????????? ? ????????? ????????? ??????? Paint, ??????? ???????????? ??? ?????? ??????????? ??????????, ??????????? ???? ???????. ????? ??????? ??????? ??? ???????? ?????????? ????? ??????????????? ?????????? ?????????? Shape ? Line.

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

 

???????? ????????? ?????????? ActiveX ? ??????? ???????

????? ?????? Visual Basic ???? ?????? ??????????? ActiveX (ActiveX Control Interface Wizard). ? ??? ??????? ????? ????? ? ?????? ??????????????? ???? ????? ???????, ??????? ? ??????? ???????????????? ???????? ??????????. ?????? ?????????? ???????????? ? ?????? ?????? ???????? ???????, ????????? ?? ?????????? ???, ??? ??????? ???????. Add-Ins/Add-In manager/ActiveX Contril Interface Wizard. ?????? ?????? ????? ??????? ??? ??????? Visual Basic ??? ??? ???????? ?????? ??????? ActiveX Control.

?? ?????? ????? ?????? ?????????? ?????? ??????????? ??????????? (???????, ??????? ? ???????, ??????? ?????????? members). ?? ??? ??????? ??????? ??, ??????? ?????? ????? ??????? ??????????.

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

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

?? ????????? ????? ?????? ??????? ??????? ??????????? ?????? ???? ??????????? ???????? ???????. ??? ???????? ????? ??????? ??? ??????, ??????? ??? ????? ???????, ???????? ?? ?????????, ??? ??????? ?? ????? ?????????? ? ?? ????? ??????????, ???????? ???????. ?????, ??????? ????? ?????? ? ???? Description ???? ???????, ????? ????? ?????????? ? ???????? ????????? ? ???? ???????.

????? ?????????? ?????? ?????? ????????? ??????????? ?????? ???? ? ?????? ???????? ??????????.

??? ?????? ????????? ??????????, ??????? ???????????? ? Visual Basic, ????? ?????? ???? ??????? Visual Basic, ?????????? ??????????? ???? ???????. ????? ???? ??????? ????? ??????? ? ??????. ??? ????? ??????? ?????? ??????? ??????? (Property Page Wizard). ??????? ?????? ????? ? ??????? Add-Ins/Add-In manager/ Property Page Wizard.


???????? ????????? ?????????? Active X ?? ??????? ZigZag.

????????? ???????? ?????????? Active X (Active X Controls) ? ????? VB ????? ??????. ?? ?????? ??????? ?? ???????? ??????? ?????????? ZigZag, ??????? ???????????? ????? ?????????, ?????? ???????? ????????? ????? ?????.

?? ???? Active X Control - ??? ?????, ??????? ?????????? ????????????? ? ?????????????? ????? ???????, ??? ????? ???????? ?????? ? ???????, ????????? ? ???????? ??????, ?? ???? ?????????? ????????? ???? ????? ??????.

?? ????? ????????? ??? ??????? ?????????? ZigZag ?? ? ????, ? ?????????? ??? ???????????? ??????????? ???????? ?????????? VB.

???????? ?????? ?. ?????? ??????? ???? Active X Control, ??????? ??????????? ?? ??????? ????? P:\PREP\System_program\VB\Lessons\ActiveX_Control\1.html ? ???????? ?????? ? ??????? ???? ??????? ?????????? Active X. ???????? ???????? ?? ????????????? Active X Ctrl Interface Wizard'?, ??????????? ???????????? ??????????? ???????, ??????? ? ??????? ?????? ???????? ??????????.

 

2. ??????????????? ??????.

??????????? ??????? ?????????? Active X - Liner, ?????????????? ????? ?????????? ????????? ??????????? ????????, ??????????? ?????? ??????? ?????????? ?????.

???????? ????? ?????? ?????? ??? ?????????? ??? ??????? (????????, ???????, ?? ? ??????????), ?????? ?????? ????? (?? ??????), ? ????? ??????? ?????????. ? ??????? ????????? ??????? ????? ?????? ???? ???????? ? ?????? ????????? ????? ?????. ????????? ????? ?????? ???? ???????????? ??????? ????? ????? ???????? ?????. ???????? ?????? ????, ???????????? ????????? ????????? ????? ? ?????????? ????? ???????????. ?????? ???????? ????????? ??????? ???? ?????????. ?????? ?? ?????? ?????????? (RaiseEvent) ????????? ???? ??????? onOK. ??????? ?????? ?????????? ??????????? ??????? ? ????? ??????????????. ? ?????? ?????????????? ?????? ?????? ?????, ???????? ? ?? ?????????, ?????? ??????? ?????????? ????????, ? ?????? ???????? ???????????? ? ????? ?? ??? ?????????? ?? ??????????????. ? ?????? ?????????????? ???????????? ????? ??????? ????? ???????????? ????? ??????? ?????? ?????? ???? ????? ???. ??? ???? ????????? ????? ??????????:

????? ????? ???????, ????? ????????? ????? ???? ?? ?? ?????? ? ?????????? ??? ?? ????? ????? (????? ??????? ????) ??? ??????? ????????? ????? ???????? ?????? ???????'.

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

?????????? ??????? ?????????? ???????? ? ?????.

?????? ?? ??????????:

- ??? ????? ???????? ?????? ???????? ?????????? ? ???? ???????? ????????? ?????? ? ????? ?????, ????? ???????? ???? ??? ?????? ?????

- ?????? ?????? ????? - ?????? ????????? ?????????? ??????, ??????? ???????? BackColor - ???? ?? ??????, ? Style - 1-Graphical. ????????? ??????? ?????? ?????? - ?????????????? ??????? ?? ??? ?????? ????? ???????? ? ???????? ????? ????????????? ???????? BackColor ??????? ?????? (??? ???????? ????? ??????????? ?????????? ???? Variant)

- ????????? ????? ?????????? ? ??????????? ??????? Paint ?????? ???????? ?????????? (UserControl_Paint) - ?????? ??????????? ?????? ?? ???? ???????????? ?????? ? ?????? ?? ? ??????? ????????? Line, ?????? ????????? :

Line (x1,y1) - (x2,y2),Color,BF

BF - ?????????????? ????????, ??????? ?????? ????? ?????? ??????????? ????????????? ?? ???????? ???????????

- ??? ????????? ????? ????? ?????????? ???????? ??????????????? ??????????? ??????? MouseDown (?????? ???? ??????), MouseMove (????? ????? - ??????), MouseUp (?????? ???? ????????? - ????????? ????????? ?????)

- ??? ?????? ????? ? ?????? ????????? ????? ????? ???????????? ????? ?????:

o X ? Y - ?????????? ???? ? ?????? ??????? ?????? ?????? ???? (??? ?????????? ? ?????????? ? ???????? ?????????? ???????????? ????)

o ???????? ?? ???? ???????????? ??????

o ??? ?????? ????? ??????? ?????????? ?? ????????? ?? ???????? ????? ?? ??????? sqr((x1-x2)^2+(y1-y2)^2)

o ????? ??????? ????? ?????????? ?? ????????? ???? ?? ????????? ? ???????? ?????

o ???????? ?? ??????? ??????

o ???????? ????? ? ??????????? ???????? - ??? ? ????? ????? ????????? ?????

- ?????? ????????/???????????? - ?????? (CheckBox), ??????? ???????? Style ?????? 1-Graphical. ????????? ??????? ?????????? ?? ??????? Click.


????????????? ??????? Windows API ? VB.

Windows API, ??? Application Programming Interface (????????? ??????????? ????????????????) - ??? ????? ???????, ??????? ????????????? ???????????? ?? Windows. ??? ??????? ????? ?????????? ?? VB ??? ?????????? ?????, ??? ??????? ???????????? ???????????? ???????????? ???? VB. ????????, ??????????? ??????? VB ?? ????????? ????????????? ?????????, ?? ???????????? ????? ?????????, ??????????? ? ??????????????? ??????? Windows API.

? ????? ?????? ????????????, API ??????? ?????????? ??????? ???????? VB. ??? ????? ????? ??????? ? ???????? ??????????, ?????? ?????????? ? ????????? ?? ????????? ????????? ????????. ??? ??????? ??? ?????????????? ? ????????? dll ??????????.

??? ????????????? ??????? Windows API, ?? ?????????? ??????? ???????? ? ??????? General Declarations (? ????? ?????? ????), ????????? ???????? ????? Private. ???????? Windows API ???????, ? ????? ???????? ? ???????????????? ????? ????? ????? ? ????? Win32api.txt. ????? ?????? ??????????? ?? ????? ????? ??????, ???????????? ? ????????? Declare. ? ????????? Declare ?????????? ??? ????????? ???????, ? ????? ?????? ?? ?????????? dll, ? ??????? ?????? ??????? ???????.

?????? ?????????? ? ????? ??????????, ? ??????????? ?????????? Declare ???????????? ???????? ????? Alias (?????????). ????????? ?????????? ?????????????? ??? API ???????, ?.?. ???, ???????????? ? dll. ?????????? ???????????? ? ??? ??????, ???? ? ?????????? ??????? ???????????? ??? VB ??? ???????.

????? ?????????? ???????, ????????, ????? ?????????? ?????????? ??????, ???????????? ? ??????? ? ??????? ?????????. ??? ???????? ????? ????? ??????????? ?? ????? Win32api.txt. ??? ?????? ??????? ?? ???? ????????? ?????????? ?????????? ? ??? ?? ?????, ???????? ??????????? ????????? ?, ????????, ????????? ????????? ?????????? ?????-???? ??????????.

? ???????? VB ?????? ??????????? ?????????? API Text Viewer, ??????? ????????? ?????? ???????? ?????????? ?????? ??????? API. ??? ??????? ????? ?????????? ?????????? ??????? ? ???? ???? ?????? ???????? VB (Microsoft Visual Studio Tools), ? ????? API Text Viewer. ????? ??????? ?????????? ?????????? ????????? ??????? Load Text File ? ????????? ???? Win32api.txt. ????? ?????, ? ??????? Available Items ???????? ?????? ????????? ?????????? API.

API Text Viewer ????????? ?????????? ? ????? ?????? ???????????? ????????? ???????. ? ????? ??????????, ????? ?? ??????? ????????? ? ???????? ?????? Public, ??? Private. ?????????? API-?????????? ????? ???????????? ? ??????? ? ?????????? ? ??? ?? ????? ?????? ???? ? ??????? ???????. ???? ?? API ??????? ?????????? ???????????? ? ?????, ??? ?????? ???? ????????? ? ???????? ?????? Private.

 

??????? ????????? ???????:

SndPlaySound - ????????? ??????????? ???????? ????? ? ??????? WAV

SystemparametersInfo - ???????????? ??? ????????? ????? ???????? ????? Windows.

ExitWindowEx - ????????? ????????? ?????? Windows.

GetFreeDiskSpace - ???????? ????? ?????????? ????? ?? ?????.

CreateProcess - ????????? ????????? ??????????

WaitForSingleObject - ???????? ?????-???? ????????, ??? ????????? ???????

GetFileTime - ???????? ???? ????????, ??????? ? ????????? ??????????? ?????

GetFileSize - ???????? ????? ?????

GetFileAttributes - ???????? ???????? ?????

GetSystemTime - ????????? ???????? ????????? ???????? ????/???????

ReadFile - ?????? ?????

 


API-?????? ??? ?????? ? ??????

????? ????????? API ??????? ????????? ????????? ?????????? ???? ? ???????? ?????????? ? ?????? ?????. ??? ????????????? ???? ???????????? ?????????? ???? - ?????????? ?????, ??????????? ??????? ????????? ???? (window handle).

??? ??????????? ??????????? ???? ???????????? ??????? FindWindow. ? ??? ??? ?????????: ??? ???? ? ??? ?????? ????. ??????? ?????????? ???? ?????????? ????, ???? ????, ???? ??????????????? ???? ?? ???????. ??? ????????? ???????? ????? ???? ? ????? ?????? ???? ????? ??????????????? ?????? API ????????? ??? GetWindowText ? GetWindowClass.

???? ??????????, ????? ????? ????????? ?????????? ???? ? ??????? ??????? Windows API ShowWindow (????? ??????? ??????? ?????????? ????: ??????????????, ???????????????, ? ?.?.).

??????? Sendmessage ? postMessage ????????? ?????????? ????? ????????? ?????????. ????????, ????????? ??????? ????. ??? ???? ????? ????? ????????? ? ???????????? ????????????? ? ?????????? ????????? ?????????. ??????? postMessage, ? ??????? ?? Sendmessage, ???????? ??????????, ?.?. ???????? ?????????? ????????? ?????????, ?? ????????? ????????? ?????????.

 

API-?????? ?????????? ?????????

??????? Shell ????????? ????????? ?? ????? ????????? ??????, ?? ??? ??????? ???????? ?????????? ? ????????? ?? ?????????, ?? ????????? ????, ????? ????? ????????? ?????????? ??????. ?????? ????? ????? ???????????? ??????? ExecCmd.


???????? ??????? ? Visual Basic.

1. ??????? ?????? ? ???????.

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

 

??????? Dir

???? ?? ???????? ???????? ??????? ??? ?????? ? ??????? - Dir$. ??? ?????? ?? ??????? DOS dir, ? ?????? ??? ????????? ?????? ?????? ? ?????????, ??????????? ? ???????? ????????.

??? ????? ????? ???? ?????? ? ???? ??????? ????? ????? ??? ?????????????? ????, ? ????? ? ???? ???????, ?????????? ?? ???????? ??????????? (*, ?).

????????? ??????? Dir:

?????????_?????????? = Dir$ (??????, [????????])

?????? - ?????? ??? ????? ??? ?????? ????? ????? (??? ????????).

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

?????????

????????

??????????

vbNormal

0

???????? ?? ?????????

vbHidden

2

????? ??????? ??????

vbSystem

4

????? ????????? ??????

vbVolume

8

?????????? ????? ????

vbDirectory

16

????? ?????????

vbReadOnly

1

????? ??????, ??????? ??????? read-only

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

??? ???? ????? ???????? ????????? ???? ??? ???????, ?????????? ??????? ??????? Dir$ ??? ?????????? ? ??? ??????.

????????: ???? ??????? Dir$ ??????? ?????? ?????? (????????? ??? ?? ??????), ?? ????????? ????? Dir$ ??? ?????????? (???????? ????????? ???? ??? ???????) ??????? Runtime Error.

?????? ?????? ??????:

Dim Filename As String

Filename = Dir$("C:\Tmp\*.*",vbHidden+vbDirectory)

While Filename <> ""

Debug.Print Filename

Filename = Dir$

Loop

????? ???????, ??????? Dir$ ????? ???????????? ??? ??? ?????? ?????? ? ?????, ??? ? ??? ??????????? ????????????? ???? ??? ????? ????? (????? ??? ??? ? ???????? ??????? ?????????).

??????? ??????????????? ???????

????? Dir$ ?????????? ?????? ???????, ??????????????? ???????????, ??????????? ???????? DOS ?? ?????? ? ???????.

????????

?????????

??????????? ?????

FileCopy <??????>, <????>

???????? ??????

Kill <????>

?????????????? ?????

Name <??????_???> As <?????_???>

???????? ????? ?????

MkDir <????>

???????? ?????? ?????

RmDir <????>

?????? ???????? ????????

ChDir <????>

?????? ???????? ?????

ChDrive <????>

?????? ?? ????????? ? ????????? MS-DOS ??? ??????? ????? ??? ???????????:

- FileCopy ?? ????? ?????????? ????????? ?????? ?? ???????

- Name ???? ?? ????? ????????? ??????? ??? ??????????????

 

??????????? ??????????????? ????? ?????????

??? ??????????? ??????????????? ??????????? ????? ????????? ?????? ???????????? ??????????? App.Path.

?????? ???????? ??????? App ???????? ???? ? ?????????. ??????????? ??????????? ? ???, ??? ??? ??????? ?????????? ???? c \' ?? ?????, ???? ????????? ????????? ? ???????? ???????? ??????-???? ?????, ? ???, ???? ? ?????-???? ?????? ????????. ???????, ????? ???????? ???? ? ????????????? ???? ?????????? ????????? ??????? \' ?? ????? ????????????? ???? ? ???????? (??? ???????) \'.

 

?????? ?????????????:

Dim Apppath1 As String

Apppath1 = App.Path

If Right$(Apppath1,1) <> "\" Then Apppath1 = Apppath1 + "\"

...

Dim Filename As String

Filename = Apppath + "myfile.txt"

 


2. ????????? ????????? ?????????? (????? ????????????????? ???????).

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

??? ???????? ?????? ???????????? ??????????? Open:

Open <???_?????> For <?????> [Access <??????>] [<??????????>] As [#]<?????_?????>[Len=<?????_??????>]

<?????> - ????? ? ??????? ??????????? ????:

Append - ??? ?????????? ? ????? ?????

Binary - ??? ?????? ? ?????? ? ???????? ?????? (??. ????)

Input - ??? ?????? ????? (???? ?? ????????????????)

Output - ??? ?????? ? ???? ? ????????? ??? ??????????? ?????

Random - ??? ????????????? ??????? (?? ?????????)

<??????> - ????????, ??????? ????? ????????? ? ??????:

Read - ????? ?????? ??????

Write - ????? ?????? ??????????

Read Write - ????? ???

<??????????> - ??? ?????????? ?????:

Shared - ?????? ???????? ????? ?????? ? ?????? ???, ??? ??????

Lock Read - ?????????? ??????

Lock Write - ?????????? ??????

Lock Read Write - ?????? ?????????? (?????? ???????? ?? ????? ???? ??????? ????)

<?????_?????> - ?????????? ?????? ? ???? ?????? ???????????? ?? ??????, ??? ??????? ?? ??????, ?????? ??? ????? ??????? ????? ???? ?????? ?????? 1 ????. ??? ????????? ?????????? ?????? ????????????? ???????????? ??????? FreeFile (??? ??????????).

 

<?????_??????> - ???????????? ? ?????? ??????? ??????? (??. ????).

???? ???? ??? ?????? ??? ???????????? ?????? ????????? ??? ????????? ?????? ??????, Open ?????????? ?????? (??????? ????? ?????????? ? ??????? OnError ...).

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

???????? Line Input #?????_?????, <?????????_??????????> ????????? ??????? ????????? ?????? ?? ?????. ????????? ?? ????? ?????, ????? ????????? ??????? EOF(?????_?????).

?????? ?????????? ??????? ?? ??? ??????. ? ???? ?????? ???????????? ???????? Input # ??? ??????? Input.

???????? Input # ???????????? ??? ??????, ? ??????? ?????? ???????? ? ?????????????:

??????, 100, #2002-10-10#

? ????????? ?????? ???? ?????????? ????????? ??????????? ? ??????????????? ??????????:

Dim StringVar As String

Dim IntVar As Integer

Dim DateVar As Date

Input #1, StringVar, IntVar, DateVar

?????? ?????? ?????????? ?????????? - ????????????? ??????? Input (?? ?????? ? ?????????? Input #). ??? ??????? ????????? ????????? ????? ???????? ? ????????? ??????????:

Input (<???-?? ????????>,#?????_?????)

????? ?????? ? ?????? ??? ????? ??????? ? ??????? ????????? Close #?????_?????.

??? ???? ????? ???????? ???-?????? ? ???? ? ???????????????? ????????, ?????????? ??????????????? ???????????

Print # ? Write #.

???????? Print #?????_?????, <?????????> ?????????? <?????????> ? ???? ? ??????? ???????. ???? ? ????? ????????? ????? ;', ?? ???????????? ??????? ?? ????? ??????.

???????? Write #?????_?????, <??????_??????> ?????????????? ????????? Input # - ?.?. ??????? ?????????? ? ???? ? ?????????????.

 


3. ????? ????????????? (???????) ???????.

????? ? ???????????????? ???????? ?? ????? ?????-???? ?????????, ????????? ??????????? ????? ??????????? ?????. ??? ???????????? ??????????????? ?????, ?????? ????? ? ??????????? ?? ????? ?????????. ???? ?? ???????? ???????? ????? ? ?????-???? ?????????? ? VB ??????? ? ????????????? ?????? ????????????? (???????) ???????.

??? ?????? ? ????? ?????? ?????????? ??????? ??????? ???????????????? ??? (UDT), ??????? ???????????? ????? ?????? ????????? ?????? ?????.

??????:

Private Type MyRecord

FIO As String

Birth As Date

Salary As Integer

End Type

????? ?????????? ??????? ???? ? ??????? ????????? Open. ??????? ?? ???????? ?????? ????????????????? ??????? ??????????? ? ????????????? ???????????? ?????? ???????? - Random ? ??????? ? ????? ??????????? ????? ??????????? ??????? ????? ??????? ??????? ? ??????? Len = <?????_?_??????>.

 

??????:

Dim tmprec As MyRecord

Open "c:\tmp.mmm" For Random As #1 Len = Len (tmprec)

?????? ??????? ?????????????? ? ??????? ?????????

Get #?????_?????, [<?????_??????>], <??????????>

???? ???????? <?????_??????> ??????????, ?? ?????? ?????????? ?????? ????????? ??????. ?????????? ????? ???, ???????? ????????????? (UDT).

??? ?????? ? ?????????? ????? ??????? ????????????

Put #?????_?????, [<?????_??????>], <??????????>

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

??????????? ?? ????? ?????????????? ? ??????? ?????????

Seek #?????_?????, <?????_??????>

????? ????? Get ? Put ??? ??????? ????????? ????? ???????? ? ???????, ?? ??????? ?? ?????????????.


4. ????? ?????????????.

????? ????????????? (ini-?????) ??????????? ??? ?????????? ?????? ?????????? ? ????????? ? ?? ??????????, ???????? ?????????????. ???????? INI-????? - ??? ??????? ????????? ????? ? ??????????? .ini ? ??????? ??????????, ??????? ????????? ???????? ??? ????????? ????????? ????????? ??????????.

?????? ini-????? ????? ???????, ?????????? ? ??????? ???????? ???? system.ini ? ????????? ????? Windows (??? WinNT ??? ??? ?? ??? ?? ??????? ??? ?????????).

????????? Ini-?????? ???????? ??? ???????? ???????? - ???????, ????? ? ????????. ????? ? ??? ????? ?????????????? ??????????? (?????????? ? ;).

???? ?? ?????? ???????????? ????????????? ini-?????? ??????? ? ???, ??? ???????????? ?? ???? ????????? ? ???????? ?????, ??? ???????? ??? ?????? ?????????? ??????. ??? ?????? ? ini-??????? ?????????? ???????? ??? ??????? Windows API:

Declare Function GetPrivateProfileString Lib "kernel32" Alias _

"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _

ByVal lpKeyName As Any, ByVal lpDefault As String, _

ByVal lpReturnedString As String, ByVal nSize As Long, _

ByVal lpFileName As String) As Long

Declare Function WritePrivateProfileString Lib "kernel32" Alias _

"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _

ByVal lpKeyName As Any, ByVal lpString As String, _

ByVal lpFileName As String) As Long

??? ??????????? ??????? ????? ????? ???????? ? ??????? ??????????? API Text Viewer, ????????? ? ???????? ???????? Microsoft Visual Studio 6.

?????????:

- lpApplicationName - ??? ???????

- lpKeyName - ??? ?????

- lpDefault - ??????, ?????????????? ? ???????? ?????? ?? ?????????, ???? ???? ?? ??? ??????

- lpReturnedString - ??????, ???? ???????????? ???????? ?????, ???? ?????? ???????????? ???????? ????? (????? ??? ???????? lpString)

- lpFileName - ??? ????? (? ????, ???? ?? ?????)

- nSize - ???????????? ?????? ???????????? ???????? ????? (? ??????)


5. ????????????? FSO (File System Object).

? VB 6 ??? ?????? ? ??????? ?????? ??????????? ???????, ????????? ????, ?????????? ??????????? ?????????? - FSO. ????? ???????? ? ?????? ? ??? ?? ?????? ?????? ?? ????? ?? ??????? ????? P:\PREP\System_Program\VB\Sample\File\FileSystemObject\Doc\FileSystemObject.htm. ? ???????? P:\PREP\System_Program\VB\Sample\File ????? ????????? ??????? ?? ?????? ? ???????.

 


????????????? ???????? ?????????? WinSock Control ??? ???????? ??????? ??????????.

??? ???????? ??????? ?????????? ?????????? VB ????? ????? ???????????? Active X Control WinSock, ??????? ????????? ????? ??????????? ?? TCP ??? UDP ??????????.

??? ??????????? WinSock ? ?????? ?????????? ?? Components ?????????? ??????? ????????? ?????? Microsoft Winsock Control 6.0.

?????? ? ????, ??? ?????? ????? ???? TCP/IP ??????????. ???? TCP/IP ??? ??????????? ?? ???? ???????? ??????????:

TCP

UDP

IP

?.?. ??? ????????? TCP ? UDP ?????????? ? ?????????? ? ????? ?????? IP-????????. ??????? TCP ?? UDP - TCP - ???????? ? ??????????????? ????????? ??????? ? ????????? ?.?. ??????, UDP - ??????? ? ??????? ????????, ?? ??? ??????????????? ???????? ??????? ? ??? ???????? ??????. ????????????? ????????? TCP-????????.

?????? ?????????? IP-?????????. ??? ????????? ??????????? ??????????? 4 ????? ?? 0 ?? 255, ??????????? ??????. ????????, 192.233.80.41. ????? 127.0.0.1 ???????? ??????, ?.?. ????????? ?? ???? ????????? (? ??????? ???? ????? ??????????? ?????????? ??? ???? ??? ???? ??? ???????). ?????? ?? ?????? ?????????? ????? ???????? ????????? ????????, ???????????? ????. ?????? ????????? ?????? ??????? ?.?. ?????, ?.?. ??????????? ??????????. ????? ???????? ?????? ???? ?? ????? ? ??????? ?? ???????????, ??????? ?????? ?????????? ? ???????????? ????? ?? 0 ?? 65535 (????). ????????, ??????-?????? ? ?????????????? ???? ????? ??????? ???????? ?? ?????? 192.168.10.1:8080, ?.?. ????? ?????? - 8080.

 

?????????? ??????? ?????????? ?????? ?????????? ? ?????? ??? ?????? ??????? ?? TCP-?????????. ?????????? ????? ???????? ?????????????? ???????? ? ???????? (?.?. ?????????, ??????? ??????????? - ??????, ??????? ???? ?????????? - ??????).

 

1. ?????? ??????? ????? ? ????????? ? ????? ????????????? (listen).

2. ?????? ??????? ?????, ?????? ????? ??????? ? ????? ??????, ?? ???????? ??????? ?????? ? ???????? ?????? ?? ?????????? (connect).

3. ????????? ?????, ??????? ?????? ?? ??????????, ?????? ??????? ??????? ????? ??????, ?? ???????? ?????????? ? ?????????? ?????????? ? ????????? ????????? ????? ??? ??????/???????? (????? ?????????, ???? ?????? ????? ??? ?????????????) ? ??????? ??????? (accept).

4. ????? ????? ?????? ??????? ? ??????? ????????? ? ????? ?????????? ??????????.

5. ?? ????????? ?????? ?????????? ??????? ?????? ?? ????? ??????.

 

??? ??? ??? ?????????????????? ??????????? ? ??????? WinSock:

1. ?? ????? ??????? ???????? WinSock ? ?????? ??? ????????: LocalPort (????? ?????? -???? ???????), Protocol (??? ?????????). ??? ???????? ??????? ? ????? ????????????? ???????????? ????? Listen (??????? WinSock).

2. ?? ????? ??????? (?????? ??????????) ???????? WinSock ? ?????? ??? ???????? ?????????? ???????, ???? RemoteHost (IP-????? ? ???????? ?? ?????? ??????????????) ? RemotePort (???? ???????). ??? ??????? ??????? ?? ?????????? ???????????? ????? Connect. ? ?????? ?????? ? ?????????? ?????????? ??????, ??????? ????? ??????????.

3. ? ????? ??????? ?????????? ???????? ?????????? ??????? ?????? ConnectionRequest, ? ??????? ??? ????????? ????? ????? ??? ??????/????????, ??? ???????????? ??? ???????????? ??? ?????? ?????? Accept ? ?????????? RequestID (??? ???????? ??????? ConnectionRequest).

4. ????? ????? ?????? ????? ???????????? ??????????? ? ??? ??????? ? ??????????? ?????? SendData. ??? ???? ????????? ??????? ?????? ?????????????? ? ??????????? ??????? DataArrival, ? ??????? ? ??????? ?????? GetData ????? ?????????? ???????? ?????? ? ????? ?????.

5. ????????? ?????? ? ??????? ?????? Close.

 


?????? ? ????? ?????? ?? VB ? ??????? ADO.

 

1. ????? ADO.

????????, ??? ?????? ? ?????? ???????? ????????? ??????????? ??? ?????????? ??????????? ??????-??????????. ?????????? ODBC ???????????? ?????? ? ??????????? ????? ?????? ? ??? ?????? ??? ?? ???? ??????? ???? ????????. ??????, ????? ???????????? ????? ???????? ? ???? ??????? ????????????? ????????? ?????? ??? ???????? ? ??????, ???????? ????????, ??? ???????????? ? ???????? - ???? ????????????? ??????????? ????????? ??????? ? ??????, ???? ???????? ?? ?????? API, ??? ???????????? ? ?????? ???????. ActiveX ??????? ??????? ? ?????? (ADO) ?????? ??? ??????? ? ???????????? ?????? ??????, ??????? ???????? ?? ????? ??????????? ?????? ? ????????? ??????. ????? ??????? ADO ???????????? ????????????????, ?????????????????????? ?????? ? ??????, ? ???????? ?? ?????? ????????? ?????????? ????????? ??? ?????? ? ?? ??? ??????-??????? ???????? ??????, ???????????? ??????????, ??????????????, ???? ???, ????, ????????-???????. ADO - ??? ?????? ????????? ??????? ? ??????, ??????? ??? ????????? ??? ???????? ????- ? ?????????????? ?????????? ??????????? ??????/?????? ? Web-??????????????? ?????????????? ??????.

?????????? ADO ???? ??????? ????????? ? Microsoft Internet Information Server ??? ????????? ??????? ? ??. ????????????? ADO ????????? ?????????????? ??????? ?????? ? ???????? Internet-????????? ? ????????? ?????????? ????????????? ??????? ????? ?????????? ??????????? ? ?????????? ??????. ADO ????? ????????????, ??? ??? ?? ????????? ????????? ??????? ??????? - ????????? ????????????? OLE, ????????? ??????? ? ??????????? ??????? ?????????? ??????????. ??-?? ???????? ?????????? ? ???????? ???????????? ADO ????? ????? ? ? ????? ADO ???????? ?????????? RDO ? DAO, ??????? ? ????????? ????? ??????????? ????? ??????. ?????????? ADO ?? ?????? ??????? RDO ? DAO, ????????, ??? ?????????? ?? ?? ?????????? ?????. ADO ????? ???????????? ??????????? ????????? ? ??????? ????? ???? ????? ??????? ?????????????? ??.

ADO ???????? ??????????? ???????????? ?????? ? OLE DB, ???????? ? ????????? (?????? ???????) ????????? ??????? ? ?????? ?? MS. OLE DB ???????????? ?????????????????????? ?????? ?? ?????? ?????????? ??????. ADO ? OLE DB ?????? ???????????? ????? ?????? ????????? ?????????????? ??????? ? ?????? (Universal Data Access). OLE DB ???? ??????????? ?????????????? ??????? ?? ?????? ?????? ? ???????????? ????????????? ??????????? ??????? ??? ?????????? ?????. ??? ??? ADO ????????? ?? ??????? OLE DB, ?? ?????????? ADO ????? ??? ???????????? ?????????????? ??????? ? ??????, ??????? ???????????? OLE DB.

 


2. ?????? ?????????? ??????? - ADO Data Control.

??? ??????? ? ????? ?????? ????? ADO ???????????? ??????? ?????????? Active X, ???????????? ADO Data Control. ??? ????, ????? ?????????? ??? ? ?????? ???????, ?? ?????? ????????? Active X ?????????? ??????? ??????? Microsoft ADO Data Control 6.0 (SP4) (OLEDB).

?????????? ???????? ???????? ????? ??????????:

??? ????? ??????? ????????? ???? ?????????? ???????????? ?????? ??????????, ??????? ??????? ????? ?????? ??????? ?? ???????? (Custom), ? ??????? ???????? ????? ????? ??????? Connection String, ?????? ??? ? ??????, ? ????? SQL-??????, ??? ??????? ??? ??? ???????? ?????????.

?????????? ????? ?????? ????????, ??????? ? ?????? ??????? ADO Data Control, ????????? ??????????:

 


3. ????????? ? ??????? ???????? ??????????.

??? ??????????? ?????? ???????????? ???????? ??????????, ????????? ? ????????? ?????????? ADO Data Control.

?? ??????????? ????????? ?????????? ????? ?????????????? EditBox, CheckBox, PictureBox.

?????????? ??? ??????? ??? ???????? ?????????? ? ADO Data Control.

??????? ?????????? ?????? ???????? DataSource - ?? ???? ?? ??????? ??????? ??? ?????? ADO Data Control'?.

????? ???????? DataField ????????? (??????? ?? ??????) ??? ????, ???????? ???????? ????? ???????????? ? ?????? ???????? ?????????? (? ??????????????? ? ???).

?????? ???? ??????????? ????????? ?????????? ????? ???????????? ?????????????????? ???????? ?????????? DataList ? DataCombo. ??? ???????? ?????????? ????????? ??????????? ??????? ?????????????? ? ???? ????????? ????????. ???????? ????? ???????? Active X control, ??? ??? ??? ????????????? ?? ?????????? ?????????? - Microsoft Data List Controls 6.0 (SP3) (OLEDB).

???????????, ??? ??? ?????? ???? ????????? ?????????? ??????? ?? ????? ??? ???????? ?????????? ADO Data Control, ?.?. ?????????? ?????? ????? ??????? ?? ????? ??????? (??? ???????), ? ????????? ???????? ???????????? ? ???? ??????? ?????? ??????.

?????????? ??????????? ???????? ???? ????????? ??????????:

??????, ????????? ? ????? ?????????? ??????????:

?.?. ?????? ????? ???????? ????? ???.

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

 

????????????? DataRepeater.

??????? ?????????? DataRepeater ???????? ????????? ?????????? Active X, ??? ??? ??? ????????????? ??? ?????????? ?????????? ? ??????? ????? ???? Components - Microsoft Data Repeater Control 6.0 (OLEDB).

???? ??????? ?????????? ????????? ?????????? ????????? ??????? ?? ????? ?????. ?????????? ?? ???????? ??????????? ??? ?????????? ???? Active X Control'?, ? ??????? ?????????? ??????????? ?????? ????? ??????. DataRepeater ?? ????????? ??? ??????? ?????????? ? ?????? ????????? ?????????? ?? ????? ???????? ??????.

??? ???? ????? ???????????? DataRepeater, ?????????? ????????? ????????? ?????????????????? ????????:

- ??????? ???? ??????? ?????????? Active X ??? ?????? ???????? ????? ????? ??????

- ???????? ????????? ??????? ?????????? ????????? ???? Components

- ?????? ???????? DataRepeater'? RepeatedControlName, ?????? ?? ???? ?? ??????? ??? ??????? ??????????

- ??????? ADO Data Control, ?????? ??? ???????? (?????????? ???)

- ?????????? ???????? DataRepeater'? DataSource ?? ????????? ADO Data Control

- ???????? ?????? ??????? ???? ?? DataRepeater ? ??????? ? ??????????? ???? ????? Properties

- ??????? ?? ???????? RepeaterBindings

- ?????????? ??????????? ????? ?????????? ?????? Active X ? ?????? ?????? (?.?. ? ?????? Active X ?????? ???? ??????? ???????? ??? ???????? ???????? ????? ??????).

??????? ??????????:

- ????????????? ???????? ???????? ?????????? Active X,

- ????????????? ????????????? DataList ? DataCombo ?????? ????? ????????.

 


4. ????????????? Data Grid Control.

?????? ?????? ????????? ???????????? ??????? ????????? ??????? ????? (? ????????????? ??) - ????????????? ???????? Data Grid. ??????? ?????????? ???????????? ????? ??????? (?????, ???, ????????, ? Excel), ? ??????? ?????? ??????? ????????????? ????? ??????, ?????? ??????? - ?????? ????. ???????????? ????? ???????? ????????????? ?????? ? ???????, ?????????? ?? ??? ???? ?????? ???????. ??? ????????????? ????? ???????? ?????????? ??? ?????????? ?????????? - Microsoft DataGrid Control 6.0 (SP4) (OLEDB).

? ??????? ???????? ?????????? ????? ???????, ?????? ?????? ?? ??? ???????? ????? ????? ??? ????????? DataGrid.

?????????? ?????????????????? ?????? ? DataGrid:

- ??????? ADO Data Control, ?????????? ??? ? ???? ??????

- ????????? DataGrid ?? ?????

- ???????? ????? ???????? DataSource ??? ADO Data Control

- ????? ??????? ?????? ?????? ???? ?? DataGrid'? ???????? ?? ??????????? ????, ?? ???????? ???????? ????? Retrieve Fields

- ????? ????? ????????? ??????? ????? ???????????????? ??????? ????? (????), ? ??????? ??????? ? ???????????????? ??????

- ??? ????, ????? ????????? ????????? ????? ? ?????? ?????????, ?? ???????????? ?? ?????? ?????? ???? ???? ???????? ????? Properties

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

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

 


5. ?????? ? ????? ?????? ????? ??????? ADODB.

????????? ?????? ADO ?????????? ????? (?????????) ??????????????? ????????, ??????? ????? ?????????????? ? Visual Basic, Visual C++, VBScripting, Java ?? ????? ?????????, ??????? ???????????? COM ? ????????????? OLE. ????????? ?????? ADO ??????????? ??? ?????????? ??????????? ???????????? OLE DB.

ADO ???????? ???? ????????:

? ?????? ?????? ???????? (?????????):

??????? Connection, Recordset ? Command ???????? ????????? ????????? ? ????????? ?????? ADO. ADO ?????????? ????? ???????????? ?????? Connection ??? ????????? ?????????? ? ???????? ??, ?????? Command - ??? ?????? ??????? ? ??, ????? ??? ???????, ?????????? ? ?.?. ? ?????? Recordset - ??? ????????? ? ??????????????? ???????. ????????? ????, ???????????? ? ???????? Command, ??????? ?? ?????????? ??? ??. ? ?????? ??????????? ??? ?????? ? ???????? ?????????? ????? ????????? SQL.

? ?????? ???????? Errors ? ??????? Error ????? ???????? ?????? ????? ?????? Connection ????? ???? ??? ????????? ?????? ??????????. ? ?????? ???????? Fields ? ??????? Field ????? ???????? ?????? ????? ?????? Recordset ????? ???? ??? ? ??????? Recordset ???????? ?????-???? ??????. ?????????? ? ?????????? ??????? Recordset ????? ???? ??????????? ????? ????? ???????? Fields ? ?????? Field.

 

?????? Connection.

?????? Connection ????????? ????????????? ?????? ????? ? ??????????? ??????. ?????? Connection ???????????? ???????? ??? ????????????? ? ???????????? ??????????, ?????????? ???????? ? ????????????? ??????????.

????? Open ??????? Connection ???????????? ??? ????????? ??????????. ????? ??????????? ?????????? ????? ?????????? ?????? ??????????, ????-??? ??????????, ?? ?? ????????? ? ???????? ??????????. ?????? Connection ??? ?? ????????? ?????????? ???????? CommandTimeout ??? ???? ????????? ????????, ????????? ? ?????? ???????????. ?????????? ?????? Open ???????? ?????? ??????????. ??? ????, ????? ????? ?? ????????, ???????? ?? ????? ????????? ??????? ADO Data Control ? ???????? ? ??????? ??????? ?????? ??????????. ????? ?????? ?????????? ?? ? ??????????? ? ?????? Open, ? ????????? ?????? ???????.

??????? ???? ??????????? ? ?????????????? ?????? Execute.

????? ?????? ? ?? ?????????? ??????? ?????????? ??????? Close ? ???????? ?????????? ???? ADODB.Connection.

??????:

Dim Conn1 as ADODB.Connection

Conn1 = New ADODB.Connection

Conn1.ConnectionTimeout = 100

Conn1.Open "Driver={SQL Server};Server=Server1;Uid=sa;Pwd=;Database=pubs"

Conn1.Execute "DELETE * FROM Table1"

Conn1.Close

Conn1 = Nothing

 

?????? Command.

?????? Command ????????? ?????????? ??????? ? ??. ??? ??????? ????? ???????? ?????? ???????? ? ????????? ? ????????? ?????????, ?? ?? ?????????????? ?????? ?????????.

?????? Command ????? ??? ????????? ????? ??????????, ??? ? ???????????? ??? ???????????? ?????????? ??? ?????????? ????????, ? ??????????? ?? ????????? ???????? ActiveConnection. ???? ???????? ActiveConnection ??????????? ? ??????? ?? ?????? Connection, ?? ?????? Command ????? ???????????? ???????????? ?????????? ?? ??????? Connection. ???? ???????? ActiveConnection ???????????? ??????? ??????????, ?? ??? ??????? Command ????? ??????????? ????? ??????????. ??? ?????? ??????? Connection ????? ?????????????? ????????? ???????? Command.

?????????? ???????? ????? ???????????? ????? ???????, ????????????? ?????? ??????? ??? ?? ???????????? ??????? ???????. ????????, ?????????? ???????? ????? ???????? ?????? (data definition language - DDL) ?? ?????????? ??????? ???????. ?????????? ????????? SELECT ????? ???????????? ????? ??????? ? ?????????? ?????? SELECT ?????????? ??? ???????? ????????? ?????????? ????? ??? ???? ????? ???????.

?????? ??????? ???????????? ????????? CommandText. ?????? ??????? ????? ???? ?????????? ?? ??????????? ????? ??????????????? ??????? (data manipulation language - DML) ? ?????????????? SELECT, INSERT, DELETE, ??? UPDATE ?????????? ??? ?? ????? ???????? ??????, ???????? CREATE ??? DROP. ? ?????? ??????? ????? ????? ???? ??? ???????? ????????? ??? ???????.

??? ?????? ??????? ???????????? ????????? CommandType. ???????? ???????? CommandType ????? ???? ??????????: adCmdText, adCmdTable, adCmdStoreProc ? adCmdUnknown. ????? ??????? ??????? ???????? SQL ????????, ???????? CommandType ?????? ???????????? ??? adCmdText. ???????? adCmdStoreProc ??? adCmdTable ???????????, ???? ?????? ??????? ???????????? ??? ???????? ????????? ??? ??? ???????.

? ????????? ??????? ???????? ?????????? ????????? SELECT, ??????? ?????????? ?????? Recordset:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

...

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

?????? RecordSet.

?????? Recordset ???????????? ?????? ??? ??????????????? ???????? ??????. ?????? Recordset ????????? ?????????, ???????, ????????? ?????? ? ???????????? ?? ??????? ??????? ??????. ? ??????? ?????? ???????? Fields ? ??????? Field ????? ???????? ?????? ? ????? ?????????? ??????. ?????????? ??????? Recordset ????? ???? ??????? ?????????? ??? ? ???????? ??????. ??? ???????? ??????? Recordset ????????????? ??????????? ??????.

?????? Recordset ????????? ?????????? ??? ??????? ???? ???????????? ??? ?????? ??????????????? ?????? ??????. ????????? ???????? CursorType ????? ?????????? ??? ???????: forward-only, static, keyset-driven, ??? dynamic. ??? ??????? ?????????? ????????? ??????? Recordset ??? ????????? ??????? ??????/????? ??? ??? ?????????? ???????. ??? ??????? ????? ?????? ?? ????????? ?????????? ???????.

?? ????????? ??? ??????? ??????????????? ? forward-only ?????? ??? ??????. ???? ?????????? ?????? ?????? ?????? ? ???????????????? ?????? (forward), ?? ???????? ??? ??????? ?? ???????. ? ?????? ???????, ????? ?????????? ??? ??????? ? ??????????? ?? ???????? ??????.

????? ???????? Fields ? ?????? Field

????? ???????? Fields ? ?????? Field ????????? ???????? ?????? ? ?????? ????? ??????? ? ??????? ??????. ? ?????? ???????? Fields ????? ???????? ?????? ????? ?????? Recordset. ? ??????? Field ????? ???????? ?????? ????? ????? ???????? Fields ????????? ??????. ?????? Field ????? ???????????? ??? ??????????? ????? ?????? ??? ??? ????????? ??? ???????????? ?????? ? ????? ???????????? ?????? AddNew, Update ??? UpdateBatch ??????? Recordset ??? ??????? ????? ??? ????????? ???????????? ??????.

??????:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Dim Fld1 as ADODB.Field

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

For Each Fld1 In Rsc1.Fields

Debug.Print Fld1.Name

Debug.Print Fld1.Type

Debug.Print Fld1.Value

Next

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

Fld1=Nothing

???????? ?? RecordSet'? ?????????????? ? ??????? ????????? ??????? ????? ???????:

????? ???????, ???????? ?? ???? ??????? ? ?????? ????? ????????? ???????:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

Rsc1.MoveFirst

Do While Not (Rsc1.EOF)

... ?????-?? ???????? ? ??????? ???????

Rsc1.MoveNext

Loop

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

 


???????????? ???????: ?????? ? ??????????? ADOX.

1. ???????? ? ADOX.

ADOX ???????????? ????? ?????????? ?????????? ADO, ??????????? ? ??????? ?????? ? ????????? ?????????, ??????? ? ???????? ????????? ??? ??????, ? ????? ????????? ??????????? ???????????? (?????????????? ? ?.?.). ???? ? ??????????? ????? ?????? ???????? ????????? ?????????????? ?? ?????? SQL, ? ????????? ????????? ????? ? ??????? ???????? SQL. ?????? ??? ?????? ???? ??????? ????? ????????? ?????????, ????? ??? ? ????????? ????????????, ??????? Microsoft ?????? ??????? ??????? ???????? ????????? ??? ?????? ? ????????? ?????????? ???????????? ?????????? ??? ????????????, ?????? ?????? ?????????? ADOX, ??????????????? ?????? ????????? ? ????????? ????.

??? ????? ?????????? ???????? ????????? ? ?????? ?????????? ??????? ??????????? ???????? ???? ?????? ? ??????? ADOX, ????????????? ?? ??????? ????? ?? ?????? P:\PREP\System_Program\VB\Sample\DataBase\CreateDB\ADOX.htm. ? ???????? ?? ??????? ???? ???????????? ??????? ????????????? ADO ? ADOX.

 

2. ??????????????? ??????.

?????????? ??????????? ??????????, ???????????? ADOX.

?????????? ?? ??????? ???????????? (????????, ????? ????) ??????? ???? ?????? MS Access ????????????? ??????? (?????? ???? ???? ?? ???? ????? 1-??-??????) ? ??????? ???????? ADOX, ? ????? ????????????? ??????????? ????????????? ? ????????????? ??????? ???? ? ???? ???????? (?.?. ???????? ?????? 1 ?????? ????????????). ?????? ? ???????? ?????? ?????????????? ??????? DataCombo ??? DataList, ??????????? ????? 1-??-?????? ? ?????? ????????.

????? ? ?????????? ?????? ?????????????? ????? ? DataGrid, ??????????? ????????????? ?????? ? ????? ? DataRepeater'??, ??????????? ????????? ?????. ?? ????????? ?????? ????????? ??????? ?? ???? ??? ???????.