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

.

Visual Basic
6:

.

.
.
.
.
.
.
. , .
.

Visual
Basic 6. 19
, ,
, .
.
,

- Active X Windows API.
,
.
Original English language Edition Copyright 1998, Sybex Inc. , . , 2001
, 2001
Published by arrangement with the original publisher, Sybex Inc., U.S.A.

, .
:
l i, ( ) 0, I- l, .
, : .

1. (IDE)
2.
3.
4.
5.

6.
7.
8.
9.
10.
11.
12.
13.
14.
15. - ()
16. IDE
17. ActiveX
18. Visual Basic
19. DLL Windows API



1.
(IDE)
Visual Basic
IDE








Visual Basic!

IDE
Editor
Editor Format
General
Docking
Environment
Advanced


Hello World
?
2.


/


BackColor
BorderStyle
Caption
ControlBox
ForeColor
Height
Icon
Left
MaxButton
MinButton
Name
ScaleMode
ShowlnTaskbar
Width
WindowState




Activate
Deactivate
DragDrop
Load
Resize
Unload

(MDI)
MDI-
MDI-

Form Wizard
?
3.
,















,








Windows 95


















4.
5.
6.




Public Private
(Private)
(Public).

SmartForm
Class Builder
?





Click







?




AND
EQV
OR
XOR
NOT








If..Then...Else
IIf
Select Case...End Select

For...Next
Do...Loop
While...Wend


?
7.


?







Static

?
8.

ASCII-




9.



Visual Data Manager










Memo
/


ADO (ActiveX Data Objects)
ADO

ADO



?


Print



PrintForm
Printers
Crystal Reports Visual Basic
Crystal Reports Pro



Print
10.
11.


?.







?.


Click
DblClick
DragDrop
MouseDown
MouseMove
MouseUp

OLE
OLEDrag
OLEDragMode
OLEDropMode
OLEDropAllowed
OLEDragDrop()
OLECompleteDrag()
OLEStartDrag()
OLEDragOver()
OLESetData()
OLEGiveFeedback()
OLE

?
12.





Visual Basic

Visual Basic

?
13.







HTML
?
14.


Make




Compile
Compile to P-code
Compile to Native Code

Package and Deployment Wizard


?
15.
- ()

?






?
16.
IDE
IDE

VB6

VB6 Application Wizard
VB6 Data Form Wizard





?
17.
ActiveX
Active
ActiveX
ActiveX
Web-
ActiveX
ActiveX
ActiveX

ActiveX DLL
ActiveX Microsoft Word
?
18.
Visual Basic
WebBrowser
Winsock
ActiveX
WebComm
WebComm
DHTML
DHTML Visual Basic
DHTML
IIS
?
19.
DLL Windows API
(DLL)
DLL
DLL
API Viewer
API
API
WavePlayer

SysTray
SysTray

?

...
!

. (Peter
Kuhns) , . (Kim Wimpsett)
(Davina Baum) - , - .
, . (Scott Thompson) -
,
. - (Jefferson McClure), ,
(Cyndy Johnsen), .
, , , , .

!
,
. ! , , , ,

.

Microsoft Visual Basic 6 .


Visual Basic .
Visual Basic .
, ,
, . ActiveX
Internet, .
Windows API Visual Basic ,
.
Visual Basic 6: , Visual Basic.
Visual Basic , ,
,
.
: .
,
.
; , , Windows
. , Visual Basic .

?
Visual Basic,
Visual Basic .
,
. ,
. - , .
! 1,
(IDE), Visual
Basic . 2, ,
Visual Basic. 3,
, ,
. 4, , ,
. ,
, lBar,
5, .
6, , ,
. ,
, -. ,
.
7, ,
(, ),
. , 8,
. , .
Microsoft ActiveX
Data Objects (ADO). 9, ,
Visual Basic Printer. , Visual Basic
Crystal Reports Pro, . 10,
, , Visual Basic.
, ,
. 11, , ,
. ,
(drag-and-drop). ,
OLE.

12, , , .
.
.
.
13, , ,
Help Workshop ,
Visual Basic. WinHelp, ,
HTML, Microsoft .
. 14,
,
. ,
.
, Visual Basic
. 15, - (),
.
, !
16, IDE ,
Visual Basic . ,
, ,
. 17, ActiveX,
ActiveX. ,
ActiveX .
- 18. 18, Visual
Basic, Internet .
- WebComm. Internet Visual Basic, .
, 19, DLL Windows API, ... ,
. , ,
. Visual Basic Windows API
.
, , ,
.

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


,
:
, Visual Basic
.
> . , File > Exit ,
File, Exit.
+ . , Ctrl+Alt+Del ,
Ctrl Alt , , Del.
, , .
, ,
, , .
,
, .
(_) ,
. , ; Visual Basic
.


? Web-
. : http://www.piter-press.ru

Visual Basic
IDE


IDE


. ,
.
,
! ,
.
, , ,
.
,
BASIC ( Beginners ll-Purpose Symbolic
Instructional Code )
. , BASIC
. Microsoft Visual Basic 6
.
Visual Basic .
Visual Basic
. -
, . , Visual Basic
, .
(IDE, Integrated Development Environment). He
.
. Visual Basic
, , .

Visual Basic
Visual Basic 6 Visual Basic.
Windows, C++
. Visual Basic ,
, . Visual Basic
, . , , ,
, , (,

).
.
6 Visual Basic Internet. ,
Web, ActiveX.
, Visual Basic,
Web- Microsoft Internet Explorer 4.
Internet. Visual Basic 6
ISAPI DHTML.
, Web- .
18, Visual Basic. Visual Basic
- , Windows1.
Visual Basic.
,
. ,
.
Visual Basic Project Wizard,
New Project (. 1.1).

. 1.1. New Project Project Wizard

,
. : New ( ), Existing (
) Recent ( ).
New, Visual Basic .
, Visual Basic.
New :
Standard EXE ( -);
ActiveX EXE (- ActiveX);
ActiveX DLL (DLL- ActiveX);
ActiveX Control ( ActiveX);
VB Application Wizard ( Visual Basic);
Data Project ( );
IIS Application ( IIS);
Add-in ();
ActiveX Document DLL (DLL- ActiveX);
ActiveX Document EXE (- ActiveX);
1

Windows Explorer . . .

DHTML Application ( DHTML).


.
Standard EXE, 17, ActiveX,
ActiveX.
Existing . ,
Visual Basic, , .
Visual Basic, .
, Recent .
Existing, ,
, .
Visual Basic . ,
Don't Show This Dialog in the Future.
, , Visual Basic
.
Don't Show This Dialog in the Future .
; , ,
.

(IDE) Visual Basic.

IDE
Project Wizard , IDE (. 1.2).
Visual Basic;
.

. 1.2. (IDE) Visual Basic

IDE ,
. ,
. ,
IDE. ,
.
IDE :
;
;
;
;
;
;
;
.

IDE!
,
. , IDE,
( , ,
), .
IDE. ,
. .
, , , .
IDE Visual Basic,
!


, Visual Basic.
, Windows.
. File.
, . , ,
.
(. ).
File Edit.
, . ,
. Find IDE.
, .
Visual Basic.
View .
,
, .
. Project .
, , ,
ActiveX . ,
OLE, .
.
Format .
Debug.
, ,
, .
Run.
, .
.
Tools . ,
, 5,
. Options IDE.
Add-Ins , (add-ins).
Visual Data Manager Add-In Manager. Visual Data Manager
,
, Microsoft Access. 16, IDE
, Add-In Manager , Add-Ins.
Window IDE ( ). ,
.
, .
IDE.
Help , . ,
.


Visual Basic (. 1.3). ,
View > Toolbars > Standard. , Visual Basic
, .

. 1.3. Visual Basic

,
. , .

. ,
.

IDE . View >


Toolbars , .
,
.


, Visual Basic,
. :
1. .
2. Customize... .
3. Customize : Toolbars, Commands Options. Toolbars
, . ( IDE, ,
, , ; ,
.)
4. .
.
5. I,
. , ,
.
.
, .

, , Reset
. Close.



, .
:
1. .
2. Customize... .
3. Commands Customize.
4. Categories Built-in Menus.
5. Help Visual Basic Commands.

, Help Visual Basic.


6. Help Commands .
7. Save.
, .
, .
( Windows,
. IDE,
. 11, .


(. 1.4).
,
.

. 1.4.
Windows:
.
, , .
, , Visual Basic
.VBP ( Visual Basic Project, . . Visual
Basic).
, . . , .
. 4,
.

, .
.

, View Object (
, , View Code).
, ,
. , ,
.
,
Remove...
Remove.
Visual Basic ,
. .
, .


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

. 1.5.
, . ,
, , . ,
(Caption , Height , Width . .).
. ,
, .
, .
, .
- , F1.
,
.

, (. 3,
), .
, ,
.
. ,
.
.
IDE (design time),
. ,
- . ,
. .
,
. .
,
. .

.
Visual Basic IDE ,

. , ,
.
.
, File > New Project.
Project Wizard, Standard EXE ,
-.


:
1. Form1, .
True False ( ),
. MaxButton Form1 False.
2. Run > Start ,
( ). , ,
.
, Run > End Visual Basic,
End , []
Form1. .


(
),
. , ,
.
BorderStyle ( ) Form1:
1. Form1, .
2. rderStyle.
:
0-None . .
1-Fixed Single
.2
BorderStyle 2-Sizable. ,
.
- ,
, BorderStyle 3-Fixed Dialog. ,
Windows, .
, , ,
BorderStyle 4-Fixed Tool Window 5-Sizable Tool Window
, .
3. BorderStyle 3-Fixed Dialog.
.
4. Run > Start, .
. ,
.
5. Close ( ).


,
. - Name Caption .
, ,
.
( ),
Delete Backspace. ,

. - . .

Enter ,
.
:
1. , .
2. Name ( ).
, Form1.
3. frmMain. ,
.
Visual Basic,
. Backspace,
.

4. Enter, Name frmMain.


5. Caption; , Form1.
6. Caption, .
Visual Basic . Name
, , Caption ,
.


(, BackColor , )
. , , .
. Palette
, ,
. System ,
(Control Panel) Windows. ,
View > Color Palette.
, .
BackColor ( ForeColor FillColor
). :
1. BackColor ,
.
2. Palette, .
3. , .
, BackColor
.
4. BackColor System.
5. Button Face. Window Background, .
Windows ,
. .
, ,
System. ,
. .


(None).
. , . ,
Icon ,
. Windows 95 Windows NT
( ). \Graphics\Icons Visual Basic
, .
(None), Delete.
:
1. Icon frmMain. Load Icon.
2. Face02.ico \Graphics\Icons\Misc. Open.


Left, Top, Width Height ,
. ,
: ,
() Left , .
, Width Height.
,
.


, (. 1.6).
, ,
.

. 1.6.
, .
:
1. , .
2. Run > Start.


, ,
. , . 1.7 ( -
), , .
. Visual
Basic , , .
. 3 .
Visual Basic .

. 1.7. Visual Basic


6 Visual Basic.
, .
, , Internet,
. Internet :
1. .
2. Add Tab.
3. Visual Basic , Internet.
4. .
5. , ;
, (
, Internet).
6.
(, Microsoft
),
Components ( Project > Components).
7. , (
Microsoft Internet Controls).
8. OK, .
. ,
, , .


, Custom
Controls. : , , , .
Internet:

1. .
2. Components.
3. ,
. Microsoft Internet Controls.
4. .
.
.
Visual Basic , (
).
,
(. 1.8). ; , .

. 1.8.
, ,
Visual Basic .
,
.


(. 1.9) , ,
. View > Object
Browser F2. 15, -
().

. 1.9.

Visual Basic!
, Unix, !
- vi Unix, ,
.
.
Visual Basic (. 1.10).
. ,
, .

. 1.10. Visual Basic


, . , .
View Code .
, .
, .

, .
4.

, - . ,
. . ,
. Visual Basic , .
IDE
(. ). ,
.
.


Visual Basic .
.
, ActiveX ( 17,
ActiveX) ,
.
, Visual Basic,
. :
1. MSDN Library - Visual Basic Setup
(Add/Remove Program) .
2. / (Add/Remove), .
3.
MSDN Library - Visual Studio 6.0,
Add/Remove.
4. MSDN Library - Visual Studio . VB
Product Samples. , Select All.

5. Continue, .
,
:
1. File > Add Project.
2. Add Project Existing.
3. FirstApp.vbp \MSDN98\98vs\1033\Samples\VB98\ Firs.
4. Open; FirstApp IDE.
5. File > Add Project, .
6. Existing .
7. Controls.vbp \MSDN98\98vs\1033\Samples\VB98\ Controls;
Controls IDE.
, .
, . ,
ActiveX.
,
. .

IDE
6 Visual Basic
, . ,
, ,
. IDE Tools > Options.
Options IDE, .

Editor
Editor (. 1.11).
,
Editor.

. 1.11. Editor
Code Settings , .
Tools > Options :
Auto Syntax Check,
. ,
.
Require Variable Declaration,
.

Auto List Members,


, .
. , , .
Require Variable Declaration .
Option Explicit General Options , .
.
, .
.
, .

Auto Quick Info,


. ; Visual Basic
.
Auto Data Tips, ,
. .
Auto Indent, ,
. .
, .
, .
Tab ,
Tab. ,
. .

Window Settings :

Drag-and-Drop Text Editing,


.
Default to Full Module View,
. ,
.
Procedure Separator, ( Default to Full
Module View) .
.

Editor Format
. 1.12, , .
, .

. 1.12. Editor Format

General
General (. 1,13) IDE ,
, . ,
. .
Form Grid Settings .
. .
Error Trapping .
,
. , .
, (Break in Class Module).

Compile :

Compile on Demand, Visual Basic


. Run > Start.
.
Enable Background Compile , Visual Basic
. .

General :

Show Tool Tips Visual Basic

, .
, Visual Basic.
Collapse Proj. Hides Windows,
.

. 1.13. General

Docking
Docking (. 1.14) , IDE
. , .

. 1.14. Docking.

IDE ,
. ,
, IDE. Co IDE ,
, IDE.


, ,
. ,
,
Hello World.

. Hello World
Visual Basic IDE. ,
, Hello World.

Hello World
Hello World :
1. File > New Project , Visual Basic
, . No;
, Yes.
2. , View > Form Layout Window.
3. .
Startup Position > Center Screen, .

, .
.

4
, .
7 5 .
5 - (Command Button) ,
. .
6 - (Label) ,
. , .
, Hello World.
, .

7.
, . , ,
, .
, F4.
8. , .

Caption
Name


frmHelloWorld

, Caption, .
Name . 3 ,
frmHelloWorld Form1, Caption
. Name Name,
, .
9. - .

Name
Text

IblHelloWorld
Hello World

10. - .

Caption
Name

&
cmdOK

Caption , . - (&)
, (
Alt+).
(, ).
11. cmdOK. ( )
. Click.
( ) cmdOK_Click (. 1.17).
Private Sub; , cmdOK_Click ,
, cmdOK, , .

Puc. 1.17.

12. PrivateSub EndSub :


Unload Me
Set frmHelloWorld = Nothing

cmdOK, cmdOK_Click.
, .
, .
13.
File > Save Project. frmWorld.frm
HelloWorld.vbp. .
, .
, .

14.
: Name (frmHelloWorld),
Caption ( ) (frmWorld.frm). ,
. Caption , Name
, .

14. Run > Start. ,


Hello World (. 1.18).
15. . - ,
.

. 1.18. Hello World

! ,
Visual Basic!
Visual Basic IDE. Hello World ,
, Visual Basic.
, .

?
:

Visual Basic .
Project Wizard .
, .
.
IDE.
IDE .
.






(MDI)

Form Wizard

Visual Basic. Visual


Basic , ,
. ,
. ,
. ,
(MDI).


, Visual Basic, ,
. ,
. ,
, .
,
. Visual Basic
.
, ,
, .
(.
(MDI)). , Visual Basic File >- New Project.
, (. 2.1).
, , .
,
Windows. , Visual Basic.

. 2.1. -

.
, .
BorderStyle.

( ) .
Windows, .
. ,
.

, . ,
.
.
BorderStyle None, (
) . , Caption
.


, , ,
, . ,
True ControlBox .


, .
, True MinButton
.
MDI .
, (System ), .

/
. ,
.
(MDI) (
(MDI) ). ,
.
, True MaxButton
.


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


1, .
. Visual Basic ,
. -.

ActiveControl
ActiveForm
Appearance
AutoRedraw
BackColor
BorderStyle
Caption
ClipControls
ControlBox
Controls
Count
CurrentX
CurrentY
DrawMode
DrawStyle

DrawWidth
Enabled
FillColor
FillStyle
Font
FontBold
FontItalic
FontName
FontSize
FontStrikeThru
FontTransparent
FontUnderline
ForeColor
hDC
Height

HelpContextID
hWnd
Icon
Image
KeyPreview
Left
LinkMode
LinkTopic
MaxButton
MDIChild
MinButton
MouseIcon
MousePointer
Moveable
Name

NegotiateMenus
Picture
ScaleHeight
ScaleLeft
ScaleMode
ScaleTop
ScaleWidth
ShowInTaskbar
Tag
Top
Visible
WhatsThisButton
WhatsThisHelp
Width
WindowState

, . ,
(
), . :
-. 3,
, .
, . Name Steve,
EyeColor ( ) Blue (). Name
Susan, EyeColor Brown ().
. - ,
, (
, ).



F1. , Caption .

( )
. (Contents, Index, Search Favorites)
Visual Basic.
, , , .
6, Microsoft Microsoft Developer Network (MSDN)
HTML. 13, .

(
;
).

BackColor
BackColor, 1, .
, .
BackColor ,
.
,
, . ,
Designed for Windows.

Border-Style
BorderStyle , .
, . . ,
. . 2.1
BorderStyle.
2.1. BorderStyle

-None

. ,
, ,
.
,

Visual
Basic
Windows.



,
,
.

.

-
,
ControlBox False

(

). ,

Click ,

(,
frmFormName.Hide)
Fixed Dialog,
( ,

).

To , Sizable,
. Windows 95
,

1 - Fixed Single

2 - Sizable

3 - Fixed Dialog

4 Fixed
ToolWindow

5 Sizable
ToolWindow



Hello World, 1. Hello World,
File > Open Project , 1.
1. , .
2. Hello World , ,
BorderStyle 3 - Fixed Dialog.
3. Hello World Run > Start.
.
.

Caption
, .
BorderStyle None, ( ) .
Caption ,
.

ControlBox
True False ,
. , BorderStyle, ControlBox, MaxButton MinButton .
, ,
. BorderStyle
FixedToolWindow, , .
Hello World, .
:
1. .
2. ControlBox False.
3. (Run > Start).
( ), ( ).
.

ForeColor
, , -
, . ,
, ForeColor . , Print,
. ,
. , BackColor.
( . 3)
:
1. File > New Project.
2. Form1 , - .
3. , , Click( )
.
4. Click :
Print "Hello World"

, BackColor ForeColor .
, . , BackColor ForeColor
, :
, BackColor = ForeColor

Height
Height . ,
. Height ( Width, Left )
(twips).
, Visual Basic.
, Height Width.
:
1. Width 3600.
2. Height 3600.
,
. , ,
, .

, , :
1. , . ,
,
Form Load; ,
Load -. 4,
.
2. , Resize.
Resize .
3. Resize : Width = Height
4. Run > Start.
, .
.
, .
. ,
. - ,
. .

Icon
, .
Icon ,
. 1. ,
, BorderStyle Fixed Dialog.
Visual Basic,
\Graphics\Icons, , Visual Basic CDROM. , Windows 95
.

Left
Height Width, .
, Left .
, .
:
1. , .
2. , Resize.
3. Resize Width = Height:
Left=(Screen.WidthWidth)/2
Top=(Screen.HeightHeight)/2

4. .
,
. , Resize :
Width=(Screen.HeightHeight)/2

MaxButton
MaxButton True,
; , ,
False.

MinButton
MinButton True,
. , ,
False.
, , ,
, .
MaxButton MinButton False.

Name
, Name Visual Basic. , Visual
Basic . , ,
frm. Hello
World 1, , frmHelloWorld.
, 20 30 ! ,
, Form17 Form20; frmLogon
frmChangePassword .
.

3 ,
.

ScaleMode
Height, Width, Left ,
,
.
, ScaleMode 3 - Pixel.

ShowInTaskbar
, .
( )
, , False.
Load :
PrivateSubForm_Load()
ShowInTaskBar=False
EndSub

Width
. Height
.

WindowState
WindowState . ,
.

0
1
2

Normal
Minimized
Maximized


, .
(, BorderStyle),
. ,
(, hWnd), .
,
.

Caption , .
: .
.
1. (File > New Project) Form1 Name
frmForm1. ,
Caption .

2. - , .
Name cmdHello, Caption &11.
3.
, cmdHello_Click.
( . . 2.2):
IffrmForm1.Caption="??????"Then
frmForm1.Caption="????"
Else
frmForm1.Caption="??????"
EndIf
If-Then-Else . If ,
Then, Else.
6.

Puc. 2.2.
4. (Run > Start) .
Caption . .
2.3, "", "". (
Else) "".

. 2.3. Caption


.
Click. , :

IffrmForm1.Caption="??????"Then
frmForm1.Caption="????"
cmdHello.Caption="&??????"
Else
frmForm1.Caption="??????"
cmdHello.Caption="&????"
EndIf
- .
, , .
, .


. 2.4, ,
Caption :

cmdHello.Caption = "&"
cmdHello.Caption = "&"

Windows 95,
. , ,
, .
, , Caption ,
.
:
1. ,
Form_Load.
2. ( Private Sub End Sub),
. 2.5:

cmdHello.Caption = "&"

. 2.4. Caption

. 2.5. Load
3. (Run > Start) .
? , ,
. .
Private Form_Load 4.


, , ,
. Windows . ,
.
. , , ,
. ., Windows , ,
. , ,
. ,
, .
. , .
, .
Activate
Click

KeyDown
KeyPress

LostFocus
MouseDown

OLESetData
OLEStartDrag

DblClick
KeyUp
Deactivate LinkClose
DragDrop
LinkError

MouseMove
Paint
Mousellp
QueryUnload
OLECompleteDrag Resize

DragOver
GotFocus

OLEDragDrop
OLEDragOver

LinkExecute
LinkOpen

Initialize Load

Terminate
Unload

OLEGiveFeedback

(, , ) .
.
. , ,
, .
Object, (. 2.6):

. 2.6. ,


Visual Basic , .
Activate.

, (
, ) F1.

,
, Activate Load. ,
, . -
. . , ,
,
, .

Activate
Activate Load.
, , Initialize GotFocus. ,
, .
, .
,
, . :
Initialize. .
Load. , .
Load, .
Activate. Activate , ,
.
GotFocus. , , , .
GotFocus Activate,
, , Initialize.
, Visual Basic .
Run > Start. Load -
, Visual Basic .
( , )
Activate. GotFocus.

,
. , ,
Got Focus Got Focus .
, Load
, Activate. , .
,
Activate, Load. , Load ,
.
: Load,
Activate. (
), Activate,
Load.

Deactivate
Deactivate Activate. ,
. Windows
(, ).

DragDrop
, .
Hello World , .
DragDrop , , .
, ,
, :
1. DragMode Automatic.
2. : Drag Icon,
.
3. , .
4.
DragDrop
.
5. , DragDrop :
PrivateSubForm_DragDrop(SourceAsControl,XAsSingle,YAsSingle)
Print"??????????????"
EndSub
DragDrop , ,
. ,
. ( )
. ,
Windows.

Load
Load Initialize, Activate
. , .
,
.

Load/Unload Activate/Deactivate
, . Windows
, Load.
. ,
:

PrivateSubForm_Load()
Move(Screen.WidthWidth)/2,(Screen.HeightHeight)/2
EndSub
, .

Activate. , .
Activate .
Activate , .
.
Deactivate , .
, .
, Unload ,
. .
.

Resize
Resize , .
:
, ;
.
Height Width .
Height Width.
. ,
MaxButton MinButton False.

Unload
Unload Load.
, , (
, QueryUnload, ).
Unload , , .
(Cancel As Integer), .
, :
1. (File > New Project) Standard EXE.
2. Form1 , .
3. Unload.
4. Unload :
PrivateSubForm_Unload(CancelAsInteger)
IfMsgBox("????????",vbYesNo,"??????")=vbYesThen
UnloadMe
SetForm1=Nothing
Else
Cancel=1
EndIf
EndSub

5. Run >- Start.


6.
. ;
Unload.
MsgBox , .
10, .

Unload, Visual Basic


, . Yes,
. , No, Cancel 1
.
(, ),
, .
Unload , .


, , .
, .
, Unload , .

, :

Circle
Cls
Hide
Item
Line

Move
PaintPicture
Point
Print
PrintForm

PSet
Refresh
Scale
SetFocus
Show

TextHeight
TextWidth
Unload
ZOrder

Show,Hide?Unload , .
, .

(MDI)
, MDI-. MDI
-. ,
( Word for Windows) (. 2.7).
, . MDI-
, Windows.
, .
, .

. 2.7. -
MDI - (,
). -,
.
, MDI. Visual Basic MDI.

MDI-
MDI- ()
(). ,
. MDI- .
:
1. File > New Project. Project Wizard,
Standard EXE.
2. . Name
frmChild, Caption MDI.
3. MDI, Forms
Add > MDI Form. Form Wizard,
MDI Form.
4. Name frmMDI, Caption MDI
5. Project1
Project1 Properties. Startup Object frmMDI. ,
.
6. frmChild. MDI Child True -
.
7. frmMDI.
8. Tools > Menu Editor. , . 2.8.

. 2.8.
.
- 5,
.
1. &File Caption.
2. mnuFile Name.
3. Next.
4. .
5. &New Form Name.
6. mnuFileNew Name.
7. .
8. frmMDI File. File > New,
.
9. mnuFileNew_Click() :
DimfrmAsNewfrmChild
frm.Show

10. . MDI-.

frmChild .
File > New. ; ,
MDI-.

MDI-
MDI- Windows,
. ,
, ; .
, . ,
, ,
.
1. , frmMDI,
&Window. WindowList .
2 Tile Cascade. mnuWindowTile mnuWindowCascade
.
3. .
4. Click mnuWindowTile :
frmMDI.ArrangevbTileHorizontal
5. Click mnuWindowCascade :
frmMDI.ArrangevbCascade
vbCascade vbTileHorizontal Visual Basic.
.
6. mnuFileNew:
PrivateSubmnuFileNew_Click()
StaticCounterAsInteger
DimfrmAsNewfrmChild
Counter=Counter+1
frm.Caption="?????????????MDI"&Counter
frm.Show
EndSub

7. . . 2.9 .


,
. .

, ,
.
(Static Counter As Integer) Visual Basic Counter.
Static , Counter .
Counter .

. 2.9. MDI-
(Dim frm As New frmChild) Dim.
, frm,
frmChild. New Visual Basic , ,
, .
Counter ,
:
Counter = Counter + 1

, Counter 3, 3 1,
4. Counter Static, ,
Counter 5, 6 . .
(frmCaption = " MDI" & Counter) Caption
, " MDI" , Counter.
, Caption " MDI 2".
, , . Visual Basic .
, ,
Load. .

Form Wizard
Visual Basic,
( MDI-). (SDI)
MDI,
MDI-. ,
;
. Visual Basic 6 : Form Wizard
.
Add > Form - Form Wizard Add
Form (. 2.10).

. 2.10. Form Wizard


, About (About Dialog), (Splash Screen),
(Tip of the Day) - (Web Browser)!
Wizard, Visual Basic .
Form Wizard ,
.
,
, Form Wizard.

Form Wizard :
1. Add
> Form. Form Wizard.
2. - About Dialog Add
Form. frmAbout.

3. frmMDI , MDI-.
4.
&New Form. , (...).
, . Caption
&Help, a Name mnuHelp.
5. Next, .
6. mnuHelp
. Caption &About, a Name mnuHelpAbout.
, Help .
.
7.
Project1 Properties.
8. Project Properties Make.
9. Title MDI-.
10. Version Information Company Name
Value.
11. Product Name MDI-,
.
12. Help > About MDI-, .
13. mnuHelpAbout_Click() : frmAbout.Show vbModal
14. About (. 2.11).

. 2.11. About, Form Wizard


vbModal. 4,
, .
vbModal , Show . Visual Basic ,
About .
.
, .
. ,
, ,
.
- . , ,
. -
. ,
. .
Visual Basic , .
.

?
:

.
Visual Basic.
.
.
MDI- .
Form Wizard.






Windows 95

, Visual Basic .
, ,

.
Visual Basic 6. ,
, . !
.


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

(
).
. ,
, . ,
, (. 3.1).
, .
Visual Basic 6 ,
.
, (, Winsock Internet Control)
Internet. . ,
ActiveX .
.
17,
ActiveX.

. 3.1. Visual Basic

, Windows
(. ). Visual Basic.
,
. ,
Cancel .
, ,
. ,
.
: . ,
, , .


. , ,
. , ,
F1.
Appearance
Enabled
hWnd
Style
BackColor
Font
Index
Tablndex
Cancel
FontBold
Left
TabStop
Caption
FontItalic
MaskColor
Tag
CausesValidation FontName
MouseIcon
ToolTipText
Container
FontSize
MousePointer Top
Default
FontStrikethru Name
UseMaskColor
DisabledPicture FontUnderline OLEDropMode Value
DownPicture
ForeColor
Parent
Visible
DragIcon
Height
Picture
WhatsThisHelpID
DragMode
HelpContextID RightToLeft Width
Name Caption. Visual Basic

. Name
. Caption , .
(&) .
Alt ,
. , Tab
.
, ,
. , , ,
, .
, .

Cancel Default. Default


True, Enter.
Cancel True, Esc .
, Default
True; . ,
Cancel True.

Style,
. , , ,
Picture.
( ) DisabledPicture DownPicture. ,
Enabled Visible, . - False,
. ,
(, )
.
, False Enabled,
Visible. , ,
; .

Tablndex Tab. ,
Tablndex 0, ( ,
). Tablndex
. , Tab,
TabStop False; , ,
. ,
Enabled Visible.


, , , Click.
.
MouseUp
OLEGiveFeedback
KeyPress
LostFocus
MouseMove

OLECompleteDrag
OLESetData
DragDrop
GotFocus

OLEDragDrop
OLEStartDrag
KeyUp
MouseDown

OLEDragOver
Click
DragOver
KeyDown

, Click.
, ,
Visual Basic. , Click
MouseUp. Windows 95 ,

Click.


, SetFocus.

Drag
SetFocus

Move
ShowWhatsThis

OLEDrag
ZOrder

Refresh

SetFocus . ,
, .
:
cmdMyButton.SetFocus
Change .


:
1. -
\MSDN98\98vs\1033\Samples\VB98\Controls\Controls.vbp3.

Visual

Basic,

-,

1 , .
.

2. Run > Start. Control Examples


Test Buttons , . 3.2.

. 3.2.
3.
, .
, .

.
4. Run > End.
5. Test Buttons, frmButton .
6 ,
. Style 1 - Graphical.
7. Visible imgGreen, imgYellow imgRed False.
8 Load :
PrivateSubForm_Load()
cmdChange.Picture=imgGreen.Picture
EndSub
9. ChangeSignal:
PrivateSubChangeSignal()
StaticsignalAsInteger
3
, Visual Basic,
. . .

signal=signal+1
Ifsignal>3Thensignal=1
SelectCasesignal
CaseIs=1
CaseIs=1
cmdChange.Picture=imgYellow.Picture
CaseIs=2
cmdChange.Picture=imgRed.Picture
CaseIs=3
cmdChange.Picture=imgGreen.Picture
EndSelect
EndSub

10. (Run > Start). Test Buttons,


.
, .
, .
Click ,
. , , Click :
PrivateSubcmdChangeSignal_Click()
End
EndSub
, -
Style 1 - Graphical. Picture
.


Visual Basic (.
).
. , .
, InputBox
, ,
. Visual Basic InputBox MsgBox (
) 10, . MsgBox
.


. , ,
.
Alignment
Font
Linkltem
RightToLeft
Appearance
FontBold
LinkMode
ScrollBars
BackColor
FontItalic
LinkTimeout SelLength
BorderStyle
FontName
LinkTopic
SelStart
CausesValidation FontSize
Locked
SelText
Container
FontStrikethru MaxLength
Tablndex
DataChanged
FontUnderline MouseIcon
TabStop
DataField
ForeColor
MousePointer Tag
DataFormat
Height
MultiLine
Text
DataMember
HelpContextID Name
ToolTipText
DataSource
HideSelection OLEDragMode Top
DragIcon
hWnd
OLEDropMode Visible
DragMode
Index
Parent
WhatsTnisHelpID
Enabled
Left
PasswordChar Width

, Name.
txt. Caption,
Text. Text,
. , .
Text. MaxLength

PasswordChac, , (
, *). MaxLength PasswordChar
, . Multiline
, .
ScrollBars,
(, ).
SelLength, SelStart SelText . ,
SelText .
.
Readonly Visual Basic
Locked. True,
, . ,
, ,
. ,
. (
), Tablndex. ,
, TabStop False.
, , False
Enabled. .
,
, . Visual Basic
.


, .
Change
KeyDown
LinkOpen
OLEDragQiter
Click
Keypress
LostFocus
OLEGiveFeedback
DblClick
KeyUp
MouseDown
OLESetData
DragDrop
LinkClose
MouseMove
OLEStartDrag
DragOver
LinkError
OLECompleteDrag Validate
GotFocus
LinkNotify OLEDragDrop
Change , ,
. Change
. ,
Key...
, . ,
, . Microsoft
Developer Network, - Visual Basic,
.

Drag
LinkExecute
LinkPoke

LinkRequest
LinkSend
Move

OLEDrag
Refresh
SetFocus

ShowWhatsThis
ZOrder

, Link... ,
DDE (Dynamic Data Exchange). DDE
,

, . , DDE
. , .
, SetFocus .
(, ), . Click
SetFocus, ,
Tab.
:
txtMyTextBox.SetFocus


, SetFocus:
1. \MSDN98\98vs\1033\Samples\VB98\Controls\Controls.vbp,
.
2. Run > Start. Control Examples
Text Box. , . 3.3.
,
. Multiline True,
. , ,
Multiline ScrollBars.

. 3.3.
, ( BorderStyle).
MDI,
. ,
Resize :
txtText1.Top=frmForm1.ScaleTop
txtText1.Left=frmForm1.Scaleleft
txtText1.Width=frmForm1.Width
txtText1.Height=frmForm1.ScaleHeight

Scale... . , Height ScaleHeight


. ScaleHeignt ,
.
3. frmText .
4.
5 ,
:
PrivateSuboptInsert_Click()
?????????????????????5???????

txtDisplay.SelStart=5
???????????????????????????,
???????????????????????????????
txtDisplay.SetFocus
EndSub

SelStart ( ) .
5- . SetFocus
txtDisplay.
5. Click optSelect:
PrivateSuboptSelect_Click()
???????????????????????
txtDisplay.SelStart=0
??????????????????????????????
?????????????????????????????????
txtDisplay.SelLength=Len(txtDisplay.Text)
???????????????????????????,
???????????????????????????????
txtDisplay.SetFocus
EndSub

, .
Select All, .
, , SelText.
6. cmdClose_Click :
PrivateSubcmdClose_Click()
IftxtDisplay.SelLength>0Then
MsgBox"????????????"&txtDisplay.SelText
EndIf
End'??????????????
EndSub

7. . Text Box Properties Multiline


Close. . 3.4.

. .4. SelText

(. )
. ,
( ).
Caption ( Text, ).
. ,
, . .
, ,
Caption .


Alt+. Alt
, .
, Caption, .
(, ) Caption,
Tab ,
.
, .
, Tablndex ,
. (&) Caption ,
.
:
1. Controls.vbp, .
2. frmText , .
3. txtDisplay, ,
Tablndex . 0,
.
4. txtDisplay.
Name IblDisplay. Caption Dis&play. He
.
5. Tablndex IblDisplay 11. 0.
6. Run > Start.
7. Control Example Text Button.
8. Text Box Properties Reset, txtDisplay.
9. Alt , , .
Alt , .
, (. ) , TabStop,
GotFocus LostFocus SetFocus. , ,
,
.


. :

Alignment
Appearance
AutoSize
BackColor
BackStyle
BorderStyle
Caption
Container
DataChanged
DataField
DataFormat
DataMember

DataSource
DragIcon
DragMode
Enabled
Font
FontBold
FontItalic
FontName
FontSize
FontStrikethru
FontUnderline
ForeColor

Height
Index
Left
Linkltem
LinkMode
LinkNotify
LinkTimeout
LinkTopic
MouseIcon
MousePointer
Name
OLEDropMode

Parent
RightToLeft
Tablndex
Tag
ToolTipText
Top
UseMnemonic
Visible
WhatsThisHelpID
Width
Wordwrap

, ( )
Name. 1bl. Caption ,
. (&), .
, ?
; , .
, -,
UseMnemonic False ( True). (mnemonic)
.

. Caption
, , .
, ,
. ,
AutoSize Wordwrap .
, , ,
.
BorderStyle. He
, .
BorderStyle 1 Fixed Single, a BackColor ( ) ,
, .
, .


:
. ,
Key..., , . Mouse,.,
, .
, , . Link...
, .
DDE ( ). Key...
Mouse... 11, .
Change
Click
DblClick
DragDrop
DragOver

LinkClose
LinkError
LinkNotify
LinkOpen
MouseDown

MouseMove
OLEGiveFeedback
MouseUp
OLESetData
OLECompleteDrag OLEStartDrag
OLEDragDrop
OLEDragOver


, , , .
.

Drag
LinkExecute
LinkPoke

LinkRequest
LinkSend
Move

OLEDrag
Refresh
ShowWhatsThis

ZOrder

, LinkRequest
DDE-.


,
. Controls,
:
1. frmMain , .
2. . .
3. Name lblHelp, Caption
.

4. . 3.5 , .

. 3.5.

(. ) ( !) .
(. ),
, . ,
, UPS (United Parcel Service)
. (
). , (, )
- , .


, .

Alignment
Appearance
BackColor
Caption
CausesValidation
Container
DisabledPicture
DownPicture
DragIcon
DragMode
Enabled
Font
FontBold
FontItalic
FontName

FontSize
FontStrikethru
FontUnderline
ForeColor
Height
HelpContextID
hWnd
Index
Left
MaskColor
MouseIcon
MousePointer
Name
OLEDropMode
Parent

Picture
RightToLeft
Style
Tablndex
TabStop
Tag
ToolTipText
Top
UseMaskColor
Value
Visible
WhatsThisHelpID
Widht

Name;
opt. Caption ,
. Value ,
. ,
( ) . Value
: True False. Value
True False. ( !)
. True
Value , .
6 Style. (0 - Standard)
, , .

1 - Graphical, , ,
.
,
, Style 1 - Graphical.
, Picture.


, , Click.

Click
DblClick
DragDrop
DragOver
GotFocus

KeyDown
KeyPress
KeyUp
LostFocus
MouseDown

MouseMove
MouseUp
OLECompleteDrag
OLEDragDrop
OLEDragOver

OLEGiveFeedback
OLESetData
OLEStartDrag
Validate

Value ,
. , .
Value Click ,
.
If... End Select Case... End Select.
, Click.
:
1. Controls Run > Start.
2. Option Buttons Control Examples.
3. .
Caption Click .
4. Close.
5. Exit Control Examples.
, :
1. frmOptions , .
2. 486, .
:
PrivateSubopt486_Click()
????????????????????????????????????
strComputer="486"
???????????????????
CallDisplayCaption
EndSub

Click strComputer 486,


, . 3 (General)
( ). (DisplayCaption)
. DisplayCaption:
SubDisplayCaption()
'?????????????????????????????????????????????????
lblDisplay.Caption="??????????????????"&_
strComputer&"?????????"&strSystem
EndSub

Caption lblDisplay ,
Click .


Visual Basic .

Drag

OLEDrag

SetFocus

ZOrder

Move

Refresh

ShowWhatsThis

.
Control.vbp. Option Buttons -
Options (. 3.6).

. 3.6. Options
. 486, Pentium Pentium Pro
, Windows 95 Windows NT
.
. - ,
. .

(. ) -, .
, Value
. :
, ,
. ( )
. , Value .
, , , Value
True False. : ,
. , ,
. ,
. ,
( ) . . 3.7,
, . Windows 95,
. ,
( ) Windows 95.


.
Alignment
DownPicture
Height
Appearance
DragIcon
HelpContextID
BackColor
DragMode
hWnd
Caption
Enabled
Index
CausesValidation Font
Left
Container
FontBold
MaskColor
DataChanged
FontItalic
MouseIcon

RightToLeft
Style
Tablndex
TabStop
Tag
ToolTipText
Top

DataField
DataFormat
DataMember
DataSource
DisabledPicture

FontName
FontSize
FontStrikethru
FontUnderline
ForeColor

MousePointer
Name
OLEDropMode
Parent
Picture

UseMaskColor
Value
Visible
WhatsThisHelpID
Width

, Name, Caption Value.


( Name) chk.

. 3.7. , ,


, .
Click
DragDrop
DragOver
GotFocus
KeyDown

KeyPress
KeyUp
LostFocus
MouseDown
MouseMove

MouseUp
OLECompleteDrag
OLEDragDrop
OLEDragOver
OLEGiveFeedback

OLESetData
OLEStartDrag
Validate

Click.
Click
, Value.

Drag
Move

OLEDrag
Refresh

SetFocus
ShowWhatsThis

ZOrder

, .
, , Controls Check Box.

Check Box Example ,


(. 3.8).

. 3.8. Check Box Example


, - .
, FontBold Click.
PrivateSubchkBold_Click()
???????Click?????????????????????????????????????.
????????Value??????????????????????????????.
IfchkBold.Value=1Then'????????????????????
txtDisplay.FontBold=True
Else'??????????????
txtDisplay.FontBold=False
EndIf
EndSub


, :
1. File > New Project.
2. Name Form1 frmMain.
3. . Name chkOptions, Caption
:.
4. chkOptions, .
(General) (Declarations) :
PublicPeanutButterAsBoolean
PublicJellyAsBoolean

5. MouseUp chkOptions :

PrivateSubchkOptions_MouseUp(ButtonAsInteger,ShiftAsInteger,_
XAsSingle,YAs,Single)
frmOptions.ShowvbModal
IfPeanutButterAndJellyThen
chkOptions.Value=1
ExitSub
EndIf
IfPeanutButterOrJellyThen
chkOptions.Value=2
ExitSub
EndIf

IfPeanutButterAndNotJellyThen
chkOptions.Value=3
ExitSub
EndIf
EndSub
6. Add >
Form. ( Form) Add Form.
7. Name frmOptions, Caption
Set Options.
8. frmOptions . Name chk-PeanutButter,
Caption .
9. . Name chkJelly, Caption
.
10. frmOptions, .
Load :

PrivateSubForm_Load()
IffrmMain.PeanutButterThen
ChkPeanutButter.Value=1Else
chkPeanutButter.Value=0
EndIf
IffrmMain.JellyThen
chkJelly.Value=1Else
chkJelly.Value=0
EndIf
EndSub
11. Click chkPeanutButter :
PrivateSubchkPeanutButter_Click()
IfchkPeanutButter.Value=1Then
frmMain.PeanutButter=True
Else
frmMain.PeanutButter=False
EndIf
EndSub

12. Click chkJelly :


PrivateSubchkJelly_Click()
IfchkJelly.Value=1Then
frmMain.Jelly=TrueElse
frmMain.Jelly=False
EndIf
EndSub

13. Run > Start.


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

(. ) , .

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

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


, .
Appearance
BackColor
BorderStyle
Caption
ClipControls
Container
DragIcon
DragMode
Enabled

Font
FontBold
FontItalic
FontName
FontSize
FontStrikethru
FontUnderline
ForeColor
Height

HelpContextID
hWnd
Index
Left
MouseIcon
MousePointer
Name
OLEDropMode
Parent

RightToLeft
Tablndex
Tag
ToolTipText
Top
Visible
WhatsThisHelpID
Width

, ( Name) Caption.
, ,
( ) . /
Caption. ,
, - .


.
Click

MouseMove

OLEGiveFeedback

DblClick
DragDrop
DragOver
MouseDown

MouseUp
OLECompleteDrag
OLEDragDrop
OLEDragOver

OLESetData
OLEStartDrag

. , -
, DragDrop ,
. 11.


.
, Visual Basic.

Drag

OLEDrag

ZOrder

Move

Refresh

ShowWhatsThis

. 3.9 , .
, , ,
. Caption ,
. , Caption .

. .9.

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


,
.
Appearance
BackColor
CausesValidation
Columns
Container
DataChanged
DataField
DataFormat
DataMember
DataSource
DragIcon
DragMode
Enabled
Font

FontBold
FontItalic
FontName
FontSize
FontStrikethru
FontUnderline
ForeColor
Height
HelpContextID
hWnd
Index
IntegralHeight
ItemData
Left

List
ListCount
ListIndex
MouseIcon
MousePointer
MultiSelect
Name
Newlndex
OLEDragMode
Parent
RightToLeft
SelCount
Selected
Sorted

Style
Tablndex
TabStop
Tag
Text
ToolTipText
Top
Toplndex
Visible
WhatsThisHelpID
Width

Columns , -. ,
Visual Basic
Access, . Visual

Basic .
List , .
. 0
, 1 . , 10 ,
0 9.

Visual Basic . ,
Visual Basic.
(Chr(9)).
.
.

Index . ,
. Index .

List . ,
:
lstList1.List(2)

Text. ListIndex
, , ListIndex -1.

IstList1. List(lstList1. ListIndex) IstListl.Text ,

, (. Addltem),
Newlndex. ListCount . 1
Newlndex , 0, ListCount
, 1. ListCount 0.
MultiSelect , .
.
( Shift), ,
.
Ctrl / Shift.
Selected .
True False.
:
IstListl.Selected(2)=True
(2) .
Sorted. - .
, , True False),
, .
Sorted True, , - (
Addltem), -.
.


, ,
Click
DblClick
DragDrop
DragOver
GotFocus
ItemCheck

KeyDown
KeyPress
KeyUp
LostFocus
MouseDown
MouseMove

MouseUp
OLECompleteDrag
OLEDragDrop
OLEDragOver
OLEGiveFeedback
OLESetData

OLEStartDrag
Scroll
Validate

, DblClick.
Windows.
, Addltem (. ). ,
, Selected True.
, .
Text .
.
. Windows
.


,
.

Addltem
Clear
Drag

Move
Refresh
Removeltem

SetFocus
ShowWhatsThis
ZOrder

Addltem, Clear Removeltem. ,


, . , Removeltem
. , Clear.
Addltem :

IstListl.Addltem ""
"".
Addltem . Addltem
Form_Load, . ,
:
IstListl.Addltem"??????",3
"" . ,
, , Sorted True,
.

.
.
, .


, . ,
:
1. , File > New Project. Project Wizard
Standard EXE.
2. Form1 .
3. , .
, .
4. , .
Load :
PrivateSubForm_Load()
List1.Addltem"?????"
List1.Addltem"?????"
List1.Addltem"??????"
List1.Addltem"?????"
Listl.Addltem"???????"

Listl.Addltem"????"
Listl.Addltem"?????????"
Listl.Addltem"??????"
Listl.Addltem"???????"
EndSub
5. DblClick Listl :
PrivateSubList1_DblClick()
'???????????????????????????
List2.AddltemListl.Text
'????????????????????????????
Listl.RemoveltemListl.ListIndex
EndSub
6. DblClick List2:
PrivateSubList2_DblClick()
'???????????????????????????
Listl.AddltemList2.Text
????????????????????????????
List2.RemoveltemList2.ListIndex
EndSub
7. Run > Start.
. ,
5 6, , .
Addltem Removeltem,
. .


(. ).
.
( ) ,
. ,
. , ,
. ( ,
Visual Basic)
, .
, .
: ,
. Style.
, ( Style)
, . Text
. Text
,
, .
Style .
, .
(, DBCombo
), .


.
Appearance
BackColor

FontItalic
FontName

ListCount
ListIndex

Style
TabIndex

CausesValidation
Container
DataChanged
DataField
DataFormat
DataMember
DataSource
DragIcon
DragMode
Enabled
Left
Sorted

FontSize
FontStrikethru
FontUnderline
ForeColor
Height
HelpContextID
hWnd
Index
IntegralHeight
ItemData
SelText

Locked
MouseIcon
MousePointer
Name
NewIndex
OLEDragMode
Parent
RightToLeft
SelLength
SelStart
FontBold

TabStop
Tag
Text
ToolTipText
Top
TopIndex
Visible
WhatsThisHelpID
Width
Font
List

List, ListCount, ListIndex, Newlndex Sorted


. Style.
, - . 0-2
, , ,
.
,
. ,
. (
), .
.

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


, .
Change
Click
DblClick
DragDrop
DragOver

DropDown
GotFocus
KeyDown
KeyPress
KeyUp

LostFocus
OLECompleteDrag
OLEDragDrop
OLEDragOver
OLEGiveFeedback

OLESetData
OLEStartDrag
Scroll
Validate

.
DropDown , ,
.
Change ( 2),
.
, Click DropDown.
DblClick ,
. DblClick Click
. , ,
.

Addltem
Clear

Move
OLEDrag

Removeltem
SetFocus

ZOrder
Drag

Refresh

ShowWhatsThis

Addltem, Clear Removeltem - . ,


, Addltem Load
.
(
Microsoft Access)
? , ?
, Addltem? -,
.VBP? , Addltem
.
, RowSource ListField
( ) .
, (DBList
DBCombo).
Microsoft Developer Network.
, .
. ,
,
. Click
DblClick :
PrivateSubcboItems_DblClick()
cmdAdd_Click
EndSub
. 3.10.
, .
, .
,
.
PrivateSubForm_Load()
?????????????????????
LstItems.AddItem"??????"
LstItems.AddItem"?????????"
LstItems.AddItem"????????"
LstItems.AddItem"?????????"
LstItems.AddItem"??????"
LstItems.AddItem"??????"
??????????????????????????????????
cboCombination.AddItem"?????????"
cboCombination.AddItem"?????"
cboCombination.AddItem"??????"
cboCombination.AddItem"?????????"
cboCombination.AddItem"???????????"
cboCombination.AddItem"????"
EndSub

. 3.10.


,
. ,
.
1. , Name
IstGroceries.
2. Name
cboProducts, Caption .
3. . ,
Caption .
4. . Caption
.
5. . Name cmdAdd,
Caption - &.
6. Form_Load:
PrivateSubForm_Load()
??????????????
LstGroceries.Clear
'??????????????????????????????????
cboProducts.AddItem"????"
cboProducts.AddItem"????"
cboProducts.AddItem"????"
cboProducts.AddItem"????????"
cboProducts.AddItem"???????"
cboProducts.AddItem"???????"
EndSub
7. cmdAdd_Click:

PrivateSubcmdAdd_Click()
IstGroceries.AddItemcboProducts.Text
EndSub
8. . . ,
.
9. .
. , .

, ,
cmdAdd_Click: Click True
Value (, cmdAdd.Value = True).

( img) ,
.
. ,
.
, .
-, Visual Basic, (.BMP),
(.ICO), (.WMF), JPEG (.JPG) GIF (.GIF). ,
World Wide Web .


, .

Appearance
DataFormat
DragMode
Left

BorderStyle
DataMember
Enabled
MouseIcon

Container
DataSource
Height

DataField
DragIcon
Index

MousePointer

Name

OLEDragMode

OLEDropMode

Stretch
WhatsThisHelpID

Tag
Width

Parent
Top

Picture
Visible

, Picture. ,
- ,
True False. False ( )
. , ,
,
. Stretch True,
. Stretch AutoSize.
AutoSize True,
. Stretch
.


, .
Click
MouseDown
OLEDragDrop
OLEStartDrag

DblClick
MouseMove
OLEDragOver

DragDrop
MouseUp
OLEGiveFeedback

DragOver
OLECompleteDrag
OLESetData

. ,
, .
11

Drag
Refresh

Move
ShowWhatsThis

OLEDrag
ZOrder

, .
Visual Basic .
\Graphics\Icons Visual Basic, -.


:
1.

Samples\VB98\Controls\.

Controls.vbp

\MSDN98\98vs\1033\

2. Images.
. 3.11, ,
, . .

. 3.11.

Private Sub imgClub_Click()


shpCard.Left = imgClub.Left
picStatus.Cls
picStatus.Print "" End Sub Private Sub imgDiamond_Click()
shpCard.Left = imgDiamond.Left
picStatus.Cls
picStatus.Print "" End Sub Private Sub imgHeart_Click()
shpCard.Left = imgHeart.Left
picStatus.Cls
picStatus.Print "" End Sub private Sub imgSpade_Click()
shpCard.Left = imgSpade.Left
picStatus.Cls
picStatus.Print ""
End Sub
,
. shpCard. Left = -500 Load .
, Visible False.


, (. )
(, , , JPEG GIF).
.
- . ,
.
. ,
, . ,
.
, .
, . ,
.
.


. ,
.

Align
AutoSize
CausesValidation
CurrentX
DataField
DataSource
DrawMode
DrawStyle
DrawWidth
Enabled
FillColor
FillStyle
Font
FontBold
FontItalic
FontName
FontSize
FontStrikethru
FontTransparent
FontUnderline
ForeColor
Parent

Appearance
BackColor
ClipControls
CurrentY
DataFormat
DragIcon
Height
HelpContextID
hWnd
Image
Index
Left
Linkltem
LinkMode
LinkTimeout
LinkTopic
MouseIcon
MousePointer
Name
OLEDragMode
OLEDropMode
hDC

AutoRedraw
Borderstyle
Container
DataChanged
DataMember
DragMode
RightToLeft
ScaleHeight
ScaleLeft
ScaleMode
ScaleTop
ScaleWidth
Tablndex
TabStop
Tag
ToolTipText
Top
Visible
WhatsThisHelpID
Width
HasDC
Picture

, .
. , .
AutoSize True, .
Pictu - 1
, .
Image. 1
. :

Picture2. Picture = Picture!. Image


, . ,
, .
1 (
Picture). , .
:
Picture1. Picture = LoadPicture ("filename")
, Visual Basic Load
Picture() :
Picture1. Picture = LoadPicture()


:
Change
Qlick
DblClick
DragDrop
DragOver
GotFocus
LostFocus

KeyPress
KeyUp
LinkClose
LinkError
LinkNotify
LinkOpen
OLEGiveFeedback

MouseDown
MouseMove
MouseUp
OLECompleteDrag
OLEDragDrop
OLEDragOver

OLESetData
OLEStartDrag
Paint
Resize
Validate
KeyDown

, , Click DragDrop.
, Click . DragDrop 11,


, , .
, , .
Circle
Cls
Drag
Line
PaintPicture
ShowWhatsThis

LinkRequest
LinkSend
Move
OLEDrag
SetFocus

PSet
Refresh
ScaleX
ScaleY
LinkPoke

TextHeight
TextWidth
ZOrder
LinkExecute
Point

Circle, Cls, Line, PaintPicture, Print PSet


Cls (
DOS ) . ZOrder
, Format > Order > Bring To Front Format >
Order > Send To Back. ZOrder, .
, , ZOrder
. , (,
), . ( )
.
, , Circle, . ,
,
. , ZOrder
. ZOrder
.

Z- , , .
Format >
Order > Bring to Front Format > Order >. Send to Back,
ZOrder.

(. ) ,
. ,
, . -
.


, :

Enabled
Left
Tag

Index
Name

Interval
Parent

Name ( tmr),
Enabled Interval. , -
, (,
Enabled True). Left
. Interval
. , , 1000.
( , )
Timer. .

Interval .
, Interval , 1000. ,
Interval 0 ( ) 65 535 (65,5 ).


C Timer. ,
, Interval.
, Enabled False.


, , :
1. File > New Project Standard EXE.
2. Name Form1 frmMain, Caption - .
3. frmMain. Name tmrTime.
4. Interval 500.
. - , Visual Basic ,
.
5. (General) (Declarations) frmMain:
Option Explicit
Private OldCaption As String

6. Form_Load:

Private Sub Form_Load()


OldCaption = Me.Caption
End Sub
7. Timer :

Private Sub tmrTimer_Timer() Dim msg As String


msg = OldCaption & " : " & Time$ Caption = msg
End Sub
8. Run > Start.
. 3.12.

. 3.12. -
, , .
,

Timer:

PrivateSubtmrTimer_Timer()
DimmsgAsString
msg=OldCaption&":"&Time$
Ifmsg<>CaptionThen
Caption=msg
EndIf
EndSub
If...Then , , Time$ msg
Caption, Caption .
] Caption .

Format, .
, ,
.
. Format Format Function See Also .


(. ) - ,
\ .
, (
). ,
. , .
, .
.
, , . .
,
.
,
. , .
, Set
Focus. , , Change .

CausesValidation
Enabled
Index
Min
Parent
TabStop
Visible

Container
Height
LargeChange
MouseIcon
RightToLeft
Tag
WhatsThisHelpID

DragIcon
HelpContextID
Left
MousePointer
SmallChange
Top
Width

DragMode
hWnd
Max
Name
Tablndex
Value

Max, Min, LargeChange SmallChange.


Min , Value.
Min (, 0), .
,
:

PrivateSubForm_Load()
hscVolume.Min=0????????????????????
hscVolume.Max=255?????????????????????
EndSub
LargeChange , Value,
. SmallChange Value
. ,
-^ , , Visual Basic
- . ,
- ,
. ,
Value Change .
, Value ,
. ,
, :
PrivateSubForm_Load()
hscVolume.Min=0????????????????????
hscVolume.Max=255?????????????????????
hscVolume.Value=128'??????????????????????????????????????
EndSub
Value, LargeChange SmallChange ,
Min . Value Min ,
. LargeChange
SmallChange. , Min, .
, Min .


,
:
Change
KeyDown
Scroll

DragDrop
KeyPress
Validate

DragOver
Keyllp

GotFocus
LostFocus

Change Scroll. Value


. , Value ,
(SmallChange) (LargeChange) .
Value ,
Min.
Change , ,
. Change
, Scroll. Scroll
. Change, .
, , .
, Change.


.
Drag
SetFocus

Move
ShowWhatsThis

Refresh
ZOrder


.
:
1. File > New Project.

2. Form! . Name
hscVolume.
3. Min hscVolume 0, 100.
Value 50.
4. SmallChange 1, LargeChange 10.
5. , Name IblVolume, Caption
50.
6. Font FontSize 24.
7. AutoSize True.
.
. 3.13.

. 3-13.
8. , .
Change :
PrivateSubhscVolume_Change()
IblVolume.Caption=Trim$(Str$(hscVolume.Value))
EndSub
10. Run > Start.
.
. ,
.
Trim$ Str$. Str$ . ,
Caption IblVolume
Variant, Value . ,

Str$(hscVolume.Value)
Caption. Trim$ ,
. ,
:
Trim$(Str$(hscVolume.Value))

API.


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


,
Appearance
DragIcon
Font
FontSize
HelpContextID
hWnd
Index
Left
List
ListCount

BackColor
DragMode
FontBold
FontUnderline
ListIndex
MouseIcon
MousePointer
Name
OLEDropMode
Parent

CausesValidation
Drive
FontItalic
ForeColor
Tablndex
TabStop
Tag
ToolTipText
Top
Toplndex

Container
Enabled
FontName
Height
Visible
WhatsThisHelpID
Width

( Name) drv.
( Name) Drive,
. , .
,
Change (. ).


,
.
Change
DragDrop
DragOver
GotFocus

KeyDown
KeyPress
KeyUp
LostFocus

OLECompleteDrag
OLEDragDrop
OLEDragOver
OLEGiveFeedback

OLESetData
OLEStartDrag
Scroll
Validate

Change. ,
. Drive
. ,
. , , ,
(. ).


.
Drag
SetFocus

Move
ShowWhatsThis

OLEDrag
ZOrder

Refresh


, (. )
(. ) .
. ,
. ,
. Path Change .


, .
Appearance

FontName

List.

Tablndex

BackColor
CausesValidation
Container
DragIcon
DragMode
Enabled

FontSize
FontStrikethru
FontUnderline
ForeColor
Height
HelpContextID

ListCount
ListIndex
MouseIcon
MousePointer
Name
OLEDragMode

Font
FontBold
FontItalic

hWnd
Index
Left

OLEDropMode D
Parent
Path

TabStop
Tag
ToolTipText
Top
Toplndex
Visible
WhatsThisHelpI
Width

( Name) dir. Path,


, ,
. Change ,
. Path
Change
.


, .
Change
Click
DragDrop
DragOver
KeyPress

GotFocus
KeyDown
KeyUp
MouseMove
MouseUp

LostFocus
MouseDown
OLEDragOver
OLEGiveFeedback
OLESetData

OLECompleteDrag
OLEDragDrop
OLEStartDrag
Scroll
Validate

Click,
Change.


, ,
:
Drag
Move

OLEDrag
Refresh

SetFocus
ShowWhatsThis

ZOrder


(. ) .
, Path (. 3.14).

. 3.14. ,
, Change
. , ,
, .
, (.
).


, .
Appearance
Archive
BackColor
CausesValidation
Container
DragIcon
DragMode
Enabled
FileName
Font
FontBold
FontItalic

FontName
FontSize
FontStrikethru
FontUnderline
ForeColor
Height
HelpContextID
Hidden
hWnd
Index
Left
List

ListCount
ListIndex
MouseIcon
MousePointer
MultiSelect
Name
Normal
OLEDragMode
OLEDropMode
Parent
Path
Pattern

Readonly
Selected
System
Tablndex
TabStop
Tag
ToolTipText
Top
Toplndex
Visible
WhatsThisHelpID
Width

. Path
. , , .
Path Visual Basic , .
Path FileName, , , .
.

, .
, ,
.
, False Enabled, , False
Visible.
Path ( ) (

). ,
. ,
, :
1. Drive1_Change :
Did.Path = Drivel.Drive
. ,
Path Change .
.
2. Change :
Filel.Path = Dirl.Path
( Path )
.
.
Pattern , .
Pattern *. *, .
, , ,
*. txt .
Archive, Hidden, Normal, Readonly System
. Hidden System False
.
,
. Hidden System True.


, .
Click
DblClick
DragDrop
DragOver
GotFocus
KeyDown

KeyPress
KeyUp
LostFocus
MouseDown
MouseMove
MouseUp

OLECompleteDrag
OLEDragDrop
OLEDragOver
OLEGiveFeedback
OLESetData
OLEStartDrag

PathChange
PatternChange
Scroll
Validate

.
Click , Path
FileName . ,
. , ,
DblClick Click .
PathChange PatternChange .
Path. , PatternChange
Pattern. ,
Pattern. PatternChange
, - - , *. ini.


, .
.

Drang
Move

OLEDrag
Refresh

SetFocus
ShowWhatsThis

ZOrder


,
WinSeek.vbp.
(, .AVI, . 3.15).

1. WinSeek, WinSeek. vbp


\MSDN98\98vs\1033\Samples\VB98\FileCtls\.

. 3.15. WinSeek

2. :, .
3. . :\.
4. (, *. AVI).
, .AVI.
5. Search , WinSeek .
. 3.16.

. 3.16. WinSeek

WinSeek, Run End Visual


Basic. frmWinSeek, .
Change drvList dirList. drvList_Change:
PrivateSubdrvList_Change()
OnErrorGoToDriveHandler
dirList.PathdrvList.Drive
ExitSub
DriveHandler:
drvList.Drive=dirList.Path
ExitSub
EndSub
, On Error.

. ,
-, ,
. , . ,
, Change ,
Path. , , Change .
,
, . ,
Change .
PrivateSubDirList_Change()
'?????????????????????????????????_
'??????????????????
filList.Path=dirList.PathEndSub
, .
.
Change .


, .
Visual Basic , .
- .
:

, .
.
.

, :
1. , .
2. Add Tab...
3. Visual Basic , ??????????????
.
4. ?????????????? . ,
.
5.

Components.
6.
Controls Components ]
Microsoft Windows Common Controls 6.0 (. 3.17).

. 3.17.

7. , .
, , .
, .

. , :
1. .
2. Rename Tab.
3. , .
4 .
.
, . -
. , .

Windows 95
Visual Basic
, , Windows 95
Windows NT.
Windows :
(Tree View), (List View), (Image List),
(Status Bar) .
. 5,
.
. 3.18 Windows.
.

. 3.18. Windows

, , .
, , ,
.
-.
: .
. .
,
.
. . ,
, / ,
.
, .
.

(. ) ,
.
( ),
.


, .
Appearance
BorderStyle

Height
HelpContextID

MouseIcon
MousePointer

SingleSel
Sorted

CausesValidation
CheckBoxes
Container
DragIcon
DragMode
DropHighlight
Enabled
Font
FullRowSelect

HideSelection
HotTracking
hWnd
ImageList
Indentation
Index
LabelEdit
Left
LineStyle

Name
Nodes
Object
OLEDragMode
OLEDropMode
Parent
PathSeparator
Scroll
SelectedItems

Style
Tablndex
TabStop
Tag
ToolTipText
Top
Visible
WhatsThisHelpID
Width

,
.
, Name.
tvw. , ,
tvwDirectories.
Custom ,
(. 3.19).

. 3.19.
General.

General
Style . .

0 - tvwTextOnly

1 - tvwPictureText
2 - tvwPlusMinusText


/
( )

/,

3 - tvwPlusPictireText

4 - tvwTreeLinesText


,

,


/,

5 - tvwTreeLinesPictureText
6 - tvwTreeLinesPlusMinusText
7 - tvwTreeLinesPlusMinusPictureText

LineStyle . .

0 - TreeLines

1 - RootLines

(
)

, .
, , .

Label Ed it
. , ,
Windows. , .
True , False .
, ImageList -
(. ).
BorderStyle Appearance .
OLEDragMode ( ).
:

0 - OLEDragManual
1 OLEDragAutomatic
OLEDropMode
OLE. (. ).
Indentation ,
. , .
, 283 - .

0 - OLEDropNone

1 - OLEDropManual

OLE,

PathSeparator - ,
Full Path :

PrivateSubTreeViewi_NodeClick(ByValNodeAsNode)
DimrcasString
rc=Node.FullPath
MsgBoxrc

EndSub
, \ (
). IP- . ().
Scroll True, , .
, . Scroll
False, .
, HotTracking True, ,
, (. 3.20).

. 3.20.


, .

AfterLabelEdit
BeforeLabelEdit
Click
Collapse
DblClick
DragDrop
DragOver

Expand
GotFocus
KeyDown
KeyPress
KeyUp
LostFocus
MouseDown

MouseMove
MouseUp
NodeCheck
NodeClick
OLECompleteDrag
OLEDragDrop
OLEDragOver

OLEGiveFeedback
OLESetData
OLEStartDrag
Validate

AfterLabelEdit() ,
. ,
BeforeLabelEdit(), .
CollapseO .
. ,
.
Expand() Collapse(). ,


.
.
NodeClick() .
, , ,
. , :
PrivateSubtvwNodes_NodeClick(ByValNoeAsComctlLib.Node)
MsgBoxNode.FullPath
EndSub
, .
PathSeparator \, :, Windows,
: \Windows. OLECompleteDrag ,
OLE OLE .
OLEDragDrop() , OLE
OLEDropMode, 1 - Manual. ,
. ,
.
.
OLEDragOver OLE .
, Visual Basic OLEGive Feed back,
.
OLEGiveFeedback() OLEDragOver().
,
, . ,
(-) , ,
.
OLESetData() - GetData
DataObject .
, OLEStartDrag() ,
. OLEDragMode 1 - Automatic,
. DataObject .
-.


- :

Drag
GetVisibleCount
HitTest

Move
OLEDrag
Refresh

SetFocus
ShowWhatsThis

StartLabelEdit
ZOrder

GetVisibleCount , .
,
. ,
.
HitTest , .
OLE,
.
OLEDrag OLE. OLEStartDrag
, -.
StartLabelEdit ,
. , LabelEdit
False, . Windows
- ,
(, ).
-, ,
-: .

, .
, .


:
AllowColumnReorder
Appearance
Arrange
BackColor
BorderStyle
CausesValidation
CheckBoxes
ColumnHeaderlcons
ColumnHeaders
Container
DragIcon
DragMode
DropHighlight
Enabled
FlatScrollBar
Font
ForeColor
FontName
FullRowSelect
GridLines

Height
HelpContextID
HideColumnHeaders
HideSelection
HotTracking
HoverSelection
hWnd
Icons
Index
LabelEdit
LabelWrap
Left
Listltems
MouseIcon
MousePointer
MultiSelect
Name
Object
OLEDragMode
OLEDropMode

Parent
Picture
PictureAlignment
SelectedItem
SmallIcons
Sorted
SortKey
SortOrder
Tablndex
TabStop
Tag
TextBackground
ToolTipText
Top
Visible
WhatsThisHelpID
Width
View

Custom , Visual Basic


(. 3.21). ,
.
, Name.
Ivw. , ,
IvwFiles.
.
.

. 3.21.

General
, General, ,
.
View .

0 Ivwlcon
1

IvwList

IvwReport

IvwSmalllcon

,

IvwList,

Ivwlcon,

Arrange .
( ). Arrange
.

0
1

- IvwNone - IvwAutoLeft

- IvwAutoTop

Label Edit
. , ,

Windows. , .
True , a False . OLEDragMode
( ). :

0 - OLEDragManual
1 OLEDragAutomatic
OLEDropMode OLE
. .

0 - OLEDropNone

OLE,

1 - OLEDropManual

ColumnHeaders False, Hide Column Headers


( ).
LabelWrap, ,
. , True.
, True MultiSelect.
, False.
FullRowSelect ,
. True,
, .
, True
GridLines.
, .
True GridLines FullRowSelect, .
, IvwSheet :

WithIvwSheet
.View=IvwReport
.GridLines=True
.FullRowSelect=True
EndWith
True HotTracking, , ,
.
HoverSelection . True,
.

Image Lists
Image Lists ,
. ,
ImageList - (.
).
, Small, SmallIcons
. ,
, .
ColurnnHeader ,
.

Sorting
Sorting ,
.
Sorted . ,

. , Sorted False.
Sort Key .
0, Text . ,
Subltems.
SortOrder . 0
, 1 .

Column Headers
Index Column Header .
Text , Visual Basic Text
ColumnHeader , Index. Alignment :

0 - IvwColumnLeft
1 - IvwColumnRight
2 IvwColumnCenter
ColumnHeader (,
, ). , Width, Width
ColumnHeader. , Index.
Key .
, . ,
. Tag Tag . xpa
, .
Iconlndex , - .
, ,
, 3.


, .

AfterLabelEdit

DragOver

KeyUp

OLEDragDrop

BeforeLabelEdit
Click
ColumnClick
DblClick
DragDrop

GotFocus
ItemCheck
ItemClick
KeyDown
KeyPress

LostFocus
MouseDown
MouseMove
MouseUp
OLECompleteDrag

OLEDragOver
OLEGiveFeedback
OLESetData
OLEStartDrag
Validate

, . After Label Edit


, .
. ,
Befrelabel Edit, , .

, , .
, (subitems).
.
ColumnClick , .
,
. Windows , ,
. ,
. ItemClick .
, ,
, .
NodeClick -.
OLECompleteDrag , OLE
OLE .
OLEDragDrop() , OLE
OLEDropMode, 1 - Manual. ,

. ,
.
.
OLEDragOver OLE .
, Visual Basic OLEGiveFeedback,
.
OLEGiveFeedback() OLEDragOver().
,
, . ,
(-) , .
.
- OLESetData() - GetData
DataObject .
, OLEStartDrag() ,
. OlEDragMode 1 - Automatic,
. DataObject .
-.


,
. , .
Drag
Findltem
GetFirstVisible

HitTest
Move
OLEDrag

Refresh
SetFocus
ShowWhatsThis

StartLabelEdit
ZOrder

.
Findltem . .
,
GetFirstVisible , .
HitTest , .
OLE,
.
OLEDrag OLE.
OLEStartDrag , -.
StartLabelEdit ,
. , , Label
Edit False, .
Windows - ,
(, ).
, -
. ,
.


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


.
BackColor
HImageList
ImageHeight

ImageWidth
Index
Listlmages

MaskColor
Name
Object

Parent
Tag
UseMaskColor

Name.
iml. ,
. , tbrToolbar,
imlToolbar.
ImageHeight , a ImageWidth .
, .
, .
MaskColor
, .
. MaskColor
, UseMaskColor True.
. ,
().


,
.


Overlay.
. MaskColor
, . , :
???????????????????1?????????????2
SetPicture1.Picture=imToolbar.Overlay(1,2)
.


, .
, . ,
:
1. Visual Basic File > New -
(Standard EXE).
2.
Projectl Name
ObjectExplorer.
3. Form1 Name frmMain.
4. Caption Object Explorer.
5.
Components.
6. Components
Microsoft Windows Common Controls 6.0. OK, .
7. frmMain ,
. ,
Name imlCategories.
8. Custom,
.
9. Images. Insert Picture, .
10. Select picture Closed.bmp Common\ Graphics\Bitmaps.
Open, , .
11. frmMain . Name imlItems.
imlCategories.
12. 8-10, Leaf.bmp Open.
13. .
14. frmMain. Name tvw-Categories.
15. Custom,
.
16. General Style 7 - tvwTree-HnesPlusMinusPictureText,

LabelEdit 1 - Manual, Indentation 283 ImageList


imlCategories.
17. .
18. tvwCategories .
19. frmMain. Name Ivwltems.
20. Custom,
.
21. View 3 - IvwReport, Arrange 2 -IvwAutoTop,
LabelEdit 1 - Manual, OLEDropMode - 1 - OLEDropManual.
22. Image Lists.
23. Normal imlltems.
imlltems.
24. Column Headers.
25. Insert Column. .
26. Text .
27. .
28. imlltems . .
3.22.
29. File > Save Project.

. 3.22. Object Explorer

30. frmMain, .
31. Form_Resize: Private Sub Form_Resize()
Dimmid1AsInteger
Dimmid2AsInteger
Mid1=(ScaleWidth/2)50
mid2=(ScaleWidth/2)+50
IfWindowState<>vbMinimizedThen
tvwCategories.Move0,0,mid1,ScaleHeight
Ivwltems.Movemid2,0,ScaleWidthmid2,ScaleHeight
EndIf
EndSub
.
, mid1 mid2. ,
. 50,
.
If...Then ,
, . ,
. If...Then
6, .
Form_Load() :

PrivateSubForm_Load()
DimcatAsNode
'????????????????????????
WithtvwCategories.Nodes
Setcat=.Add(,,"root","???????",1)
Setcat=.Add("root",tvwChild,,"??????????,1)
Setcat=.Add("root",tvwChild,,"?????????",1)
Setcat=.AddC'root",tvwChild,,"Internet",1)
EndWith
EndSub
Node. Nodes
. (With...) Visual Basic ,
Nodes tvwCategories.
With .
"", .
(tvwChild).
: ,
. ,
, .
(General)(Declarations) frmMain:
OptionExplicit
PrivateSubListExplorer()
DimitmAsListltem
WithIvwltems.Listltems.ClearSetitm=,Add(,,"??????",1)
Setitm=.Add(,,"???????????????",1)
Setitm=.Add(,,"?????????????????",1)
Setitm=.Add(,,"??????????????????",1)
Setitm=.Add(,,"???????????????",1)
EndWith
EndSub
PrivateSubListlnternet()
DimitmAsListltem
WithIvwltems.Listltems
.Clear
Setitm=.Add(,,"Web???????",1)
Setitm=.Add(,,"ShellFolderView",1)
Setitm=,Add(,,"Inet",1)
Setitm=.Add(,,"Winsock",1)
EndWith
EndSub
PrivateSubListlntrinsics()
DimitmAsListltem
WithIvwltems.Listltems
.Clear
Setitm=,Add(,,"???????????????",1)
Setitm=,Add(,,"???????",1)
Setitm=.Add(,,"?????????????",1)
Setitm=.Add(,,"?????",1)
Setitm=,Add(,,"??????",1)

Setitm=,Add(,,"??????",1)
Setitm=.Add(,,"?????????????",1)
Setitm=.Add(,,"???????????????????",1)
Setitm=,Add(,,"??????",1)
Setitm=.Add(,,"?????????????????????????????",1)
Setitm=.Add(,,"???????????????????????????",1)
Setitm=,Add(,,"??????",1)
Setitm=.Add(,,"????????????",1)
Setitm=.Add(,,"???????????????",1)
Setitm=.Add(,,"????????????",1)
Setitm=.Add(,,"??????",1)
Setitm=,Add(,,"?????",1)
Setitm=.Add(,,"???????",1)
Setitm=.Add(,,"??????",1)
Setitm=,Add(,,"OLE",1)
EndWith
EndSub
, Option Explicit, .
. Listltem itm.
List Items Ivwltems.
With... , Listltems
. , . Clear, Listltems
. Listltem.
, NodeClick() tvwCategories:

PrivateSubtvwCategories_NodeClick(ByValNodeAsComctlLib.Node)
SelectCaseNode
CaseIs="??????????"
Listlntrinsics
CaseIs="?????????"
ListExplorer
CaseIs="Internet"
Listlnternet
EndSelect
EndSub
File > Save F5.
. 3.23. ,
.
. .
, .

. 3.23. Object Explorer

OLE. 11,
.



Windows. .
, Windows.
Windows. ,
, , .

Align
Container
DragIcon
DragMode
Enabled
Font
Height

hWnd
Index
Left
MouseIcon
MousePointer
Name
Object

OLEDropMode
Panels
Parent
ShowTips
SimpleText
Style
Tablndex

Tag
ToolTipText
Top
Visible
WhatsThisHelpID
Width

, , Name. sts.
stsStatus. Panels , .
Style .
.

0
1

sbrNormal
sbrSimple

SimpleText , , Style
1 - sbrSimple.


, .

Click
DblClick
DragDrop
DragOver

MouseDown
MouseMove
MouseUp
OLECompleteDrag

OLEDragDrop
OLEDragOver
OLEGiveFeedback
OLESetData

OLEStartDrag
PanelClick
PanelDblClick

,
. OLE
11. PanelClick PanelDblClick.
PanelClick , .
, ? ,
.
PanelDblClick .
, .
, .


, .

Drag
Move

OLEDrag
Refresh

SetFocus
ShowWhatsThis

ZOrder

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


Object Explorer . ObjectBrowser
File > Open Visual Basic.
1.
frmMain.
. Name stsStatus.
2. Load frmMain.
3.
DimcatAsNode:DimpnlAsPanel
4. With...End:
'????????????????????????????????
WithstsStatus.Panels
Setpnl=,Add(,,,sbrTime)
Setpnl=.Add(,,,sbrDate)
EndWith
5.
NodeClick tvwCategories
Select Case:
DimpnlAsPanel
DimstsAsString
6.

Select... End Select:

'??????????????????????????
sts=IvwItems.Listltems.Count&"????????"
'???????????????????????
WithstsStatus.PanelsO)
.Text=sts
EndWith
7. Form_Resize Move
:
tvwCategories.Move?,?,midl,ScaleHeightstsStatus.Height
lvwltems.Movemid2,0,ScaleWidthmid2,ScaleHeightstsStatus.Height
8. .
. 3.24 .
. , .
.
!

. 3.24. Object Explorer

?
:

, . 0 .
, . 0 .
Windows.



Class Builder

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


Visual Basic

. (
). ASCII-,
, , / .
, , .
. , , ,
. ,
( ). , ,
.
.
ASCII- .
, .
. ,
, .
. , , , -,
.

. Visual Basic
, .
-
() , .
,
,
. .
, , .
, 3, ,
, .
. ,
, - .
15.
, .
, . ,
, .
, .
, -.
, .
, .
,
. , ,
.
, ; , -
. ,
.
,
.
:
! ,
,
.


, , - .
. ,
.
:
1. Windows Windows.
2. ( ) Codelib. ,
.
.

3. Windows.
Windows .
- , Windows .
DOS Unix ,
( ). Windows
.
,
, Codelib.
, :
1. Visual Basic.
2. Add > Add File.
3. Add Module Codelib.


, Tools > Add
Procedure Add Procedure (. 4.1).
.

. 4.1. Add Procedure


.
. :
1. File > New Project.
2. Add > Module.
3. Add Module Module. Open -
.


Tools > Add Procedure , ,
:
1. Public Sub ProcedureName ( ProcedureName ) -
.
, Private Sub ProcedureName Sub
ProcedureName .
2. Enter; Visual Basic ,
Visual Basic .

4 Name
MyLibrary.
5. File > Save MyLibrary
Ctrl+S. Save File As
Codelib, .
.

, ,
.
, . , Addltem
, , . :

Istltems.Addltem "Widgets"
Addltem "Widgets" .
: . ,
.
, .

, .
, .
, ,
, - . ,
- .
, , - .
1. , .
2. MyLibrary ,
Add > Module .
Add Module, Existing. MyLibrary.Bas
Open, .
3. My Library. Bas . .
4. :
Public Sub ShowHourglass()
Screen.MousePointer = 11 End Sub

. ,
, .
5. :

PrivateSubShowMousePointer()
Screen.MousePointer=0
EndSub
6. File > Save MyLibrary Visual Basic.
ShowHourglass ShowMousePointer , ,
. ShowHourglass , a ShowMousePointer
, :

ShowHourglass
IndexLargeDatabase
ShowMousePointer
, ,
.

.
. ,
, . . ,
, .
.
:
1. File > New Project.
2. My Lib ,
Add > Module .
3. Add Module, Existing.
MyLibrary.Bas Open, .
4. MyLibrary.Bas . .
(General)(Declarations):
PublicFunctionCubeRoot
Visual Basic :
PublicFunctionCubeRoot()
EndFunction
5. (. 4.2):

PublicFunctionCubeRoot(xasDouble)AsDouble
Ifx=0Then
CubeRoot=0
ExitFunction
EndIf
CubeRoot=10^((Log(Abs(x))/Log(10))/3)
Ifx<0Then
CubeRoot=CubeRoot
EndIf
EndFunction

. 4.2.
6. File > Save MyLibrary.
, .
. ,
( Double - ,
, ), As.
End Function, End Sub. ,
CubeRoot. ,
( CubeRoot).
TimesTwo(), TimesTwo (, TimesTwo = *2).
, .
, 0 , 0 0,
CubeRoot ,
. Exit Function.
. ,
CubeRoot = 10 ^ ((Log(Abs(x)) / Log(10)) / 3) .
, , .
,
. Visual Basic

CubeRoot=CubeRoot
Exit Function .
.

,
.
7. Form1 .
8. Caption .
9. . Name cmdCubeRoot, Caption
.
10. cmdCubeRoot
cmdCubeRoot_Click().
11. :

DimYAsDouble
Y=CubeRoot(27)
PrintY
. 4.3.

. 4.3. CubeRoot
12. . . 4.4.
.

. 4.4. 3
, (.
4.5). :

. 4.5.
13. , [] .
.
14. Form1 .
15. , Name txtText1.
Text.
16. Click() cmdCubeRoot (Print Y)
:

txtText1.Text=Y
. 4.6.
, :

txtText1.Text=CubeRoot(27)

.

. 4.6.


.
, Run > Break.
, .
, View > Immediate Window. .
, Enter.
, . :
AlterCaption"??????????????"
, .
, , :
PrintCubeRoot(27)
:
?CubeRoot(27)


, ,
.
( ):
1. , File > New
Project.
2. MyLibrary.Bas ,
Add > Module .
3. Add Module Existing, MyLibrary.Bas
Open. .
4. MyLibrary.Bas .
(Genera)(Declarations):
PublicFunctionIsFile(FileNameAsString)AsBoolean
IfLen(Dir(Filename))>0Then
??????????????
IsFile=True
Else

????????????????
IsFile=False
EndIf
EndFunction
5.

File > Save MyLibrary.

IfLen(Dir(Filename))>0Then

, . Dir()
Filename. , ,
(, *. txt), , . ,
FooBar.txt Filename
:\ \F.txt, FooBar, txt.
, Dir() . Dir() Len().
, . , Len("abc")
3, abc . Di() ,
, Len(Dir()) Len("FooBar. txt"),
10. , , Len()
. FooBar. txt 10; , , IsFile
True , . Dir()
, Len() 0. , IsFile
False -, .
, , . -
API.
19, DLL Windows API.

,
. IsFile , .
.
, :
IfIsFile("C:\CONFIG.SYS")Then
...??????????????????????...
EndIf


, ,
. :
, .
, : .
, .
, , . ,
, . ,
. . ,
, , .
.
, . ,
Caption:
1. Standard EXE.
2. Form"). Name cmdCaption,
Caption .
PrivateSubAlterCaption(XAsString)
Caption=X
EndSub

. 4.7. -
X. ,
, () .
, MyTitleText
, MyTitleText . ,
, (
).
(, Click ),
(. ):


. , X.
(. ):

, .
( , , ).
. 4.8.

. 4.8. Caption
, , .
. , , . ,
CreateUser, .
:

CreateUser"???????","123456"

Dim UserlD As String


Dim Password As String
UserlD = " "
Password = "123456"
CreateUser UserID, Password
, .
.
, .
,
( ).
, ,
, . ,
:
DimUserlDAsString
DimPasswordAsString
UserlD="???????"
Password="123456"
IfValidUser(UserID,Password)=TrueThen
????????????????????
Else
????????????????????????
EndIf
, .
.
, .

Optional
,
. Optional:
PublicFunctionCreateUser(UserlDAsString,PasswordAsString,_
OptionalDescriptionAsString)AsBoolean
, Description, . CreateUser
, . ,
, -
Optional.

ByRef, ByVal ParamArray.

ByRef
ByRef , ( Visual Basic
). ,
.
.
:
FunctionFunctionName(ByRefAVariableAsString)AsBoolean

FunctionFunctionName(AVariableAsString)AsBoolean
,
ByRef .
DLL

ByVal
ByVal , . Visual Basic
,
. :
Function FunctionName(ByVal AVariable As String) As Boolean

ParamArray
ParamArray .
, CreateUser
. , ParamArray, ,
Variant.
:
Function FunctionName(ParamArray AnArray() As Variant) As Boolean
:
Dim rc As Boolean
r = FunctionName("",
"",
"",
r = FunctionName("")
r = FunctionName("",
"")

"")

: ,
. ParamArray
, :
Variant , Visual Basic.

Public Private
, Private Public,
.
. Private
, , .
, Public, ,
.
. ,
.

(Private)
,
.
Private, Sub. Private
, , .
, .
\MSN\98vs\1033\Samples\VB98\Controls,
(. 4.9). , .

. 4.9.
, ;
(code behind form F). .
,
.
Private. ,
. ,
,
, , .
Private.
( , ),
Public.
( ) . Private Public ,
.

(Public)
- ,
.
, ,
. ,
, Public .
.
( ) ,
. , Test,
:

Test
, Sub;
. , .
.
, , ,
. , Sub test,
frmForm1, frmForm1.test.


, , , .
().
. 15.
,
.
.
.
Visual Basic , ActiveX
(DLL) ,
OCX. ActiveX World Wide Web (
HTML). 10, , ,
ActiveX DLL. 17, ActiveX,
ActiveX. ,
Visual Basic. ,
.
, .
. ,
, . Visual Basic
. , - .
, .
.
, , ,
Class_Initialize() Class_Terminate():
Class_Initialize()
. ,
.
Class_Terminate() . ,
- .
Class_Terminate.

, .
Private Public . (Public)
, .
(Private) ,
.

. , .
, .
, :

Private Function GetBalance(AccountNo As String) As Double


GetBalance = 10000000
End Function
Public Function DisplayAccountInfo(AccountNo As String,
String) As Double

PIN As _

If AccountNo = "123456" And PIN = "5551289" Then


DisplayAccountlnfo = GetBalance(AccointNo)
End If
End Sub
GetBalance ,
. , , 10
! ,
DisplayAccountlnfo.
(PIN).

3, ,
. , , .
, .
. ,
. ,
. .
Property Get, Property Let Property Set.
Property Get ,
. Property Let
. Property Set .
,
( , ). ,
. Property Get Property Let
. .
AccountNo PIN. ,
. :

Public AccountNo As String


Public PINNo As String
Private Function GetBalanceO As Double
GetBalance = 10000000
End Function
Public Function DisplayAccountlnfo() As Double
If AccountNo = "123456" And PINNo = "5551289" Then
DisplayAccountlnfo = GetBalance()
End If
End Function
Property Let Property Get:
Private AcctNo As String
Private PINNo As String
Private Property Let AccountNo(x As String)
AcctNo = x
End Property
Public Property Let PIN(x As String)
PINNo = x
End Property
Private Function GetBalance() As Double
GetBalance = 10000000
End Function
Public Function DisplayAccountlnfo() As Double
If AccountNo = "123456" And PIN = "5551289" Then

DisplayAccountlnfo = GetBalance()
End If
End Function
Private, .
.
(Public) , .

.
. ,
,
, . ,
.
, , . ,
Form_Load .
Public Event (General)
(Declarations) . :
Public Event

EventName(napa)

: ,
. :
Private WithEvents x As ClassName
,
Private WithEvents p As Person
, Person ().
, Speak.
WithEvents. ,
.
?
.
, .
.
,
.
. ,
, Visual
Basic. , - .
, .
, .
(, )
, .

SmartForm
, .
SmartForm .
. ,
!
1. File > New Project Ctrl+N.
2. New Project Standard EXE.
3.
Add > Class Module .
4. Add Class Module Class Module Open.

5. Name Smart Form.


6. Smart Form , .
7. (General) (Declarations) :

Option Explicit

Private mForm As Object
Private mLeft As Long
Private mTop As Long
Private mWidth As Long
Private mHeight As Long
Private mWS As Integer
Public Event ErrorMessage(Message As String)
.
.
ErrorMessage (Public).
8. Tools > Add Procedure.
9. Add Procedure, Name Form.
10. Property Scope Public.
11. .
: Public Property Get Form() Public Property Let Form(ByVal vNewValue As Variant).
12.

Property Let Form(ByVal vNewValue As Variant)


Let Set. :

Property Set Form(ByVal vNewValue As Variant)


13. Property Get Form():

Form = mForm
14. Property Set Form...:

Set mForm = vNewValue


Variant,
IDE Object.
15. Ctrl+H, .
16. Find What Variant.
17. Replace With Object.
18. ,
Current Project. ,
Current Module.
19. Replace All, Variant Object.
.
20. Cancel.
Visual Basic IDE (,
), .
.

21. (General)(Declarations):

Private Sub SaveSettings()


Dim mAppName As String

' -
mAppName = App.EXEName

' ...
With mForm
If .Name <> " Then
SaveSetting mAppName, .Name, _
"WindowState", Str$(.WindowState)

Else

If .WindowState
= vbNormal Then
SaveSetting
mAppName, .Name,
"Left",
Str$(.Left)
SaveSetting
mAppName, .Name,
"Top",
Str$(.Top)
SaveSetting mAppName,
.Name,
"Width", Str$(.Width)
SaveSetting mAppName,
.Name,
"Height", Str$(.Height)
End If

_
_
_
_

' ErrorMessage
RaiseEvent ErrorMessage(" " _
" !")
End If
End With
End Sub
SaveSetting. Visual
Basic , Windows API.
22. (General)(Declarations) :

Private Sub GetSettings()


Dim mAppName As String
-
mAppName = App.EXEName
With mForm
If .Name <> "" Then
mLeft = Val(GetSetting(mAppName, _
.Name,
"Left",
.Left))
mTop = Val(GetSetting(mAppName, _
.Name,
"Top",
.Left))
mWidth = Val(GetSetting(mAppName, _
.Name,
"Width",
.Left))
mHeight = Val(GetSetting(mAppName, _
.Name,
"Height",
.Left))

.WindowState = mWS
.Move mLeft, mTop, mWidth,

mHeight

Else

ErrorMessage
RaiseEvent ErrorMessage(" "
" !")
End If
End With
End Sub
, (General) (Declarations)

Resize:

Public Sub ResizeO


' ,
'
SaveSettings
End Sub
23. (General) (Form [Property Set]):

Public Property Set Form(ByVal vNewValue As Object)



Set mForm = vNewValue

GetSettings

Resize
End Property
24.
. Class_ Terminate() :

Private Sub Class_Terminate()


'
SaveSettings
'
Set mForm = Nothing
End Sub
25. . Ctrl+S,
Save As, Save In
( ).
26. Save, .
! .
, , .
, :
1. Form! , .
2. (General)(Declarations) :

Option Explicit
Private WithEvents sf As SmartForm
, WithEvents Visual Basic
. sf Object
.
3. rMessage :
Private Sub sf_ErrorMessage(Message As String)
MsgBox Message
End Sub
MsgBox Visual Basic .
Message .
4 SmartForm (sf), . ,
, .
Form_Load() Form1 :
Private Sub Form_Load()

Set sf = New SmartForm


Set sf.Form = Me
End Sub
5.
SmartForm
. Form_Resize:
Private Sub Form_Resize()
sf.Resize
End Sub
6. , sf.
Form_Unload():
Private Sub Form_Unload(Cancel As Integer)
Set sf = Nothing
End Sub
7. Projectl Name .
, SmartForm, .
, .
, .

. , .
, []
IDE. . ,
, . 15,
.
,
.

Class Builder
, :
! , . Visual Basic
Class Builder . Class Builder (. 4.10)
. Class Builder
(add-in). , IDE,
. . 4.10, Class Builder
- , . ,
, .
Class Builder :
1. Add-Ins > Ad-In Manager.
2. Add-In Manager (. 4.11) VB Class
Builder Utility, IDE.
3. .

. 4.10. Class Builder

. 4.11. Add-In Manager


16, IDE
.

Class Builder IDE,


. Class Builder Person.
, , .
1. File > New Project. New Project
Standard EXE .
2. Class Builder Add-Ins > Class Builder Utility.
3. File > New > Class Class Builder.
Class Module Builder.

4. Person Name. Based On


(New Class). , .
5. Add New Property to Current Class .
Property Builder (. 4.12).
6. Name PersonName.
.
7. String Data Type.
8. Public Property (Let Get Set).
, (Public).
9. , .

. 4.12. Property Builder


10. Person Add New Event to Current Class
( ). Event
Builder (. 4.13).

. 4.13. Event Builder


11. Say Name. (Person) !
12. , , .
Add a New Argument ( ).
13. . .
Sentence Name.
14. Data Type String .
15. Event Builder . Person Say.
16. Person WhoAreYou. .
17. , . Class Builder ,
. 4.14.

. 4.14. Person ,

18. Person . Visual Basic File > Update


Project Ctrl+S.
19. Class Builder File > Exit.
.
, . PersonName ( Property
Let Property Get), , Class Builder .
, .
WhoAreYou():

Public Sub WhoAreYou()


RaiseEvent Say ("Moe " & mVarPersonName)
End Sub
: . ,
RaiseEvent. Say.
, .
, , . Form1
Person:
1. Form1 , .
, .
2. (General)(Declarations) :

Option Explicit
Private WithEvents p As Person
3. . _S()
:

Private Sub p_Say(Sentence As String)


MsgBox Sentence
End Sub
4. , :

Private Sub Form_Load()


Set p = New Person
p.PersonName = " "
p.WhoAreYou
Set p = Nothing
End
End Sub
, . PersonName .
5. F5.
, Class Builder ,
, .
, . .
.
. ,

. , .
15, - ().

?
:

.
.

.
.
Public.
Private.
.
Class Builder.

Windows-
.
, .


, Windows-
. ,
. , ,
. Visual Basic ,
(. 5.1).

. 5.1. Visual Basic


, , .
,
. , MDI-
. Visual Basic , ,
.
(. ).
, , . ,

Cut, Copy Paste.


, Edit > . ,
.
(. ).
, ,
. ,
(GUI) Windows (. ).
,
.


, ,
, . Visual Basic .
, , ,
.
Visual Basic .
,
. , .
, Tools > Menu Editor
(. 5.2).

. 5.2.
.
(, File).
(, Exit). , .
.
( )
Click.


,
, .
( ) :

Appearance
Caption
Checked

Index
Name
NegotiatePosition

Tag
Visible
WindowList

Enabled
HelpContextID

Parent
Shortcut

Caption , . (&)
.
Checked ( ) - .
. Checked,
.
Enabled False,
. , Save ,
- . Enabled .
,
Visible , .
Name, , .
, mnu.
Shortcut
. (
). Ctrl
Alt (, F1).
(
Click ,
Alt+,
, . , Help
Alt+H, .
, (, F1).

, , .
Click, .
Object
. ,
, .
,
.
, , ,
. (, )
, .

Click
, ;
. ,
, Click.
Click.
, .
Visual Basic Index
.
.
. ,
, .
7, .


,
.

Tools > Menu Editor (. 5.2). :


, Caption Name
.
.
Checked, Enabled Visible ,
.
.
.
. ,
( ).
.
, Index, .
( ,
File ).
HelpContextID ,
. 13,
.
NegotiatePosition
MDI, MDI.
Caption
Name. , .
. . .
( ) Next. - ,
,
, Insert. Delete.
, Caption (-).
Name .
.
mnu. , File
mnuFile. , , ; , Exit File
mnuFileExit, mnuFileSepl. , mnuExit
Exit ,
. File, .
, :
1. File > New Project.
2. Standard EXE.
3. Form1, .
4. Tools > Menu Editor Ctrl+E.
5. File &File Caption mnuFile Name.
6. Next, .
7. File, ,
.
8.
Caption &Exit, Name -
mnuFileExit.
9. . Edit Help ,
. Name Next:
Edit:
Caption:

Name:

&Edit

mnuEdit

Edit:

Caption:
Cu&t &Copy &Paste

Name:
mnuEditCut mnuEditCopy mnuEditPaste

Help:

Caption:
&Help
Help:

Name:
mnuHelp

Caption:

Name:

&About

mnuHelpAbout

. 5.3.
, . ,
. 5.3, . ,
. Edit, (. 5.4).
Paste, mnuEditPaste_Click() .
.

. 5.3

. 5.4.
File > Exit,
mnuFileExit_Click(). End .
, Exit .

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

, .
, , File ,
Help . . Edit
File, a Window Help.
Edit Window, .
, .
,
. , Cut t
, , ,
! ,
, Windows- .



.
.
,
, .
, , .
, .
, .
1. ,
Components. Components,
Microsoft Windows Common Controls 6.0.
2. . Name tbrToolba,
Align 1 - vbAlignTop. 3. (Custom).
4. Property Pages Buttons.
.
, .
5. Insert Button, .
6. Style 3 - tbrSeparator (. 5.5).

. 5.5. Style


:
1. Insert Button, . Key New,

Style - 0 - tbrDefault.
2. Insert Button . Key Open,
St1 0 - tbrDefault.
3. Insert Button .
Key Save, Style - 0 - tbrDefault.
4. OK, .
, . 5.6.
.

. 5.6.


. ,
Picture. . :
1
Name
imlToolbar.
, Microsoft Common Control 6.0.
2. Property Pages, Custom .
3. Property Pages Images, .
4 - ,
New. Insert Picture.
5. New.bmp Graphics\Bitmaps\Tblr_w95.
6. , ,
.
7. Insert Picture, n.bmp. ,
.
8 Insert Picture Save.bmp. ,
. 5.7. Property Pages .
Windows Paint
.
16x16 , - 32x32 .
Image > Attributes Ctrl+E;

. 5.7.
9. tbrToolbar Property Pages, Custom
.
10. General ImageList imlToolbar (. 5.8).

. 5.8.
11. Buttons.
12. Index 2, Image 1.
( ) . ,
.
13. Index 3, Image - 2.
Open.
14. Index 4, Image - 3.
Save.
15. . , . 5.9.
, , .
- , .

, tbrToolbar_ButtonClick().
Button - .

. 5.9.
:

Private Sub tbrToolbar_ButtonClick(ByVal Button As ComctlLib.Button)


Select Case Button,Key
Case Is = "New"
MsgBox " New"
Case Is = "Open"
MsgBox " Open"
Case Is = "Save"
MsgBox " Save"
End Select
End Sub
Select Case, .
If...Then, .
, If...Then Case Is.
Key
, .
, ,
Visual Basic 6, (CoolBar).
Visual Basic. ,
!


, Visual Basic 6,
(CoolBar). Microsoft Office (. 5.10), Internet Explorer IDE
VisualBasic. ,
, .
, , (
).
(bands),
.

.5.10.
, Microsoft . ,
. :

1. , .
.
2.
Components.
3. Components Microsoft
Windows Common Controls 6.0 Microsoft Windows Common Controls-3 6.0.
Common Controls-3. Common Controls 6.0
.
4.
OK, . 5.
frmMain.
6. , .
7. Ctrl+X, .
8.
Ctrl+V.
9. Name br1,
Align 1 - Align Top.
10. (Custom),
(. 5.11).

. 5.11. General
11. General , Bands.
5 12
,
.
12. , Index 1, Child
tbrToolbar.
13. .
(. 5.13) -
, . , .
, .
14. , .
15. (Custom) ,
.
16 General rnce 0 - ccFlat. Ha Apply,
, .

5.12. Bands

17. aaecocyStyleaee1 - tbrFlat. 1


.
18. .
HotImage List,
. ,
! , ,
, (Index),
Image.

19. F5. ,
(. 5.14).

. 5.14.

, , .
-,
, !

1. [x] File > Exit .


2. . ,
, .
3. . Caption
!
4. cbrCoolbar ,
(Custom).
5. Bands Index 2
.
.
6. Child Combo1, Caption . 1.
Apply.
8. ( 3 Index). Child Checkl.
9. .
10. .
(
) . ,
, .
, ! ,
.
,
. , .

?
:

, .
.
Windows-.
.
.
.
.

, ,
Visual Basic. ,
.
.
,
. ,

.
?

, , ,
. .
, . ,
. ,
.
. , ,
.
, : ,
. , ,
. , , .
.
, .
.

, ,
.
, , ,
.
. ,
1, 0,
1. 9,
, 1 . .
, .
, 1 . .
,
, .
: AND, EQV, OR, XOR NOT.
AND

AND ()
. , , .
. ,
. ,
. , -**
.
AND . ,
. , . . 6.1
,
AND.
6.1. AND
1

.
1, , ; ,
. 0, .
, -
.
, , . 6.2. , 217 106,
AND. 128 1

7 0. 2, ,
2, 1. 2 1, 2. 2 2, 4.
.
, , . ,
, . ,
.
. 8- ,
. 0 7.
6.2. AND




1
2
1 AND
2

7
27
128
1
0
0

6
26
64
1
1
1

5
25
32
0
1
0

4
24
16
1.
0
0

3
23
8
1
1
1

2
22
4
0
0
0

1
21
2
0
1
0

0
2
1
1 217
0 106
0 72

, (128+64+16+8+1),
217. 106.
AND, , .
72.

217 AND 106 = 72


, :
1. Ctrl+G.
2. :

A=217; B=106
? A AND B
72.
3. AND :

?
?
?
?
?

163 AND 8
55 AND 12
37 AND 7
72 AND 255
255 AND 0

0, 4, 5, 72 0.
, . 6.2 .
.
.
EQV

Visual Basic EQV .


, . , . . 6.3
.
6.3. QV
1
2

.
OR
, , OR.
, . ,
. . 6.4 OR.

6.4. OR
1
2

OR, AND.
. 6.5.
6.5. OR

7

5
4
3
2
7
6
5
4
3

2
2
2
2
2
22

128
64
32
16
8
4
1
0
1
0
0
1
0
2
1
1
1
0
1
0
1 OR
1
1
1
0
1
0
2

1
21
2
0
0
0

0
2
1
1
0
1

73
232
233

, :
1. Ctrl+G.
2. :
? 73 OR 232
, , 233.
3. ,
:
55 OR 12
37 OR 7
72 OR 255
255 OR 0
63,39,255 255. , OR
255 255.
XOR

, ,
XOR ( OR). OR
, , . . 6.6.
6.6. XOR
1
2

XOR (. 6.7).
, .
6.7. XOR

7
6
5
4
3
2

27
26
25
24
23
22

128
64
32
16
8
4
1
0
1
0
0
1
0
2
1
1
1
0
1
0
1 XOR
1
0
1
0
0
0
2

1
21
2
0
0
0

0
2
1
1
0
1

73
232
161

:
1. Ctrl+G.
2. :
? 73 XOR 232
, , 161.
3. ,
:
55 XOR 12
37 XOR 7
72 XOR 255
255 XOR 0
59, 34,183 255.
NOT

NOT .
, . :
Dim Successful As Boolean
Successful = True
If Not Successful Then
MsgBox " "
End If
Successful, ,
True (). If Not Successful, ,
. Successful ,
True False, . . 6.8,
NOT .
6.8. NOT

NOT ,
, . NOT Visual Basic
:
1. :
? NOT True
False.

2. :

? NOT False
True.

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

, .
Visual Basic =. , .
:

If x = 3 Then
MsgBox " x 3"
End If
Visual Basic .
:

x 3, .
,
. , , !
, , .
:
1. File > New Project.
2. New Project Standard EXE. .
3. Name Form1 frmMain, Caption
.
4. .
5. Name cmdGetSecretNumber, Caption
&.
6. Name cmdGuess, a Caption &.
7. frmMain, .
8. Load frmMain:

Private Sub Form_Load()



SecretNumber = GetSecretNumber()
End Sub
9. (General)(Declarations) frmMain:

Option Explicit
Private SecretNumber As Integer
10. GetSecretNumber(),
. (General)(Declarations):

Private Function GetSecretNumber() As Integer


' 1 10
Randomize
GetSecretNumber = Int(Rnd(1) * 10) + 1
End Function
11. Click cmdGetSecret Number:

Private Sub cmdGetSecretNumber_Click()


'
SecretNumber = GetSecretNumber()
End Sub
12. , Click cmdGuess:

Private Sub cmdGuess_Click()


Dim guess As Integer
Dim msg As String
Dim cap As String
'
msg = " 1 10"
'
guess = CInt(InputBox(msg))
' ?
If guess = SecretNumber Then
' ! !
msg = " !"
cap = "!"
'
MsgBox msg, vbExclamation, cap
'
End
Else
' . ...
msg = "."
cap = " !"
MsgBox msg, vbInformation, cap
End If
End Sub
. = - msg =
" ...", If guess = SecretNumber Then.
, .
13. . .
14. F5. ,
1 10. !
, (.6.1).

. 6.1.

, , >.
:
if x > 3 Then
MsgBox "x 3"
End If
,
. ,
. , .
:
1. , frmMain.
2. Click cmdGuess :
Private Sub cmdGuess_Click()
Dim guess As Integer
Dim msg As String
Dim cap As String
'
msg = " 1 10"
'
guess = CInt(InputBox(msg))
' ?
Select Case guess
Case Is = SecretNumber
' ! !
msg = " !"
cap = "!"
'
MsgBox msg, vbExclamation, cap
'
End
Case Is > SecretNumber
' . ...
msg = ". ."
cap = " !"
MsgBox msg, vbInformation, cap .
End Select
End Sub
3. .
. ,
(. 6.2).

. 6.2.

, s Is >
SretNumber. , - SecretNumber.
, , SecretNumber.

<:
if x < 3 Then
MsgBox "x 3"
End If
.
, .
. :
1. , frmMain.
2. Click cmdGuess :
Private Sub cmdGuess_Click()
Dim guess As Integer
Dim msg As String
Dim cap As String
'
msg = " 1 10"
'
guess = CInt(InputBox(msg))
' ?
Select Case guess
Case Is = SecretNumber
' ! !
msg = " !"
cap = "!"
'
MsgBox msg, vbExclamation, cap
'
End
Case Is > SecretNumber
' . ...
msg = ". ."
cap = " !"
MsgBox msg, vbInformation, cap
Case Is < SecretNumber
' . ...
msg = ". ."
cap = " !"

MsgBox msg, vbInformation, cap


End Select
End Sub
3. .
. ,
(. 6.3).

. 6.3.

, ,
<>:
if x <> 3 Then
MsgBox "x 3"
End If
, ,
. , , :
1. , 1 10.
2. .
3. OK Cancel
. End,
. , ,
:
guess = CInt(InputBox(msg))
, CInt() , .
, .
, ,
. <> !
:
If r <> "" Then
: guess ,
-.
4. Click cmdGuess :
Private Sub cmdGuess__Click()
Dim guess As Integer
Dim msg As String
Dim cap As String
Dim rc As String


msg = " 1 10"

r = InputBox(msg)
, ...
If r <> "" Then

guess = CInt(rc)
' ?
Select Case guess
Case Is = SecretNumber
' ! !
msg = " !"
cap = "!"
'
MsgBox msg, vbExclamation, cap

End
Case Is > SecretNumber
' . ...
msg = ". ".
cap = " !"
MsgBox msg, vbInformation, cap
Case Is < SecretNumber
' . ...
msg = ". ".
cap = " !"
MsgBox msg, vbInformatidn, cap
End Select
Else
msg = " !"
cap = " !"
MsgBox msg, vbInformation, cap
End If
End Sub
5.

, .
>=:

if x >= 3 Then
MsgBox "x 3"
End If
. x 3,
.
, , . ,
. , ,
.
. ( , !) ;
, .
:
1. File > New Project.
2. New Project Standard EXE. .
3. Name frmMain, Caption .
4. Name vscThrottle.

.
5. vscThrottle 100.
6. frmMain . Name lbl Airspeed,
Caption :.
7. frmMain , .
8. (General)(Declarations) frmMain:

Option Explicit
Private Throttle As Integer
Private Const VNE = 427

'
'

9. ,
Load frmMain:

Private Sub Form_Load()


vscThrottle.Value = 100
End Sub
10. Change vsc
Throttle:
Private Sub vsc_Throttle_Change()
Dim ias As Integer
'
'
Throttle = 100 - vscThrottle.Value
'
ias = Throttle * 4.5
'
lblAirspeed.Caption = " : " & Trim$(Str$(ias))
' ,

If ias >= VNE Then


MsgBox " !", vbCritical, " "
End If
End Sub
. , Throttle,
- , Value
0. , ,
( ). .
, (ias), .
.
, 400 .
:

' ,
'
If ias >= VNE Then
MsgBox " !", vbCritical, " "
End If
,
.
11. . ,
. , (. 6.5).

. 6.5.

, ( )
. <=. ,
:
if x <= 3 Then
MsgBox "x 3"
End If
.
, . Ha
, . :
1. , .
2. (General)(Declarations) frmMain:
Private Const VSTALL = 73 '
3. , 77 .
Form_Load :
Private Sub Form_Load()
vscThrottle.Value = 23
vscThrottle_Change
End Sub
, Change vscThrottle:
Private Sub vsc_Throttle_Change()
Dim ias As Integer '
'
Throttle = 100 - vscThrottle.Value
'
ias = Throttle * 4.5
'
lblAirspeed.Caption = " : " & _ Trim$(Str$(ias))
' , '

If ias >= VNE Then
MsgBox " !", vbCritical, " "
End If
' ,
If ias <= VSTALLThen
MsgBox " !", vbCritical,' " !"
End If
End Sub
5. .
.
, .

.

. ,
.
If...Then...Else

If...Then...Else ,
Visual Basic. If...Then
:
If 1 2 Then
'
End If
, : AND, OR, =,
<> . . 1 2 ,
. , :
PIN = "123456"
If PIN = "123456" Then
MsgBox " PIN"
End If
PIN , "123456". ,
.
,
. Else.
:
If 1 2 Then

Else

End If
, , Else .
Else End If.
, . :
PIN = "654321"
If PIN = "123456" Then
MsgBox " PIN"
Else
MsgBox " PIN!"
End If
, , . -
.
, If...Then...Else ( ).
If...Then .
:
If ValidUserID(UserID) Then
If ValidPassword(UserID, Password) Then
MsgBox " !"
Else
MsgBox " !"
End If
Else
MsgBox " !"

End If
, .
ValidUserID(). True ( ), .
, .
ValidPassword() True, .
. If...Then
ElseIf:
If x = 1 Then

ElseIf x = 2 Then
'
End If
/ .
.
IIf

If...Then...Else If, IIf.


, IIf .
:
Function TasteIt (Food As String) As String
CheckIt = IIf(Food = "". ", ", "!")
End Function
, ", " "!",
, IIf.

, IIf() , .
, IIf
.

TasteIt() . , Food "",


", ". "!"
, IIf, ,
.
Select Case...End Select

( )
Select Case...End Select. :

Select Case x
Case Is =3
'
Case Is > 17
'
Case Else.
' ,
'
End Select
Select Case End Select.
Case Select Case End Select .
Case.
, , Case Else.
Else If...Then.
Select Case , .
, , 1 10:

Select Case guess


Case 1 to 10

Case Else

End Select
s 1 to 10 guess, - 1 10.
Case Else .
Select Case...End Select . , -
:

Select Case x
Case Is = "3"

Case Is > "17"

Case Else
,

End Select
, , Case.
Case (. ). :
Case End. ,

. ,
.

12,

,
, . ,
. . -,
. .
, Trim$(). -, ,
. UCase$() LCase$(,).Bo-
:

If Trim$(UCase$(txtInput.Text)) = "" Then


'
End If
If Trim$(LCase$(txtInput.Text)) = "" Then
'
End If
If...Then . :
, .


. , ,
, .
For...Next

Visual Basic For,..Next.


. For...Next
, . :

For = To

Next
, :
(Integer Long) (,
I).
, .
, .
, x 1 5, x,
1, 5. For...Next
Step. (
1). , 3, For Step 3.
2, Step 2. 10
100 5:

For I = 10 To 100 Step 5


'
Next
Next -.
For...Next Next. , ,
. ,
For Next.
For...Next 1.
, Step, .

.
Step. ,
- 10 1:

For I = 10 To 1 Step -1

Next
100 0 10:
For I = 100 To 0 Step -10
'
Next
, , Exit
For. :

For I = 1 To 100 Step 5


X = I * 10
If X > 100 Then
Exit For
End If
Next
For...Next .
.
Do...Loop

Do...Loop.
,
. , ,
. , ,

, . Do...Loop .
Do...Loop :
Do
Loop

'

:
Do While X < 10
X = X + 1
Loop
, 10. X
, 10 . While
Until,
. :

Do Until X = 10
X = X + 1
Loop
,
Visual Basic. ,
.

Exit Do. Oco-


If...Then.

While...Wend
, Do...Loop, While...Wend.
, . ,
:

While X < 10
X = X + 1
Wend
, X 10. While-Wend
Do...Loop, .
Mny76

Visual Basic , .
For Each...Next. ,
- .
, , .

Dim cmd As CommandButton


*
For Each cmd In Form1
With cmd
If .Index <> Index Then
MsgBox " " & Trim$(Str$(.Index)) &_
"
End If
End With
Next

CommandButton. Bo Visual Basic


CommandButton Form1. With cmd, ,
With...End With cmd.
,
, MDI ,
DHTML (. 18, Visual Basic).

, -,
.
. ,
.
1. File > New Project.
2. New Project Standard EXE .
3. Name Form1 frmMain, Caption .
4. Ctrl+E. 5. ,

Caption &. Name mnuLoop.


6. ( Next ).
7.
, (. 6.7),
.
.

. 6.7.

8. Caption &For... Next, Name mnuLoop ForNext.


9. Next, . :
, .
10. Caption &Do... Loop, Name mnuLoopDo-Loop.
11. Next, . Caption
&While... Wend, Name mnuLoopWhileWend.
12. Next, . Caption
- (), Name mnuLoopSep1.

Caption (-), ,
.
5, .

13. , Caption &-,


Name mnuL1.
14. OK, .
15. File > Save Project.
- .
, .

16. frmMain ,
Name txtTextBox. Text.
17. , txtTextBox .
18. Ctrl+C, .
19. frmMain.
20. Ctrl+V, .
(. 6.8), .
Yes.

. 6.8.

21. .
22. Ctrl+V,
. , 20 21.
.
, . 15
, . 6.9.
23. For...Next frmMain.
mnuLoopForNext_Click.
24. :
Private Sub mnuLoopForNext_Click()
Dim i As Integer
'
For...Next For i = 0 to 14
txtTextBox(i).Text = "i = " & Trim$(Str$(i))
Next
End Sub

. 6.9.

25. mnuDoLoop_Click :
Private Sub mnuDoLoop_Click()
Dim i As Integer
' For...Next
i = 0
Do While i < 15
txtTextBox(i).Text = "i = " & Trim$.(Str$(i'))
i = i + 1
Loop
End Sub
26. mnuWhileWend_Click:
Private Sub fnnuWhileWend_Click()
Dim i As Integer
' For...Next
i = 0
While i < 15
txtTextBox(i).Text = "i = " & Trim$(Str$(i))
i = i + 1
Wend
End Sub
27. mnuLoopClear_Click:
Private Sub mnuWhileWend_Click()
Dim x As Control
'
'
For Each x In frmMain.Controls
If UCase$(Left$(x.Name, 3)) = "TXT" Then
x.Text = ""
End If
Next
End Sub
28.Coxpa .
, ,
. , (. 6.10).
, -.
, .
Text . ,

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

. 6.10.

?
:

.
Visual Basic .
.
.
.

7




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

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

, ,
. . 5x5 0,25
2. ,
. (1024 ) 16x16 . ,
, . 1024 ,
5,12x5,12 , 26,2144 2.
16 ,
20,48x20,48 , 420 2. !
, ,
. , .
, , ,
.

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

Integer
,
-32 768 32767
Long
, Integer

Single
Double


, Single

Currency
String
Byte



0-255, ,
Integer

Boolean
Date
Object

True False

Visual Basic

Variant

. 7.1, . , ,
: (Byte), (String), (Integer),
(Boolean), (Variant) (Object).
^ , , . .

, ,
.
12, .

.
, : 0 255.
,
ASCII .
:
1. File > New Project.
2. Project Wizard Standard EXE.
3.
Visual Basic , Form1.
Form1 Remove Form1
.
4. Visual Basic Form1, No.
5.
Add > Module
.
6. Add Module Module. B .
7. , Module 1
.
8. :
Option Explicit
Private Sub Main()
Dim b As Byte
Dim text As String
Debug.Print "ASCII-"
for b = 0 To 63
text = Str$(b) & " " & Chr$(b)
text = text & Chr$(9) & Chr$(9)
text = Str$(b + 64) & " " & Chr$(b + 64)
text = text & Chr$(9) & Chr$(9)
text = Str$(b + 128) & " " & Chr$(b + 128)
text = text & Chr$(9) & Chr$(9)
text = Str$(b + 192) & " " & Chr$(b + 192)
text = text & Chr$(9) & Chr$(9)
Debug.Print text
Next
End
End Sub
9. Run > Start.
, .
ASCII-. 0 255, .
ASCII-. ,
. ,
Chr$(9). 9
. , Chr$(9).
Debug.Print .
9, .
,
, ASCII- Chr$(), ASCII .

, .
( )
. ,
. . 7.2 . :
11 , ASCII- .
, ,
. , Name Caption - .
, :

;
( String);
.
strName. str
, . , ,
. .
Dim:
Dim strName as String
. Visual Basic -
, . ,
:
strName = "Jane"
, .
, Visual Basic , strName Jane.
, ,
:
Form1.Caption = strName
:
1. File > New Project.
2. Form1 , .
3. Events Click .
4. Click :
Private Sub Form_Click()
Dim msg As String
msg = "!"
Caption = msg
End Sub
5. Run > Start.
6. .
.
, .
,
Option Explicit (General) (Declarations)
.
Visual Basic (.BAS).

, Tools >
Options. Require Variable Declaration Editor Options (.
7.3). Visual Basic Option Explicit (General)
(Declarations) .

Puc. 7.3. Options


.
, ( )
-32 768 32 767. ,
. ,
.
:
1. .
2. Name cmdPush, Caption
.
3. , .
4. Click :
Dim A
Dim
= 2
=
Print

As Integer
As Integer
+ 1

5. .
. 7.4 .

. 7.4.

, 3 (. 7.5).

. 7.5. -

,
.


True False.
.

. True, , False
. , ,
:
1. File > New Project.
2. Project Wizard Standard EXE.
3. Form1 Name txtFilename.
4. Caption
Caption Textl.
5. . Name
cmdSearch, Caption &Search.
6. Form1, .
7. IsFile:
Private Function IsFile(Filename As String) As Boolean
If Len(Dir$(Filename)) > 0 Then
IsFile = True
Else
IsFile = False
End If
End Function
8. cmdSearch (
). Click.
9. Click cmdSearch:
Private Sub cmdSearch_Click()
Dim filename As String
Dim rc As Boolean
filename = txtFilename.Text
rc = IsFile(filename)
If rc = True Then
MsgBox " !"
Else

MsgBox " !"


End If
End Sub
10. .
, , .
, IsFile True, False.
filename,
IsFile. filename Click cmdSearch.

, ,
Dir$(), Len(), Len(Dir$(filename)).
, , 0 . IsFile
.

(, ,
) .
Dim, Visual Basic , .
, :
, .
, Visual Basic .
, ,
.

. , .

, , Dim (
Dimension, ). .
. ,
, .
( ).
, . -,
(General) (Declarations) . , Dim Private ( Dim
Visual Basic).
,
, (. 7.6).

Projectl.Vbp

. 7.6.
, .
, . (General)(Declarations), Dim

Private - Global.
.BAS, .
, , :
1. .
2. Project Wizard Standard EXE.
3.
Add > Module.
4. Add Module Module. Module1
.
5. :

Option Explicit
Global UserID As String
Global ACL As Integer
6. Module1 :

Public Sub InitApp()


UserID = ""
ACL = 255
End Sub
, .
UserID ACL c Global
. InitApp
Public,
. UserID
"", ACL 255.
:
1. Form1 ,
.
2. Name Form1 frmLogon, Caption
.
3. . Name lblUserID, Caption
:.
4. lblUserID , Name
lblPassword, Caption :.
5. Name
txtUserID.
6. . Name
txtPassword, PasswordChar (*).
7.
. Name
cmdLogon, Caption &.
,
, . 7.7.

. 7.7.

8. Form1.
9. Option Explicit (General)(Decla-rations) Form1.

10. Enter, Option Explicit .


11. tion Explicit:
Private Password As String
12. Load :

Private Sub Form_Load()


InitApp
txtUderID.Text = UserID
txtPassword.Text = ""
End Sub
13. Click cmdLogon
:

Private Sub cmdLogon_Click()


Dim msg As String
UsertID = txtUser.Text
Password = txtPassword.Text
msg = " : " & UserID & Chr$(13)
msg = msg & ": " & Password & Chr$(13)
msg = msg & "ACL:
" & Str$(ACL)
End Sub
14. Run > Start.
, .
UserID.
Form_Load, Module1.
.
(General)(Declarations) . . ,
. ,
.
: . Click
.
Static

(Dim)
Static:

Static X As Integer
,
.
. Static ( Dim),
.
, . Sybex
, . , !
, :
1. Standard EXE.
2. Caption Form1 Sybex.
3. . Name
lblQuantity, Caption ;0.
4. lblQuantity. Name cmdAdd,
Caption & !.
5. cmdAdd , .
6. Click cmdAdd:

Private Sub cmdAdd_Click()


Static count As Integer

count = count + 1
lblQuantity = " :" & Str$(count)
End Sub
7. , .
count Click (Static),
. , .
,
Dim Static , Private Static
Sub cmdAdd_Click().

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

Static
X(0) =
X(1) =
X(2) =

X(2) As Integer
7
99
123

For...Next,
(. 7.8):
Dim Y As Integer
For Y = 0 To 2
Print X(Y)
Next Y

. 7.8. For...Next

X ( 0,1 2
). ,
Dim (General)(Declarations) .
, Public. ,
:
1. Standard EXE.
2. Form1. Forml
Remove Forml .
3.
Add > Module .
4. Add Module ModuLe.
5. Module1 :

Sub Main()

Dim x(7) As Integer


Dim i As Integer
Dim txt As String
'
For i = 0 To 7
x(i) = 2 ^ i
Next
'
For i = 0
txt =
txt =
Next

To 7
" " & Str$(i) & " = "
txt & x(i)

End Sub
6. .
, . x
8 ( 0 7). i For...Next,
txt .
For...Next .

x(i) = 2 ^ i
.
.
For...Next txt, Debug. Print
.

( )
. . ,
, . ,
, , Dim, Static:

Dim Y() As Integer


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

ReDim Y(5)
.
:

ReDim Y(7)
, , . ,
Preserve:

ReDim Preserve Y(7)


, .
, .


. ,
.
vbModal, -
1. .
Const:

Const conPi = 3.142


:

Const conPi = 3.142


Dim Radius As Integer
Dim Area As Double
Option Explicit
Private Sub cmdPrintArea_Click()
Radius = 3
Area .= conPi * (Radius ^ 2)
Print Area
End Sub
, conPi ( con
, ). (. 7.10).

. 7.10.
, .
, , Global,
Global Const Pi = 3.142.
.
,
. , ,
, . To .
.
?
:

.
.
.

ASCII-





Visual Data Manager
ActiveX Data Objects (ADO)

,
.
. ,
, .
.
ASCII-,
,
.

ASCII-
Visual Basic , ,
ASCII-. , ( ) ,
ASCII-.
, (. 8.1).
, ,
. ,
. , INI-.
. ,
,
. Visual Basic .
( )
/ . ,
, (. ). ,
, .
,
.
. Visual Basic
Open, .
Open , . Open
:

Open filename For mode As fileno


filename , mode .
Append (), Input (), Output (), Binary () Random
(). , fileno

. 8.1. ASCII-
,
. .
. Append,
Binary, Output Random Visual Basic . , mode ,
.
. , .
, ASCII- ,
,
. Input.
Close :
Close fileno
,
.

Visual Basic .
ASCII- (. 8.2).

. 8.2.

Output Append.
, Visual Basic . ,
Output , Append .
, .
.
, Input. ,
Input, Output Append,
(. ). , Close
. Print # ( Write #),
Line Input #(a pa lnput # Input).
, C:\Data
:

Dim FileNo As Integer


FileNo = FreeFile
Open "C:\data\test.txt" For Append As FileNo
Print #FileNo, ""
Print #FileNo, ""
Close FileNo
FreeFile ,
Open, Print # Close.
WordPad Notepad (. 8.3). , ( ,
), Output Append.

. 8.3.
.
: , .
7, .
C:\Data\test.txt:

Dim FileNo As Integer


Dim GetValues() As String
Dim Counter As Integer

Counter = 0

FileNo = FreeFile
'
Open "C:\data\test.txt" For Input As FileNo
Do Until EOF(FileNo)
Counter = Counter + 1
ReDim Preserve GetValues(Counter)
Line Input #FileNo, GetValues(Counter)
Loop
Close FileNo
EOF , .

ASCII-,
. , GetValues
:

Dim J As Integer
For J = 0 To UBound(GetValues)
Print GetValues(J)
Next J
, Option Base 1 (General)(Declarations)
. 1,
0. , For...Next 1, 0.
UBound , LBound .
.
:

Dim J As Integer
For J = LBound(arrayname) To UBound(arrayname)
'
Next J

ASCII-,
.
.
, . ,
,
. , Random:

Open "C:\data\test.txt" For Random As FileNo Len=10


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

Private Sub SaveFile()


Dim FileNo As Integer
Dim RecNo As Integer
Dim FName As Integer
Dim LName As Integer
Dim Lineout As Integer
FName = ""
LName = ""
Desc = " "
LineOut = LName & FName & Desc
FileNo = FreeFile
RecNo = 1
Open "C:\test.txt" For Random As FileNo
Put #FileNo, RecNo, LineOut
Close FileNo
End Sub
:


! ,
.
Type...End Type.
Type .
, . , Type,
, . Visual Basic
. ,
(General)(Declarations) . :

Type UserInfoRecord
LName As String * 15
FName As String * 15
Desc As String * 50
End Type
:

Private Sub SaveFile()


Dim FileNo As Integer
Dim RecNo As Integer
Dim usr As UserInfoRecord
usr.FName = ""
usr.LName = ""
usr.Desc = " "
FileNo = FreeFile
RecNo = 1
Open "C:\test.txt" For Random As FileNo Len = 80
Put #FileNo, RecNo, usr
Close FileNo
End Sub
Type. ,
Type...End Type. , ,
LName, FName Desc. ,
. LName FName
15 , Desc 50 .
-, 80 .
, .
User.InfoRecord,
Dim, . Visual Basic, .
, ,
.
Get#. , .
. 8.4 , Notepad.

. 8.4.

, ASCII. .
. ,
. .

.
Get#, Put# ( ).
,
.
. , , ( ),
. , 10 :

Temp = String(10, " ")


Get #FileNo, , Temp
RecNo ,
. Visual Basic ,
.
. .


. , , ,
. ,
.
Actions > Encrypt, a - Actions > Decrypt. B
, .
1. Standard EXE.
2. Form1 Name frmMain, Caption
.
3. , Name
dlgFile.
4. :
File:
Caption:
&File

Name:
mnuFile

File:
Caption:
&Exit

Name:
mnuFileExit

Actions:
Caption:
&Actions

Name:
mnuAct

Action
Caption:
Name:
&Encrypt
mnuActEncrypt
&Decrypt
mnuActDecrypt
, . 8.5.

. 8.5.
( . ,
.
Open Save,
.
.

5.
Object
mnuFHeExit.
6. mnuFileExit_Click() End.
7.
. (General)
(Declarations) :
Function Encrypt(infile As String) As Boolean
Dim fileno1 As Integer
Dim fileno2 As Integer
Dim outfile As String
Dim xpos As Long
Dim x As Byte
'
MousePointer = vbHourglass
xpos = 4
outfile = "c:\temp.enc"
fileno1 = FreeFile
Open infile For Binary As fileno1
fileno2 = FreeFile
Open outfile For Binary As fileno2
Put #fileno2, 1, 0
Put #fileno2, 2, 128
Put #fileno2, 3, 0
Put #fileno2, 4, 128
Do While Not EOF(fileno1)
xpos = xpos + 1
Get #fileno1, xpos, x
Get #fileno2, xpos, x + 128
Loop
Close fileno2
Close fileno1
'
Kill infile
FileCopy outfile, infile

Kill outfile.
Encrypt = True
'
MousePointer = vbNormal
End Function

,
. , Sub
, . ,
,
. True,
, False . , infile.
. infile GetFile().
.
, . ,
.
* - ,
. , , .
, MousePointer vbHourglass.

, FreeFile
. , FreeFile.
, .
. ?
infile outfile . ,
. ,
FreeFile, a
Open (FreeFile , ).
fileno1 fileno2. FreeFile
Open, . : FreeFile
Open, . ,
!
,
FreeFile Open. FreeFile ,
. Open FreeFile.

,
. ,
. ,
.
0, 128, 0, 128.
. Encrypt Decrypt ,
.
x , . ,
255. x
255, x , . 128 128,
256. 256 , 255, x
.
. 128 , ,
.
Kill, .
infile outfile. B
, .
, ,
infile , outfile.
outfile .
,

, . Encrypt True,
.
1.
( ) . ,
. mnuEncrypt_Click():
Private Sub mnuActEncrypt_Click()
Dim filename As String
filename = GetFile()
If filename <> "" Then
If Encrypt(filename) = False Then
MsgBox " !"
End If
End If
End Sub
2, Encrypt
GetFile():
Function GetFile() As String
dlgFile.CancelError = True
On Error GoTo filerr
dlgFile.DialogTitle =" ..."
dlgFile.DefaultExt = "*.txt"
dlgFile.Filter = " (*.txt)|*,txt* _
(*. *)|*.*"
dlgFile.FilterIndex = 1
dlgFile.MaxFileSize = 32767
dlgFile.ShowOpen
GetFile = dlgFile.filename
Exit Function
filerr:
GetFile = ""
End Function
GetFile() .
. , .
, , Open
.
. .
GetFile() , CancelError True.
Cancel .
, .
On .
DialogTitle " ...",
.
.
*.txt. ,
DOS, , .txt
.
, .
( Filter). ,
,
(|). , , .
.
FilterIndex. FilterIndex , .
1, 2 . .
. (. 8.6).

. 8.6.
MaxFileSize 32 767. ,
32 .
, ,
. ,
, MaxFileSize .
MaxFileSize
. ,
( ).

, ShowOpen, .
Cancel, , .
FileName , ,
GetFile(). , .
, :
1. :
Private Function Decrypt(infile As String) As Boolean
Dim fileno1 As Integer
Dim fileno2 As Integer
Dim outfile As String
Dim xpos As Long
Dim x As Byte
Dim t(3) As Byte

'
MousePointer = vbHourglass
xpos = 4
outfile = "c:\temp.enc"
fileno1 = FreeFile
Open infile For Binary As fileno1
fileno2 = FreeFile
Get #fileno1, 1, t(0)
Get #fileno1, 2, t(1)
Get #fileno1, 3, t(2)
Get #fileno1, 4, t(3)
If (t(0)=0 And t(1)=128 And t(2)=0 And t(3)=128) Then
Open outfile For Binary As fileno2
Do While Not EOF(fileno1)

xpos = xpos + 1
Get #fileno1, xpos, x
Get #fileno2, xpos - 4, x + 128
Loop
Close fileno2
Decrypt = True
Else

Decrypt = False
End If
Close fileno1
'
If Decrypt Then
Kill infile
FileCopy outfile, infile
Kill outfile
End If
'
MousePointer = vbNormal
End Function
, .
, ,
0, 128, 0, 128. .
, , ,
.
2. Decrypt :
Private Sub mnuActDecrypt_Click()
Dim filename As String
filename = GetFile()
If filename <> "" Then
If Decrypt(filename) = False Then
MsgBox " !"
End If
End If
End Sub
- . ,
, .
.


Visual Basic Microsoft Access
, Visual Basic .
,
! Biblio.mdb,
Visual Basic, VB98. (
) , , ,
. Access ,
, . :
Microsoft Access, ,
Visual Basic. ,
.

Access, Visual Basic Visual Data Manager


(. 8.7). Add-Ins > Data Manager.

. 8.7. VisualData Manager

, Visual Basic.
:
DAO
(Data Access Objects - ), RDO (Remote Database Objects -
) ADO (ActiveX Data Objects - ActiveX). Bce
, . ADO
Visual Basic 6- .
- Visual Basic Data Form Designer.
, Add-Ins > Add-In Manager .
Add-Ins , Add-In
Manager.
, Visual Basic.
.

-
,
.
1. Ctrl+N.
2. New Project Standard EXE OK,
3. .
4. , .
5. .
6. , ( ).

7. :
Caption:
Connect:

Authors
Access (default)

DatabaseName:
RecordsetType:
RecordSource:

C:\Program Files\Microsoft Visual Studio\VB98\biblio.mdb


( )
1 Dynaset ( )
Authors ( )

8. :
Data1
Author

DataSource:
DataField:

9. :
Data1
Au ID

DataSource:
DataField:

10. ,
. ,
.
, .
Russell Jacobs. 56, Bradford Nichols.

11. , .
12. , EOFAction
2 - Add New.
,
Windows , .

13. . ,
.
14. Doe, John .
.

15. .
16. , .
Name cmdDelete, Caption &Delete.
17. Click :

Private Sub cmdDelete_Click()


With Data1.Recordset
.Delete
.MovePrevious
End With

End Sub

, , .
, ,
I .

(. 8.8). Connect
Access. DatabaseName ( ,
Access; ).
RecordSet , , (dynaset)
(snapshot). ( ) ,
;
,
. RecordsetType .
RecordSource ( Access;
). ,
SQL- Access.

. 8.8.

. .
DataSource ( Datal), DataField
, RecordSource .
Visual Basic.
, ,
Visual Basic. ,

ADO ! ADO
, .

Visual Basic Microsoft


Access (.MDB), SQL Server Oracle. Visual Basic
, (
Microsoft Access 97 ( )). ,
Access Access, Visual Basic
AccessJet Engine. , - MDB- Access.
Access, Visual Data Manager,
Visual Basic.
Access , , .
, . ,
. .
( , ).
SQL (Structured Query Language- ),
.

SQL, , . Visual
Basic Access c ,
. To, xBase , Access . Visual Basic Access
, .
Access , , . .
, . ,
. ,
. ,
Excel, .
, , .
.

.
.
.

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

, .
, .

.
, , .
, .
, .
(, ),
. , ,
. SQL ,
. :
1. .
2. RecordSource : select * from [Authors] where
[Author] = "Blaha, Stephen"

3. Run > Start.


:

Blaha, Stephen

9033

;
. Visual Basic Access .
, ,
( ), (
Stephen Blaha). ,
, .
,
. ,
,
, . ,
, , .
Visual Basic Access.
, (, ,
). , ,
-, - .
? ,
, , ,
Access ,
.
, .
, . ,
?
, . ,
,
.
, Visual Basic.

Visual Data Manager


. ,
, .
, . Visual Basic Access
, .
.
.MDB. , (,
. .), . , MDB-,
.
. :
1. Visual Data Manager Tools > Visual Data Manager.
2. File > New > Microsoft Access > Version 7.0 MDB,
Select Microsoft Access Database to Create.
3.
; HouseOfBooks (
). .MDB , Visual Basic .
4. .
. .
(Database Window -. . 8.9), SQL (SQL Statement). B
.
. .
Dynaset ( ), -
.

. 8.9.
, , :
1. File > Close. Close
.
, Visual Data Manager.
2. File > Open Database > Microsoft Access, Open
Microsoft Access Database. HouseOfBooks.mdb Open.
- , Open as Read Only.
.
.


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





Windows
Access

, .
, .
.


Windows

Access

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

HouseOfBooks,
( File > Open Database). B
. ,
TabLe:
1. New
Table. Ha ,
, , (. 8.10).

. 8.10. Table Structure

Table Structure .
, , .
. , .
2. . BookList.

:
1. Add Field, . Add Field (.
8.11).

. 8.11. AddField
2. Name TITLE.
, , .
3. Tab, .
Access (Text).
4. Tab, Size. 40.
5. OK, .
6. , LASTNAME.
7. Tab, .
, 20.
8. OK, .
9. , FIRSTNAME.
10. Tab, .
, 20.
11. Close. .
12. Build the Table Table Structure, Data Manager
.
. ,
. ,
:
1. BookList .
Open. , ,
, - .
2. Table Structure Close.


Windows. F2,
. , ,
, .
:
1. BookList.
2. Open.
, , .
, .
. .
; Yes,
. :
1. Add, .
2. Title
LASTNAME.

3. LASTNAME FIRSTNAME.
4. FIRSTNAME .
5. , Yes.
. Add
.
TITLE




Windows
Access

LASTNAME

FIRSTNAME


Update .
, .
,
, .
BookList.

, SQL
, .
BookList
. , , :
1.
New Query. , Utility > Query Builder Visual Data Manager.
Query Builder(pnc.8.12).

. 8.12. Query Builder

2. BookList .
Field Name .
[BookList].LASTNAME.
3. Operator. Hac ,
.
4. Value List Possible Values
.
. .
5. Fields to Show , . ,
.

6. SQL Show. Ha
, BookList
.
7. Add into Criteria, SQL .
Add into Criteria
Or into Criteria. .
8. , Run. Data Manager ,
SQL- (passthrough) ( No;
SQL- , Microsoft SQL Server). ,
, (. 8.13).

. 8.13.

9. Close.
10. Save Query Builder.
Powys. .
11. Query Builder Close.
.
BookList. ,
.
, , . ,
, .
Visual Data Manager. ,
SQL Visual Basic. ,
. , SQL- :
SQL = "Select * from [BookList] Where [BookList].LASTNAME = '"
SQL = SQL & txtAuthorName & .....
txtAuthorName.
, SQL-,
.
,
BookList.

, ,
.
, , . ,
, . BookList
. ,

. ,
. ,
. ,
. ,
. (,
) ( , ,
),
.
ISBN (International Standard Book Number ,
). ,
, Ho\fepa ISBN. ISBN ,
,
. .

:
1
.
, . .
- Visual Data Manager, ,
Long 1 Increment. ,
Required (Primary Key). B
.
BookList ISBN,
( , ISBN).
- BOOK CODE.
: - . ,
.
ISBN , ,
. Access
(
,
). .
,
.

BookList
.
, . ,
.
- . Access
. ,
. ,
. :
1. ,
. ,
1. , Access
. , .
Field Size Byte, Integer, Long, Single Double.
,
( , )
. .

Field Size
Byte
Integer
Long

0 255
-32 768 32 767
-2 147 483 648



0
0
0

1
2
4

Integer
Single
Double

2 147 483 647


-3.410383.41038
7
308
308
-1.79710 1.79710
15

4
8

, .
, Single
Double ( , ).
, ,
, , .
255, Byte.
QUANTITY. ( )
Integer Long.

, Double.
. -,
( ). -, , ,
-. , . , ,
(, ), . ,
( PRICE) .
,
!

(/, / , ./.).
^
. .
, ,
.
, .
RARE BOOK? ( ).
Memo

Memo ,
. ,
. ,
. Memo .
Memo , ,
. 255
( 255 , 40 ), Memo 64 000
.
Memo . ,
, , ,
.
. Memo NOTES.
/

/ , ,
. Access ,
. Visual Basic Access /,
. : , 27
1998 4:
4 27 98;
27
April
4

( ) Windows ( (Regional Settings)


). . .

04/27/1998.
, , .
, . , 27 1989 ,
89 1989.
/ BookList.
, .
, ,
. , ,
. Visual Basic Access
. / ACQUIRED.


,
BookList. Ha .
:
1. BookList ,
Design.
2. Add Field, . Name
BOOK CODE. Type Tab,
Long. , AutoIncrField Required.
.
3. , QUANTITY, Tab.
; Type Byte. OK,
.
4. , PRICE, Tab. Type
Currency. OK,
.
5. , RARE BOOK?. (Boolean).
OK, .
6. NOTES. Memo
.
7.
. ACQUIRED, /
(Date/Time) . Add Field Close.
8. Table Structure Add Index, Name BOOK
CODE. BOOK CODE Available Fields, Indexed
Fields.

, Primary Unique ,
BOOK CODE .
, ( )
.
, ,
. .
, , ,
. ( ,
, ).
, ,
Index Fields. , OK,
.
, UNIQUE, PRIMARY REQUIRED True.
( BOOK CODE),
. Access ,
. ,
. , Access -
, .
9. . TITLE Name,
TITLE Available Fields. Unique Primary,
, , ,
. .

, ,
Access.
.
, ,
.

10. LASTNAME.
.
11. , Close.
12. Field List QUANTITY, . 1
DefaultValue , .
Access .
, .
,
. ,
OLE.
13. Field List PRICE, .
, . ,
QUANTITY , .
, Byte 0-255,
.
14. ValidatationRule >0 and <1000. ,
.

, ( , ,
). , ,
$1000.
15. ValidationText - 0
1000. , ,
. (, ,
), ValidationText.
16. Close.
. Visual Basic,
. Visual Basic Add-Ins > Data Form Designer,
.
, .
DatabaseName, Access (.MDB),
RecordSource, MDB-. DataSource
, DataField ( ),
RecordSource .
RowSource ( ListField).
DataSource (
DataField).
ADO (ActiveX Data Objects)

ActiveX, ADO, .
, Microsoft,
DAO, RDO, .
ADO Access, SQL, Oracle, MS Exchange
.
ADO OLEDB ,
, ADO ,
. ,
(, Access) -,
Microsoft SQL Server, Oracle ,
OLEDB, ODBC (. 8.14).
8.14, ADO ,
OLEDB. , , ADO Microsoft Exchange.
, , , .
ADO . - ,

. , ,

. ADO : ,
, , ,
. ADO , ,
,
. ,
.

. 8.14. ADO
Visual Basic ADO .
ADO (ADO Data Control). , ActiveX:
ADO (ADO Connection Object) ADO (ADO Recordset Object). Bce
.
ADO

ADO ADO,
.
ADO
Visual Basic:
. ,
. , ! ,
, ADO.
1. , .
2.
, , Delete.
.
ADO, :
3.
Components.
4. Components Microsoft ADO Data Control 6.0
(OLEDB) . .
5. ADO ,
.
6. Caption .
7.
Database ADO
. ConnectionString,
(. 8.15).
Use Data Link File Use ODBC Data Source Name
(, ).
Access.
8. Build, .
9. Data Link Properties (. 8.16) Microsoft Jet 3.51 OLE DB
Provider, . Next.

. 8.15. ADO

Puc. 8.16.
10. Select or Enter a Database Name. Biblio.mdb
\gram Files\Microsoft Visual Stud1o\VB98. - Open.
Connection (. 8.17).
11. , .
Advanced All: . ,
ADO.
12. . ConnectionString .
13. RecordSource, .
(. 8.18).

. 8.17.

. 8.18. RecordSource
14. Command Type 2 - adcmdTable.
15. Table or Stored Procedure Name, Authors.
16. .
. ADO c
.
17. Textl, . DataSource
Adodc1, DataField Author.
18. Text2, . DataSource
Adodc1, DataField Au_ID.
19. cmdDelete.
20. .
, ,
. ,
.
.
ADO

ADO, ADO
. ADO Biblio.mdb,
.
:
1. File > New Project. New Project
Standard EXE .
2. Name ADORecordset.

3. Name Form1 frmMain, Caption -


ADO.
4. frmMain Name 1st Authors.
, ADO ActiveX.
, . DLL-
( ) Active,
.

: , ,

5. Visual Basic Project > References, References.


6. ADO.
Microsoft ActiveX Data Objects 2.0 (. 8.19).

Puc. 8.19. ADO


7. OK, References.
ADO .
8. (General)(Declarations) :

Private cn As ADODB.Connection
Private rs As ADODB.Recordset
9. Form_Load:

Private Sub Form_Load()


Dim cmd As String
Dim sql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
'
cmd = "Provider=microsoft.jet.OLEDB.3.51'" & _
"Data Source=" & _
"C:\Program Files\Microsoft Visual Studio" & _
"\VB98\Biblio.mdb"
'
Set cn = New ADODB.Connection
With cn
.ConnectionString = cmd
.Open
End With
'

sql = "select * from authors"


'
Set rs.= New ADODB.Recordset
With rs
.Open sql, cn, adOpenForwardOnly, adLockReadOnly
Do While Not rs.EOF
'
lstAuthors.AddItem rs("Author")
'
rs.MoveNext
Loop
' .
Close
End With
Set rs = Nothing
'
cn.Close
'
Set cn = Nothing
End Sub
10. .
Biblio.mdb
Authors. , ,
, , , .
, cmd sql. cmd,
ADO, . sql
SQL-. Biblio.mdb c
OLEDB ( Provider = ).
, , SQL Server -
. . ADO
, .

(, Access, SQL Server Oracle). ,
.
ADO .
.
ADO.Connection ConnectionString cmd.
. Open . ,
ConnectionString, .
ADO. Recordset .
SQL-, .
:
sql = "select * from authors"
SQL, : (*)
Authors. .
, .
:
Set rs = New ADODB.Recordset
. With ADO

With rs
.Open sql, cn, adOpenForwardOnly, adLockReadOnly

, , .
SQL- . , cn, ,
cn.
: ,
. ADO,
. .

adOpenForwardOnly

.
.

,

.
,

,
.
, -

Ad0penKeyset
Ad0penDynamic

AdOpenStatic

, ADO ,
. pe-
, .

aLockReadOnly
AdLockPessimistic

AdLockOptimistic

AdLockBatchOptimistic


, ,

:
. Update .




,
.
,
(EOF).
Author :
lstAuthors.AddItem rs("Author")
.
MoveNext. , ,
. , ,
. .Close Recordset Connection.
Nothing .
, . MoveNext.
( ), . Do
While..., a - .MoveNext Loop,
. .

,
. ADO .
- .AddNew:

rs.AddNew
rs("Author) = "Doe, John" rs("Au_ID") = 123456
rs.Update
. , .AddNew.
, . ,
:

Rs("Author") = "Doe, John"


Rs!Author = "Doe, John"
Rs.Fields(1) = "Doe, John"
, .
, . , ,
, .
, . Update.

,
.AddNew. ,
. Update. :

Rs("Author") = "Brown, Steve"


Rs("Au_ID") = 373737
Rs.Update
DAO, ,
. Edit . ADO.

ADO . , -
. Delete. :

'
sql = "select *from authors where [Author] = 'Brown, Steve""
'
Set rs = New ADODB.Recordset
With rs
.Open sql, cn, adOpenForwardOnly, adLockReadOnly
If rs.RecordCount > 0 Then
rs.Delete
End If
'
.Close
End With
'
Set rs = Nothing
ADO, Microsoft
.
,
( ). , ADO
Web-!

Access . ,

, .
Visual Data Manager , Microsoft Access,
. Access ,
.
Visual Basic!
,
,
. Visual Data Manager.
, (
). Visual Basic
, .
.

?
:

ASCII- .
, .
.
Visual Data Manager.
.


Print

PrintForm
Printers
Crystal Reports VisualBasic

, , .
, .
, ,
. Visual Basic !
, Printers Printer
, . , Crystal
Reports Pro , Visual
Basic.

,
, , . ,
, . Visual Basic
:
;
;
;
, Crystal Reports Pro ( Visual Basic);
(, Word for Windows) DDE OLE Automation.
Print

Print. ,
, Print. ,

( Run > Break). Print
. Printer. Print,
Print,
(, frmMyForm.Print).
Cls , . ,
Print .

, . Print
, . ? ,
. int , ,
. EndDoc,
NewPage.
, (, Click )
, :

Printer.Print " "


Printer.Print " "
Printer.NewPage
Printer.Print " "
Printer.EndDoc

,
. -" ( )
.
:
MsgBox, ( , )
.
,
. .
, ,
MsgBox, , ,
MsgBox. .
.
, . , , ,
, , ,
.
Debug.
Print, :

X = X + 1
Debug.Print x
x.
Debug , .

, ,
, :
1. (File > New Project).
Standard EXE .
2. Form1, .
3. Click Form1:
Private Sub Form_Click() Dim x As Integer

On Error GoTo looperr

' x = 100000
Do While x < 100000
x = x + 1
Loop
'
Exit Sub
looperr:
Debug.Print
Debug.Print
End Sub

"!"
"x = " & Trim$(Str$(x))

. ?
4. , , .
. 9.1:

. 9.1.

7 , , ,
. ,
, .
-32 768 32 767. x 100 000,
, 32 768.
x Long.

, . :
1. , .
2.
Dim x As Integer
Click :
Dim x As Long
3. (Run > Start).
,
, . . Visual Basic
.
. ,
.
.

12,

, Print
. ,
, . ,
PrintForm.
PrintForm

PrintForm ( ) ,
. .
.
Me. PrintForm Form_Click ,
,

. ,
:
frmReport.PrintForm
Visual Basic frmReport.
frmSplash, frmMain, frmAbout .
Printers

Visual Basic Printers. B


-, .
, , ,
- .
, ,
:
1. Ctrl+N.
2. - (Standard EXE) New Project.
3. PrintersCollection.
4. Name Form1 frmMain, a Caption -
.
5.
Components.
6.
Components Microsoft Windows
Common Controls 6.0. .
7. frmMain . Name lvwPrinters.
8. frmMain, .
9. Resize :
Private Sub Form_Resize()
'
lvwPrinters.Move 0, 0, ScaleWidth,
End Sub

ScaleHeight

10. Load :
Private Sub Form_Load()
Dim p As Printer
Dim x As ListItem
'
With lvwPrinters
.View = lvwReport
.ColumnHeaders.Add , , ""
.ColumnHeaders.Add 2, , ""
.ColumnHeaders.Add 3, , ""
End With
'
For Each p In Printers
With p
Set x = lvwPrinters.ListItems.Add(, , .DeviceName)
x.SubItems(1) = .DriverName
x.SubItems(2) = .Port
End With
Next
End Sub
11. .

- , (. 9.2).

. 9.2. Printers

Crystal Reports Visual Basic


Visual Basic Crystal Reports Pro. C
.
, ,
.
Crystal Reports Pro Visual Basic
Report Wizard (. 9.3), Project Wizard.

. 9.3. Report Wizard Crystal Reports

( . 9.3) Crystal Reports Pro


, ,
. Report Wizard
. .
(. 9.4).
, , , ,
. , .

. 9.4. Crystal Reports


Crystal Reports Pro

Crystal Reports Pro, .


Visual Basic 6 .
Crystal Reports Pro :
1. - Visual Basic CD-ROM.
2. \Common\Tools\VB98\Crysrept -.

3. Crystl32.exe, .
.
,
. ,
.

Crystal Reports Pro :


1. Crystal Reports Pro , .
2. Crystal Reports Pro Visual Basic.
3. , New Project
.
Visual Basic.
4. Crystal Reports Pro Report Designer Add-Ins.
5. File > New Crystal Reports Pro.
6. Create New Report (Standard).
7. Create Report Expert (. 9.5) Data File,
.

. 9.5. Create Reports Expert

8. biblio.mdb \Program Files\Microsoft Visual Studio\VB98.


Add, .
9. Done.
. 9.6 Links,
.

. 9.6.

, All Titles, Title Author Titles


ISBN. Title Author Authors ( Au_ID),
Titles Publishers ( PubID).

. .
10. , Title Author c Authors,
Delete.
11. , Titles c Publishers,
Delete.
12. Next, .
Fields, . 9.7.
13. Au_ID Title Author Database Fields.
( Report Fields).
14. Title Titles, Report
Fields.
15. Next Sort (. 9.8).
16. Title Author.ISBN Report Fields Add,

. Order,
(in ascending order).
Next.

. 9.7. Fields

Puc. 9.8.

Total (. 9.9).
, .
17. Next. Select.
, . ,
ISBN.
18. Author.ISBN Add,
ISBN Title Author.
19. is .
20. greater than ( ).
21. 0-0307360-3- (
). , . 9.10.

. 9.9. Total

. 9.10.

22. Next, Style.


23. Title .
24. Style bl (. 9.11).
. .

. 9.11.

25. Preview Report, , .


. 9.12, ISBN .
, , .

, ,
, , .
, Crystal Reports Pro ,
.
1. Design . Crystal Reports Pro
.
(. 9.13) : Title
(), Page Header ( ), Details ( ), Page Footer (
) Summary (). . 9.1.

. 9.12.

. 9.13.

9.1.

Title
Page Header
Details

/ ,

,

. Crystal Reports
, (
),

Page Footer
Summary

,

, ,

2. Ctrl , , ISBN Title.


3. Format > Font Crystal Reports Pro.
Arial, Bold, 14 pt. OK, .
4. Insert > Picture.
5. Choose Picture File, beany.bmp
\Program Files\MicrosoftVisualStudio\Common\Graphics\Bitmaps\ Assorted.
.
6. (Page Header),
(. 9.14).
7. File > Save. First.rpt VB98.
8. Preview, .
.
, Crystal Reports Pro .

, Crystal Reports Pro,


.
, .
, ,
, Custom . . 9.15
Property Pages . ,
. ,
, (MAPI, VIM Lotus Notes).

. 9.14.

. 9.15. Property Pages Crystal Reports 4.6


, : 1. Visual Basic
File > New.
2. New Project Standard EXE.
.
3. Name ReportDemo.
4. Name Form1 frmMain, Caption
.
5.
Components.
6.
Components Crystal Report
Control4.6(pc.9.16).
7. OK, .
8. frmMain . Name cmdPrint,
Caption &Print.
9. Crystal Report Name rpt.
10. (Custom) Crystal Report.
Property Pages.
11. ReportFileName. ,
, Choose Report. Open.

. 9.16. Crystal Report

12. Print Window.


13. Title. 14.
.
,
.
15. cmdPrint . 16.
cmdPrint_Click() :

Private Sub cmdPrint__Click()


'
rpt.PrintReport
End Sub
17. .
Print, .
. 9.17.

. 9.17.

, Visual Basic .
:
.
Crystal Report Control 4.6 Visual Basic.
Crystal Report .
, .
.
Crystal Reports Pro
Crystal Reports. B ,

, ,
. .
.

.
,
. , .
, ? File > Print.
Print, , . 9.18.

. 9.18. Print
Print

Print , : Range

Print What. Range Selection, Current Module Current Project, o


.
Selection

, .

Current Module
, .
Print What (. ).
, ; ,
.

Current Project
, .
( ).
Print What.
Print What Print Form Image, Form As Text Code,
.

Form Image

.
,
. , ( - Form As Text)
,
-
.
.

, (,
),
Windows. Alt Print Screen.
, , .BMP.
,
, .PCX .BMP.
,
.RTF

Code
, . Code
. PrintRan Project,
. Code
( .
, Name .
Form_, Name
.
, cmdOK_Click Form_Load. (,
cmdOK ).
, . Visual
Basic - , .
.
Form As Text

, , .
, . ,
. ,
. ,
( Name Caption); ,
(Left, Top, Height Width); ,

( Scale...); TabIndex, ; LinkTopic


. LinkTopic . ,
Shortcut Caption.

. ,
. .
, , .
, Visual Basic
. . ,
!
? .
.
, (').
:

'
, :

cmdOK.Enabled = True ' OK


12, .

.
5.
.
Generic/Text, Windows.

, Generic/Text, Windows 95 NT.
FILE, ,
File > Print Visual Basic, Print to File.
WordPad .

5. ,
.
Form1 - 1
Option Explicit
Private SubmnuFileExit_Click()
End
End Sub

Private
Sub
tbrToolbar_ButtonClick(ByVal
ComctlLib.Button)
Select Case Button.Key
Case Is = "New"
MsgBox " New"
Case Is = "Open"
MsgBox " Open"
Case Is = "Save"
MsgBox " Save"
End Select
End Sub
frmData 1

Button

As

VERSION 5.00
Object = "{6B7E6392-850A-101B-AFCO-4210102A8DA7}#1.1#0"; COMCTL32.OCX

Begin VB.Form Form1


Caption
= "Form1"
ClientHeight =1572
ClientLeft
=3084
ClientTop
=2556
ClientWidth =3744
LinkTopic
="Form1"
ScaleHeight =1572
ScaleWidth
=3744 Begin ComctlLib.Toolbar tbrToolbar

Align
= 1 '
Height
= 336
Left
= 0
TabIndex
= 0
Top
= 0
Width
= 3744
_ExtentX
= 6604
_ExtentY
= 593
ButtonWidth = 487
Appearance
= 1
ImageList
= "imToolbar"
BeginProperty Buttons {0713E452-850A-101B-AFCO-4210102A8DA7}
NumButtons
= 4
BeginProperty Button1 {0713F354-850A-101B-AFCO4210102A8DA7}
Key
= ""
Object.Tag
= ""
Style
= 3
Value
= 1
MixedState
= -1 'True
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFCO-4210102A8DA7}
Key
= "New"
Object.Tag =""
ImageIndex
= 1
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFCO-4210102A8DA7}
Key
= "Open"
Object.Tag
= ""
ImageIndex
= 2
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFCO-4210102A8DA7}
Key
=
"Save"
Object.Tag =""
ImageIndex =3
EndProperty
EndProperty
MouseIcon = {Binary}

End
Begin ComctlLib.ImageList imlToolbar
Left = 2520
Top = 720
_ExtentX = 804
_ExtentY = 804
BackColor = -21474836643
ImageWidth = 16
ImageHeight = 16

MskColor
= 12632256
BeginProperty Images {0713E8C2-850A-101B-AFCO-4210102A8DA7}
NumListImages = 3
BeginProperty ListImage1 {0713E8C3-850A-101B-AFCO4210102A8DA7}
Picture
= {Binary}
Key
= ""
frmData - 2
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFCO4210102A8DA7}
Picture
= {Binary}
Key
= ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFCO4210102A8DA7}
Picture
= {Binary}
Key
= ""
EndProperty
EndProperty
End
Begin VB.Menu mnuFile
Caption
= "&File"
Begin VB.Menu mnuFileExit
Caption
= "E&xit"
End
End
Begin VB.Menu mnuEdit
Caption
= "&Edit"
Begin VB.Menu mnuEditCut
Caption
= "Cu&t"
End
Begin VB.Menu mnuEditCopy
Caption
= "&Copy"
End
Begin VB.Menu mnuEditPaste
Caption
= "&Paste"
End
End
Begin VB.Menu mnuHelp
Caption
= "&Help"
Begin VB.Menu mnuHelpAbout
Caption
= "&About"
End
End
End

.
. ,
. ,
. ,
. , Form1 - 1,
Form1. , frmData - 1,
.
, .
Begin VB. Form End.
, Begin...End,
. Begin ,
Name. .
, .

Crystal Reports Pro


, .
?
:

Print .

. 0 PrintForm
.

, , .
Crystal Report Pro .
Crystal Reports .
.

10




Windows ,
.
. , , Visual
Basic, a ,
.

Visual Basic :
. Visual Basic, ,
. (sg)
, (InputBox), , .

( ):
MsgBox , ,
, ; ;
,
. ,
.

vbOKOnly
vbOKCancel

0
1

vbAbortRetrylgnore

vbYesNoCancel

vbYesNo
vbRetryCancel

4
5



Cancel

Retry Ignore

Cancel


Cancel



Abort,
Yes, No
Yes No
Retry

vbCritical

16

()

vbQuestion

32

vbExclamation

48


()

vblnformation

64

, . ,
OK Cancel, a , :
DlgDef = vbOKCancel
DlgDef = 1 + 64
DlgDef MsgBox.

, . MsgBox
:
Dim As Integer
'
rc = (, , )
, .
.

vbOK
vbCancel.
vbAbort
vbRetry
vblgnore
vbYes
vbNo

1
2
3
4
5
6
7

Cancel
Abort
Retry
Ignore
Yes
No

, , .
:
Dim As String
= Input(, , )
,
. , .
OK, (
r). Cancel, .
InputBox , MsgBox
.

, InputBox: 1.
File > New Project
2. Project Wizard Standard EXE.
3. Form1.

4.
5.
6.
7.

Name cmdTryMe.
Caption & .
cmdTryMe, .
Click cmdTryMe:

Private Sub cmdTryMe_Click()


Dim r As String
rc = Input(" :")
MsgBox ", " & r & "!"
End Sub
8. Run > Start.
9. , InputBox. 10.
.
, MsgBox InputBox.
, , Visual Basic
, ! (, ,
).

, MsgBox InputBox ,
.
, . ,
, .
,
, ( )
. . , .
, .
,
, . :
1. .
2. :

Private Sub LoginBox()


Dim As String
= InputBox("Be :")
If = "" Then
MsgBox ", !"
Else
MsgBox ", " & & "!"
End If
End Sub
3. Click cmdTryMe:

Private.Sub cmdTryMe_Click()
LoginBox

End Sub
4. .
5. .
, LoginBox. Click,
LoginBox .
. ,
.
, , ,
. 15, (). ,
. , -
, Visual Basic. ,
shareware ( ). Visual
Basic (, ), shareware-,
ShareLib .
,
.
,
- .
, !

,
. ,
- () ActiveX 15
17. :
1. File > New Project.
2. ActiveX DLL .
3. Name modDialogs.
4. modDialogs :

Sub Main()
' ,
' DLL.
End Sub
5. Class1 , .
6. .
Name:

Instancing:

clsDialogs

5 - MultiUse

, , ,
? -
(,
). , , YNBox.
, vbYes ( 6).
clsDialogs :

Public Function YNBox(title As String, msg As String) As Integer


Dim rc As Integer
Dim DlgDef As Long
DlgDef = vbYesNo + vbQuestion
rc = MsgBox(msg, DlgDef, title)
YNBox = rc
End Function

.
, .
:

Public Sub ErrMsg(title As String, msg As String)


Dim rc As Integer
Dim DlgDef As Long
DlgDef = vbOkCancel + vbCritical
rc = MsgBox(msg, DlgDef, title)
End Sub
, .
, .
- ,
. -
,
, - . .

1. :

Public Function LoginBox (title As String, msg As String, _


default As String) As String
Dim rc As String
rc = InputBox(msg, title)
LoginBox = rc
End Function
2. dialogs.vbp.
3 Project Properties Dialogs Project Name.
Project Description .
4. Make Application Title Dialogs.
5.
,
. File > Make Dialogs.Dll .
DLL,
. ActiveX DLL 14.
, .

.
, ActiveX DLL
. .
:
1. File > New Project. B Project Wizard
Standard EXE.
2. Form1.
Name:

Caption:

FrmDialogs

3. py.frmDialogs . .
Name:
IblTitle
IblMsg

Caption:
:
:

4. .

Name:
txtTitle
txtMsg

Text:

5. .
Name:
cmdYN
cmdErr
cmdLogin

Caption:
&/
&0
&

. 10.1.

. 10.1.

6. Project > References.


7. (. 10.2),
.

. 10.2.

8. (Gene-ral)(Declarations):
Option Explicit
Dim dlg As clsDialogs
9. , ,
. Form_Load() :
Private Sub Form_Load()
Set dlg = New clsDialogs
End Sub

10. , ,
. ,
. Form_Unload():

Private Sub Form_Unload(Cancel As Integer)


Set dlg = Nothing
End Sub
11. , (YNBox):

Private Sub cmdYN_Click()


Dim rc As Integer
rc = dlg.YNBox(txtTitle.Text, txtMsg.text)
If rc = vbYes Then
MsgBox " Yes"
Else
MsgBox " No"
End If
End Sub
12. , (ErrMsg):

Private Sub cmdError_Click()


dlg.ErrMsg txtTitle.Text, txtMsg.text
End Sub
13. , (LoginBox):
Private Sub cmdLogin_Click()
Dim UserID As String
UserID = dlg.LoginBox(txtTitle.Text, txtMsg.Text, "")
If UserID <> "" Then
MsgBox UserID & " !"
End If
End Sub

14. .
, .
, :
1. ?.
2. ?.
3. /.
, . 10.3.

. 10.3. YNBox
ErrMsg .
. ,
:

1. .
2. !
3. .
, . 10.4.

. 10.4. ErrMsg
LoginBox ,
, . , LoginBox:
1. .
2. :.
3. .
, . 10.5.

. 10.5.

.
, .
,
, Visual Basic .
15 17.
?
:

Visual Basic .
.
.
.

11

OLE

, , Click
DblClick ( ). ,
Visual Basic. K
Shift, Alt Ctrl MouseDown
MouseUp, MouseMove. ,
.
.
. , ,
. ,
.
Click

Click . Visual Basic,


, Click,
. , Click ,
. :
Private Sub cmdOK_Click()
Unload Me
End Sub
DblClick

, DblClick,
.
Windows. B ,
. :
Private Sub lstmembers_DblClick()
Dim m As clsMember
Set m = New clsmember
m.MemberName = lstMembers.Text
m.ShowMemberProperties Set m = Nothing
End Sub

.
DragDrop

DragDrop , .
DragDrop :
Private
Single)

Sub

target_DragDrop(Source

As

Control,

As

Single,

As

,
. Source , .
X Y DragDrop().
, .
.
Co DragOver

DragOver .
:

Private Sub target_DragOver(Source


Single, State As Integer)

As

Control,

As

Single,

As

Source . X Y .

State .

State
0
1
2

,
. , ;
DragOver() Source DragIcon
.
MouseDown

, MouseDown.
MouseDown() :
Private Sub target_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single).
, X Y .
Button .
Button
1
2
4

, . ,
. :

Private Sub lstMembers_MouseDown(Button As Integer, Shift As Integer,


X As Single, Y As Single)
If Button = 2 Then
PopupMenu mnuMembers
End If
End Sub
Shift Shift, Ctrl Alt .
.

Shift

1
2
4

Shift
Ctrl
Alt

. , 6 ,
Ctrl Alt, a 7 , .
Shift And. C
If...Then . , :

If Shift = 6 Then
MsgBox " Ctrl Alt"
End If
:

If Shift And 6 Then


MsgBox " Ctrl Alt"

End If
MouseMove

MouseMove .
, ,
.
:

Private Sub cmdExit_MouseMove(Button As Integer, Shift As Integer, _


X As Single, Y As Single)
MouseDown.
, Exit:

Private Sub cmdExit_MouseMove(Button As Integer, Shift As Integer, _


X As Single, Y As Single)
Me.Caption = ", "
End Sub
MouseMove .

.
MouseUp

, MouseUp().
:

Private Sub target_MouseUp(Button As Integer, Shift As Integer,


X As Single, Y As Single)
MouseDown MouseMove.
Windows 95 Click. , MouseUp
End, .
, .
End , MouseUp .

Windows- (,
Windows Explorer). .
Visual Basic .
, :
1. Standard EXE.
2.
Name Form1 frmMain, Caption
.
3. . ,
.
4.
Name lstA, DragIcon
\Graphics\Icons\DragDrop\Draglpg.ico.
5. Name lstB, DragIcon
- \Graphics\Icons\DragDrop\Draglpg.ico. . 11.1.

. 11.1.
6. Form_Load() :

Private Sub Form_Load()


lstA,AddItem ""
lstA.AddItem ""
lstA,AddItem ""
End Sub
7. lstA_MouseDown() :
Private Sub lstA_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If lstA.ListCount > 0 Then
lstA.Drag 1
End If
End Sub
8. lstA_DragDrop() :
Private Sub lstA_DragDrop(Source As Control, X As Single, Y As Single)
If Source = lstB Then
lstA.Additem lstB.Text
lstB.RemoveItem lstB.ListIndex
End If
End Sub
9. lstB_MouseDown() :
Private Sub lstB_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If lstB.ListCount > 0 Then
lstB.Drag 1
End If
End Sub
10. lstB__DragDrop() :
Private Sub lstB_DragDrop(Source As Control, X As Single, Y As Single)
If Source = lstA Then
lstB.Additem lstA.Text
lstA.RemoveItem lstA.ListIndex
End If
End Sub
11. .
.
. ,
. (. 11.2).

. 11.2.
Drag.

MouseDown() 1, .
0, . , ,
Left x Drag 0.
,
DragDrop().
.
. ,
. DragIcon , .
, .
OLE

Windows 95 , ,
OLE (OLE drag-and-drop). OLE Object Linking and Embedding,
. ,
, OLE, ,
. Visual Basic ,
OLE. Windows
OLE.
OLE , .
OLEDragDrop DataObject.
OLE.
OLEDrag

OLEDrag OLE. ,
OLE OLE.
:
.0LDrg
- OLE, .
OLEDragMode

OLEDragMode ,
OLE OLEDrag
. .
vbOLEDragManual - 0
VbOLEDragAutomatic - 1

.

OLE
, Visual
Basic
OLE.

OLE

OLEDropMode

OLEDropMode OLEDragMode. ,
OLE .
.
vbOLEDropNone - 0

.
OLE
OLE
VbOLEDropManual - 1

OLE
VbOLEDropAutomatic - 2
, Visual Basic

OLE.
OLE
OLEDropAllowed

OLEDropAllowed , OLE
OLE. .
True
False

OLE
. OLE

OLEDragDrop()

OLE OLE c
. :
Private Sub _OLEDragDr( As DataObject, As Long,
As Integer, As Integer, x As Single, As Single)
, .
OLE DataObject, o .
GetData.
-,
. OLE,
(, , ).
.
vbDropEffectNone 0
VbDropEffectCopy - 1
VbDropEffectMove - 2
VbDropEffectScroll -2147483648

OLE


,
,

, OLE.
.
1
2
4

,
Ctrl, Shift Alt. AND (
) .
1
2
4

Shift
Ctrl
Alt

x . ,
.
OLECompleteDrag()

OLECompleteDrag
, . OLE
. , ,
.
: .
OLEDragDrop, ,
vbDropEffectScroll.
OLEStartDrag()

OLE
( OLEDragMode - vbOLEDrag Manual). ,
, - - OLE c
( OLEDragMode = vbOLEDragAutomatic).

DataObject - OLE
, - .
- ,
. : vbDropEffectNone, vbDropEffectCopy
vbDropEffectMove.
OLEDragOver()

OLE
OLE. , .
:
Private Sub _OLEDragOver( As DataObject, As Long, _
As Integer, As Integer,
x As Single, As Single, As Integer)

OLEDragDrop, .

, DragOver.
OLESetData()

OLESetData , - GetData
DataObject . :

Private Sub o_OLESetData( As DataObject,


- As Integer)
. DataObject,
. - ,
.
OLEGiveFeedback()

OLEGiveFeedback OLEDragOver.
, ,
. ,
.
OLE

OLE :
1. File > New Project. New Project
Standard EXE .
2.
Name Form1 frmMain, Caption -
OLE.
3. . ,
.
4. Name txt1 Text.
OLEDragMode 1 - Automatic, a MultiLine - True.
ScrollBars 2 - Vertical.
5. Name txt2 Text.
OLEDragMode 1 - Automatic, a MultiLine - True.
ScrollBars 2 - Vertical.
6. OLEDragDrop txt1:
Private Sub txt1_OLEDragDrop(Data As DataObject, Effect As Long, Button
As Integer, Shift As Integer, X As Single, Y As Single)
If Shift > 0 Then
Effect = vbDropEffectCopy
Else
Effect = vbDropEffectMove
End If
txt1,Text = Data.GetData(vbCFText)
End Sub

7. OLEStartDrag txt1:
Private Sub txt1_OLEStartDrag(Data As DataObject, _
AllowedEffects As Long)
Data,SetData txt1.Text, vbCFText
End Sub
8. txt2 .
OLEDragDrop txt2:
Private Sub txt1_OLEDragDrop(Data As DataObject, _
Effect As Long, Button As Integer, Shift As Integer, _
X As Single, Y As Single)
If Shift > 0 Then
Effect = vbDropEffectCopy
Else
Effect = vbDropEffectMove
End If
txt2.Text = Data.GetData(vbCFText)
End Sub
9. OLEStartDrag txt2:
Private Sub txt2_OLEStartDrag(Data As DataObject, _
AllowedEffects As Long)
Data.SetData txt2.Text, vbCFText
End Sub
10. .
- .
. ,
WordPad Microsoft Word txt1 (
WordPad (Notepad) OLE).
WordPad . . 11.3.

. 11.3.

. ,
, . Windows
.
, , .

, .
, .
About
. About, Form Wizard,
.
,
.
1. Standard EXE.
2. Caption Form1 .
3. Form1. Caption &About, Name
mnuAbout.
4. Add >
Form. Form Wizard About Dialog Open (. 11.4).

. 11.4. About
5. , About,
.
6. picIcon_MouseUp()
:

Private Sub picIcon_MouseUp(Button As Integer,


Shift As Integer, X As Single, Y As Single)
If Button = 2 And Shift = 6 Then
MsgBox " .!"
End If
End Sub
7. Form1 , .
8. mnuAbout_Click() :

Private Sub mnuAbout_Click()


frmAbout.Show vbModal
End Sub
9. .
10. ...
, , ,
. , . 11.5.
. ,
. , .wav,
19, DLL Windows API, .

. 11.5.
?
:

.
.
OLE .
About.

12


Visual Basic

,
. ,
,
. ,
, .
,
.

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

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

.
,
. .

. :
,
? , , , ?
.
,
,
, Visual Basic.
- ,
,
. , ,
:
' :
' :
' Copyright:
:
' /:
' :
' :
:
' :

:
1.1
'Copyright:
1998-ABCSoftware
All Rights Reserved
' :

'/:
/ Software
':
.
'

':
:
Windows 95 / Windows NT 4.0
:
MS SQL Server 6.5
MS Transaction Server 2.0
. -
, ,
. ,
, .
16, IDE c .
-
(, ), .
, ,
.


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

' :
' :
':
':
':
':

:
' :
NETAPIs.cls
':

':
6 1998 .
':

' Win32 API. ,
' , '
ANSI Unicode.
':
':
6-6-98
' .
,
. 8-14-98
.
,
(General)(Declarations) ,
. ,
.



. ,
. :
'
': AddUser()
':

'
:
6 1998 .
':

':

UserID Password.

. ,
, , . ,
.


. ,
. ,
( ).
.

'
' ???

.
,

.
,

' !!!

. ,
,
. ,
.

.
. ,
, .
(. ) .
, ,
.
,
'!!!"- , .
, ,
!!! - .
, , ,
. , .
,
!

,
.
. 3.
, Visual Basic . Visual
Basic , . ,
Form1. Name
, Visual Basic Form2.
Form3 . . .
, ,
Command1 Command12. , ,
, .
, ,
Name - . ,
.

,
:
,
(, UserName).
,
(, ACCESS_ LEVEL_ADMIN).
,
Visual Basic.

frm

frmMain


OLE

cmd
lbl
txt
cbo
1st
fra
opt
chk
pic
img
scr
tmr
drv
dir
fil
lin
sha
dat
pie
tvw
lvw
iml
sts

cmdOK, cmdCancel
IblName
txtLastName
cboAccounts
IstGroups
fra0ptions
opt0n, opt0ff
chkTaxDeductible
picWaterMark
imgSplasGraphic
scrVolume
tmrCountDown
drvDisk
dirDirectories
filHiddenFiles
linSeparator
shaCircle
datLogDatabase
oleWordDocument
tvwGroups
IvwUsers
imlGroups, imlUsers
stsAccountStatus

,
, .



.
Visual Basic ,
Tools > Options Editor Options (. 12.1).

. 12.1. IDE
, 6, . ,
:

Select Case x
Case Is = 1
'
1
Case Is = 1
' 1
Case Is = 1

' 1
Case Else
'
End Select
, :

Select Case x
Case Is = 1
'
Case Is = 1
'
Case Is = 1
'
Case Else
'
End Select

1
1
1

. ,
, Open Close. ,
Do, Do Loop :

Open filename For Input As fileno


Do While Not EOF(fileno)
Input #1, txt
Debug.Print txt
Loop
Close fileno

. ,
. , .
Visual Basic

, , Editor
Options (. 12.2).

. 12.2. Options

Auto Syntax Check,


. ,
, .
Option Explicit , Visual Basic ,
.
, Require Variable Declaration.
, , Visual

Basic, Dim, Public Private.


Visual Basic , Variant. ,
Variant .
Variant .
.
Require Variable Declaration IDE.
Visual Basic Option Explicit , .
.
,
. .
, .

Auto List Members Visual Basic ,


. . 12.3.

. 12.3.

Auto Quick, Visual Basic


(. 12.4). ;
, Visual Basic .
Auto Data Tips ,
(. 12.5). .
Auto Indent .
, .
: .

. 12.4. (Auto Quick Info)

, Visual Basic ,
.
, .
, Visual Basic.

. 12.5. (Auto Data Tips)

Visual Basic

.
. , Visual Basic
, .
Debug , . 12.6.

. 12.6.

View > Toolbars > Debug.


, Start . ,
Run > Start F5. Break
. ,
.
, Start Resume.
, .

Stop . Toggle Breakpoint


.
.
, , .

Debug>ClearAllBreakpoints Ctrl+Shift+F9.

Step Into .
, .
F8, Debug
, ,
.
Step Over
. ,
. Shift+F8.
Locals Window (. 12.7)
, , .

.
, ,
. , !

. 12.7.

Immediate Window ( Ctrl+G) (. 12.8).


,
.

. 12.8.

. ,
Watch Window . . 12.9,
tbrToolbar .

. 12.9. tbrToolbar
Quick Watch, Visual Basic (.
12.10) . Add ,
.

. 12.10.
Call Stack ,
. . 12.11 : Form_Load StartTimer.

. 12.11.
Debug Run to Cursor.
, .
, . , ,

, .
, , Run to Cursor,
, . Run to Cursor
Ctrl+F8.


Visual Basic ,
:
1. MDINote.vbp \MSDN98\98vc\1033\Samples\VB98\ MDI\.
2. frmNotepad frmNotepad
View > Code .
3. Form_Load.
4.
For i = 1 To Screen.FontCount 1
F9.

(. 12.12).

. 12.12.

5. F5. ,
.
6. F8, .
7. mnuFontName(0). Caption Quick Watch
.
8. Add,
. .
9.
. Windows.
10.
,
Ctrl+Shift+F8, Form_Load.
MDIForm_Load.
11. End.

,
. ! :
1. Ctrl+G.
2. Ctrl+Shift+F9, .
3. Module2, .
4. OpenFile.
5.
On Error Resume Next

6. :
OpenFile "c:\config.sys"
7. Enter. B OpenFile.
: IDE ,
, 5 .
8. F8 .
, FindFreeIndex().
9. FindFreeIndex() Call Stack
. , FindFreeIndex() OpenFile() ,
.
10. Show, .
11. F8.
, ,
. - ,
.
,
Visual Basic:
1. , .
2. Ctrl+A, ( ).
3. Delete.
4. Enter:

Print Mid$("Ha ", 4, 3)


.
5. :
?Format$(Date$,"mmmm")

. ,
. , .
? Print.
, ? .

Visual Basic
. .
, ,
.


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

. 12.13. Debug Toolbox

:
1. File > New Project Ctrl+N.
2. New Project Standard EXE,
.
3. Project1.
4. Name Debug Toolbox.
5. Form1 , .
6. Name frmMain, Caption Debug Toolbox.
7. .
, .
8. Name lstResults.
9. . Name fraFunctions, Caption
.
10. fraFunctions lstResults ,
.
, .
.
1. .
, , .
, .
, .

2.
Name cmdSpellMonth, Caption -
Spell&Month.
, .
,
.
3. cmdSpellMonth, .
4. Ctrl+C, Windows.
5.
fraFunctions, .
.
6. Ctrl+V; . ,
cdmSpellMonth (. 12.14).

. 12.14. ?
7. No .
-.
8. cmdSpellMonth.
9. Name cmdUTrim, Caption - UTrim$.
10. cmdUTrim Ctrl+C, .
11. fraFunctions Ctrl+V, .
, , (No).
12.
cmdUTrim cmdSpellMonth.
13. Name cmdCubeRoot, Caption - C&ube
Root$. , . 12.15.

. 12.15. Debug Toolbox


. , .
:

1. Form_Resize frmMain:

Private Sub Form_Resize()


' .
' 1/2 .
lstResults.Move 0, 0, ScaleWidth, ScaleHeight / 2
' .
' 1/2 .
fraFunctions.Move 0, ScaleHeight /2, ScaleWidth,ScaleHeight / 2
End Sub
2. , , .
ShowProcedure(). (General)(Declarations)
frmMain:

Private Sub ShowProcedure(Proc As String)


'
lstResults.AddItem " : " & vbTab &
End Sub
3. .
(Gener1)(D1tions) frmMain:
Private Function GetInput(Msg As String) As Variant
Dim rc As Variant
'
rc = InputBox(Msg, " ")
lstResults.AddItem " : " & rc

GetInput = rc
End Function
4. frmMain :
Private Sub ShowResults(result As Variant)
'
lstResults.AddItem ": " & vbTab & result
End Sub

5. .
:
1.
Add Module .
2. Name TestProcedures.
SpellMonth(). ,
. , 5,
.
3. (General)(Declarations) TestProcedures:
Public Function SpellMonth(MonthNumber As Integer) As String
Dim rc As String
'
rc = Format$(MonthNumber & "/1/1998", "mmmm")
'
SpellMonth = rc
End Function
UTrim$(). Visual Basic

UCase$(), , Trim$(), . ,
UTrim$(txt) UCase$(Trim$(txt)).
.
. :
If UTrim$(MyInput) = UTrim$(DatabaseValue) Then...
'
Else
'

End If
4. UTrim$() :
Public Function UTrim$(Txt As String) As String
'
' .
Txt = UCase$(Trim$(Txt))
End Function
5. 4, MyLibrary
7; 6.
6. :
Public Function CubeRoot(x As .Double) As Double
If x = 0 Then
CubeRoot = 0
Exit Function
End If
CubeRoot = 10 " ((Log(Abs(x)) / Log(10)) / 3)
If x < 0 Then
CubeRoot = -CubeRoot
End If
End Function

7. .
, .
.
. :
;
;
;
;
.
, SpellMonth():
1. cmdSpellMonth_Click:
Private Sub cmdSpellMonth_Click()
Dim As Integer
Dim result As String
'
ShowProcedure "SpellMonth"
'
rc = GetInput("Be :")

'
rc = SpellMonth(rc)
'
ShowResults result
End Sub
2. UTrim$():
Private Sub cmdUTrim_Click()
Dim rc As String
Dim result As String
'
ShowProcedure "UTrim$"
'
rc = GetInput("Be :")
'
rc = UTrim$(rc)
'
ShowResults result
End Sub

3. , CubeRoot():
Private Sub cmdCubeRoot_Click()
Dim rc As Double
Dim result As String
'
ShowProcedure "CubeRoot"
'
rc = GetInput(" :")
'
rc = CubeRoot(rc)
'
ShowResults result
End Sub
4. .
.
, , . ,
!

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

1
2

3
4
5
6
7
8
9
10
11
12

1. SpellMonth. : SpellMonth,
.
2. 10 . (. . 12.16)
SpellMonth . ,
. , .

. 12.16. SpellMonth()

3. SpellMonth.
4. 7 .
.
5. SpellMonth.
6. 1 .
.
SpellMonth() . ,
.
7. SpellMonth.
8. 15 .
12 , . ?
, 15-12, ?
1 12, ?
SpellMonth() If...Then...Else,
.
9. Debug Toolbox,
SpellMonth().
10. SpellMonth() :
Public Function SpellMonth(MonthNumber As Integer) As String
Dim rc As String
' , MonthNumber
' 1 - 12
If MonthNumber > 0 And MonthNumber < 13 Then
'
rc = Format$(MonthNumber & "/1/1998", "mmmm")
'
SpellMonth = rc
Else
'
SpellMonth = ": !"

End If
End Function
11. .
12. SpellMonth.
13. 15 .
.
, .
, SpellMonth().
. ,
. , -
, - , !

SpellMonth().
UTrim$(). .
.


- !




- !

1. UTrim$, UTrim$().
2. , .
.
3. .
4. . 12.17, . , ,
. UTrim$().

. 12.17. Uri$
Txt UCase$(Trim$(Txt)).

Public Function UTrim$(Txt As String) As String


'
' .
Txt = UCase$(Trim$(Txt))
End Function
, Txt
UTrim$.
5. ( End Function) :

UTrim = UCase$(Trim$(Txt))
6. .
7. UTrim$, UTrim$().
8. , .
.
9. . !
10. UTrim$

. ,
- (. 12.18).
11. OK, .
12. UTrim$,
UTrim$().

13. - !
14. .
15. . 12.19, UTrim$() .
, .

. 12.18.
, , , ,
.
.
Debug Toolbox.
CubeRoot. 4 .
, . .
, .

. 12.19. UTrim$()

1
8
9
27
300

1
2
2.080083823
3
6.694329501

1. CubeRoot.
2. 1 . 1.
3. CubeRoot.
4. 8 . 2.
5. CubeRoot, .
6. 9 . 2.0800838230519.
7. CubeRoot.
8. 27 . 3.
9. CubeRoot.
10. 300 . 6.69432950082169.
, , . ,

, CubeRoot()
. , ShowMonth() UTrim$(), .
,
.
. ,
. ,
(
, ?).
, .
.
, !
.
,
. : ,
!

?
:

.
.
.
Visual Basic.
.

13








HTML
-
, ,
. ,
. , .
- -,
. .
. .

.
, - - .
.
,
. e ,
. ,
.

,
, Visual Basic.
, .
. ,
.


RTF (Rich Text Format)
Word for Windows, . Word,
.
, HLP- RTF (a
-, ). Visual Basic
. Help Workshop, - Visual Basic
(.13.1).
(Help Compiler
Guide), Visual Basic.
RTF- HLP-.

. 13.1. Help Workshop


, ,
. ASCII Contents.
, . ,
, , .
, . . 13.2 ,
.

. 13.2.

,
. -, ,
( , ). ,
, . Help Workshop
(. 13.3) Visual Basic IDE.
Help Workshop , Contents
. .
.

. .
:
1. Help Workshop \Common\Tools\VB\HCW - Visual
Basic ( ).
2. Help Workshop .
3. File > New. Help
Contents .
4. , , . Default
Filename Skill13. hip.
5. Default Title .

. 13.3.

6. .
Add Above Heading. Title .

7. Add Below, .
Heading Title .
, .
8. Move Right, .
Visual Basic, , ,
, .
.
9. Add Below, Topic. Title
, Topic ID -IDH_CreateContentsFile. Help File
Window Type .
10. :

IDH_AddHeadings
IDH_AddTopics

11. Add Below. Title


.
12. :


IDH_WriteTopics
IDH_AddFootnotes
IDH_SaveRTF

13. Title
.
14. :

IDH_CreateProjectFile
IDH_SetOptions
IDH_SaveRTF
IDH_AddFiles
IDH_DefineWindow
IDH_Compile
IDH_Test

, . ,

. , .

, .
RTF (Rich Text Format) , , ,
. Microsoft Word,
.
1. .
2. : .
, , :

.
Help
Workshop

Visual Basic -

.
Help Workshop File | New.
Help Contents .

3. , .
. .
4. > ,
(#). .
5. , IDH_CreateContents File
.
6. ,
. .
7. > ,
($).
8. , .
9. , , .
. ( > ),
() (+).
10. auto. Windows Help
.
11. ,
. ,
. 13.4.
, . -,
, .
. .
( ).
, Help Workshop
.
, .
. , ,
. .
, .
, :
, (#).
, , .
($). ,
, Visual Basic $ .
(+) . ,
+ - , +
.

. 13.4.

:
, .
(#), .
.
($) .
, .
(+).
auto, .
Skilll3.rtf. ,
RTF.
,
. , !

,
:
1. , Ctrl+Enter.
, .
.
2. :


Add Above Add Below.
Edit Contents Tab Entry,
Heading, .
.
, -
. ,
, .
3. :
# IDH_AddHeadings
$
+ auto

4. :


, ,
. , , .
, Add Below Add Above,
Edit Contents Tab Entry Topic.
. Help Workshop
, IDH_.
,
. . ,
. Title.
:
.
5. :
# IDH_AddTopics
$
+ auto

6. :


.
, RTF (Rich Text

Format).
.
.
, . Word
Ctrl+Enter.
, ,
.
7. :
#
$
+

IDH_WriteTopics

auto

8. :

, .
.
,
(#).
:
(
). Word | #
.
IDH_ .
9. :
#
$
+

IDH_AddFootnotes

auto

10. :

, RTF.
Help Workshop .
11. :
#
$
+

IDH_SaveRTF

auto

12. :

.
,
,
.
Help Workshop File|New. Help
Contents .
Help File.
Skill13.hlp.
13. :
# IDH_CreateProjectFHe
$

+ auto

14. :

Options, .
General
Help Title .
Compression
Custom Hall Compression.

.
Files
(
RTF).
Contents File .
15. :
# IDH_SetOptions
$
+ auto

16. :

,
, .

17. :
#
$
+

IDH_AddRles

auto

18. :

,
.
Window. Window Properties
Add. ,
Procedure.
Buttons Browse -
.
, .
19. :
# IDH_DefineWindow
$
+ auto

20. :


,
. Save and Compile
.
, .
. ,

.
21. :

#
$
+

IDH_Compile

auto

22. :

.
, .
.
, .
,
.
23. :

#
$
+

IDH_Test

auto

. ,
. ,
. , .
.


, :
1. Help Workshop , .
2. File > New. Help Project
.
3. Help Workshop , Skill13 Save.
Help Workshop . 13.5.

. 13.5.
4. Options .
5. Open Help Title.

6.
Compression. Custom, - Hall
Compression.
7. Files Help File Skill13. hlp.
8. Change RTF Files.
9. Topic Files, Add. Skill13.rtf.
. Open.
10. Skill13.rtf Topic Files, .
11. Browse Contents. Skill13.cnt.
.
12. Options .
, Options
(. 13.6). , ,
Help Workshop.

. 13.6. Options
13. Windows, Window Properties (. 13.7).
14. , . Add New
Window Type Main Create a Window Named. Based on this
Standard Window Procedure. , .
, Windows Properties ,
. 13.7.
15. Buttons Browse.
. .

. 13.7. Window Properties


16. Window Properties .
, . 13.8.

. 13.8.
17. Map.
-.
18. , , Add
Topic ID, Mapped
Numeric Value.

IDH_CreateContentsFile
IDH_AddHeadings
IDH_AddTopics
IDH_WriteTopics
IDH_AddFootnotes
IDH_SaveRTF
IDH_CreateProjectFile
IDH_SetOptions
IDH_AddFiles
IDH_DefineWindow
IDH_Compile
IDH_Test

100
200
300
400
500
600
700
800
900
1000
1100
1200

19. .
20. Save and Compile. Workshop .
, (. 13.9).

. 13.9.
, ,
. :
1. Help ( ) .
2. View Help File,
Skill13.hlp. , Browse Skill13.hip.
, View Help.
3.
Contents ,
. , .
, .
, . ,
.
.
, ,
. .
Help Workshop
Windows.

HLP- .
,
.
,
.
, Project Properties
Help File HelpFile
( ) .
Windows API
. .
API, 19, DLL Windows
API, API,
. :
1. Visual Basic Standard EXE.
2. Name Forml frmMain, Caption
.
3. Projectl
Projectl Properties.
4.
Project Properties Help File
, .
5. :

File
Caption:

Name:

&File

nnuFile

File
Caption:

Name:

E&xit

mnuFileExit

Help
Caption:

Name:

&Help

mnuHelp

Help
Caption:
&Contents Files
&Topic Files
&Project Files

Name:
mnuHelpContentsFile
mnuHelpTopicFiles
mnuHelpProject

6. , .
7. . Name
dlgHelp. .
8. mnuFileExit_ Click() End.
9. Form_Load() :

dlgHelp.HelpFile = App.HelpFile
10. mnuHelpContentsFile, Click():

Private Sub mnuHelpContentsFile_Click()


dlgHelp.HelpContext = "100"
dlgHelp.HelpCommand = cdlHelpContext
dlgHelp.ShowHelp
End Sub
11. mnuHelpTopicFiles. Click():

Private Sub mnuHelpContentsFile_Click()


dlgHelp.HelpContext = "400"
dlgHelp.HelpCommand = cdlHelpContext
dlgHelp.ShowHelp
End Sub
12. mnuHelpTopicFiles_Click():

Private Sub mnuHelpProject_Click()


dlgHelp.HelpContext = "700"
dlgHelp.HelpCommand = cdlHelpContext
dlgHelp.ShowHelp
End Sub
13. .
,
. ,
, HelpContext
.
, F1 ,
HelpContextID . ,
:
1. frmMain. Name txtHelp,

HelpContextID - 1200. Text.


2. .
3. , . F1.
, (.
13.10).
, . , Windows
,
, .
.

. 13.10.
HTML

, Visual Basic
Win Help. Visual Basic HTML,
Microsoft Developers Network.
, ,
HTML. HTML ,
HTML Help Workshop (. 13.11) Winhelp-
HTML. , HTML Help Workshop .
,
HTML HTML Help Workshop .
htmlhelp.exe \HTMLHelp - Visual Basic.
Windows, .
, .
HTML Help Workshop
, HTML:
1. HTML Help Workshop.
2. File > New Help Workshop.
3. Project .
4. New Project Wizard (. 13.12). ,
Convert Win Help project , Next.

. 13.11. HTML Help Workshop

. 13.12. New Project Wizard

5. (. 13.13) .
Skilll13.hpj, . ,
, Browse .

. 13.13.
6. Skill13.hpj Browse ,
HTML-.
7. HTMLHelp File Name
.
8. ( ), Next.
9. (. 13.14),
. ,
Finish.
, .
,
. ,
.
10. Index Help Workshop.
.
11. (Create a New Index File) .
12. Save As. Index Filename
Next, .

. 13.14.
13. Project.
14. Change Project Options ( ).
Options (. 13.15).

. 13.15. Options
15. Compiler.
16. Compile Full-Text Search Information .
.
17. Save All Project Files and Compile (
Project).
HTML-,
. Help
Workshop ( . 13.16).

View Compiled File ( ).


,
Compiled Field. View, (. 13.17).

. 13.16.

. 13.17.

, ,
Search.
, Index HTML-.
HTML.
HTML , HTML
.
, HTML .
HTML Dynamic HTML,
Web-
.
!
HTML Internet Explorer.

HTML- , ,
Internet Explorer, .

?
:

.
.
.
, .
.
HTML Help Workshop HTML.

14


Make

Package and Deployment Wizard

.

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

! ,
, . , .
, , .
(),
(DLL) ActiveX (OCX).
, Visual Basic.
Visual Basic Terminal.
. ,
. Visual
Basic -Package and Deployment Wizard.
.
( , ),
, Package and Deployment Wizard.
,

VB
Terminal
(
Vbterm.vbp

\Samples\CompTool\MsComm), :
1.
VB Terminal ( Vbterm.vbp \MSDN\98VS\1033\
Samples\VB98\MsComm).
2. File > Make vbterm.exe Visual Basic.

3.
Make Project, File Name
vbterm.exe. Options.
.
, Make Compile, .
Make

Make , .
, . . Make : Version
Number, Application, Version Information, Command Line Arguments
Conditional Compilation Arguments (. 14.1). VBTerm Compile,
- .
, Compile.

. 14.1. Make V

Version Number .
. : (major)
(minor) , ( ).
1.0.0, .
, Revision . 14.1 8139.
, , ,
. Auto Increment , Visual Basic
.
.
, .

Windows, Properties1
Version Properties. ,
.
, ,
, . Auto Increment
. ,
.
.
, .
.

Application Title Icon. Title ,


, . Icon
, .
, , , , frmMain.
Icon frmMain.
.

Version Information Value.


, .
, Value.
, , , ,
.
Comments,
, , -.
, . ,
, Company Name
Value. File Description ,
.
1 . , .


Legal Copyright, ,
. : ,
. ., .
, ( ) (public
domain). ,
. ,
, . Legal Copyright
, , .
, ,
Copyright ( ) . ,
, All rights Reserved. ,
:

Version 1.0.5 Copyright 1996 - Steve Brown


All rights Reserved

.
.
, .

,
, , Legal Trademarks.
Product Name . , VBTerm
, Value Visual Basic Terminal.
, .
, Hello.exe: Hello World,
, Hello,
. , .
. Visual Basic
.
.

,
. ,
, . Command Line Arguments
Run, Start2. :
. C:\Files\MyDoc.DOC
, ,
Command$. , ,
. InStr() Mid$(). :

Private Sub Form_Load()


If Commands <> "" Then
If InStr(Command$, "/?") > 0 Then
ShowHelp
End If
End If
End Sub
Command$ Visual Basic.
, . ,
Commands Load .
, -
. , If..Then ,
. , .
/?, ,
DOS. If...Then
, .
InSt() . ,
InStr() , . ,
/?, InStr() .
, If...Then
ShowHelp.
, Command Line Arguments, .
, .
2

Windows 95. . .

.

. , :

Private Sub Form_Load() Dim platform As String


#lf WIN_NT Then
platform = "Windows NT"
#Else
platform = "Windows 95/98"
#End If
MsgBox platform
End Sub
Windows NT, Conditional Compilation
Arguments
WIN_NT=1
Windows 95 Windows 98,
WIN_NT=0
#Const.
, :
#Const WIN_NT = 1
, , (#).
.
, . Visual Basic #Const
#If...#Then...#Else...#End If. #Const
, #If ...#Then...#Else...#End If .
Compile

Compile , (. 14.2).
-,
.

. 14.2. Compile
Compile to P-code

Visual Basic
(, -). Visual
Basic. , -, ,
VBRUN300.DLL VBRUN500.DLL - ,
DLL- . ,
, .
VBRUN500.DLL -. -
, , .
-, . ,
.
. , - .
,
. , ,
, -. (,
) . , - . ,
, ,
-.
Compile to Native Code

Visual Basic
. , Visual Basic.
DLL , .
Compile to Native Code .

Optimize for Fast Code Visual Basic
. , ,
.

Optimize for Small Code Visual Basic
. ,
, , , ,
.
Pentium Pro
Favor Pentium Pro Visual Basic ,
Pentium Pro. He ,
Pentium Pro, , .

Create Symbolic Debug Info .
, Visual C+
+ , CodeView. Visual Basic
.PDB, .

No Optimization Visual Basic ,
. .

Advanced Optimizations (. 14.3).


, Visual Basic, .
Visual Basic .

. 14.3. Advanced Optimizations


,
. Make. , Compile
, .
. ,
Package and Deployment Wizard.
Visual Basic ,
VBRUN600.DLL
. OLE,
. Package and Deployment Wizard, ,
.
Package and Deployment Wizard

Package and Deployment Wizard Visual Basic, 6.


Setup Wizard Visual Basic.
Package and Deployment Wizard ,
. Package and Deployment Wizard
(. 14.4).
,
.

. 14.4. Package and Deployment Wizard


, VB Terminal:
1. Visual Basic, , Package and Deployment Wizard.
2. Browse, VBTerm.
3. VBTerm.vbp \MSDN\98VS\1033\Samples\VB98\MSComm.
Open.
4. Package, .

5. (. 14.5).

. 14.5.
6. Standard Setup Package ( ) Package Type.
, ,
Dependency File.

7. Next.
8.
. 14.6,
. , .
Setup ( ),
Next.
(. 14.7) ,
. Add
, .

. 14.6.

. 14.7. ,
9. ; Next,

.
10. Cab Options (. 14.8)
-. (Single cab).
,
Multiple cabs .
1,44 .

. 14.8. -
11. Next. Installation Title (. 14.9)
, .

. 14.9.
12. Visual Basic Terminal Installation Next . 14.10
, Setup Wizard. Package and
Deployment Wizard .
13. VBTERM, Properties.
Start Menu Group Properties (. 14.11), Name Visual Basic
Terminal. .

. 14.10.

. 14.11.
, Windows NT.
Wizard ,
, Windows NT.

14. VBTERM Properties.


Start Menu Item Properties (. 14.12), Name Visual Basic Terminal
. .

. 14.12. Start Menu Item Properties

15. . Next,
.
. 14.13 Install Locations.
, .
.

. 14.13. Install Locations

16. Next, .
Package and Deployment Wizard
(. 14.14).
ActiveX, ( ).
17.
Next.
! . 14.15
, .
, Package and Deployment Wizard

, .

. 14.14. ,
18. Script Name VBTerm Setup Script Finish.
Finish Package and Deployment Wizard
, .
, (. 14.16)
.
.
,
.
19. Package and Deployment Wizard Close.

. 14.15.

. 14.16.

,
. ,
. ,
.
, .
, !
Visual
Basic 6. , .
, , ,
. ,
Package and Deployment Wizard ,
. Package and Deployment Wizard (, , )
.
,
. .
!

,
. , ,
Package and Deployment Wizard,
, .
.
, . Package and Deployment Wizard
. ,
Web- F-, ,
. , Web- FTP--,
. , .
.
. ,
. ,

?
:

.
- .
- .
.
.
Package and Deployment Wizard .
.

15
-
()


?
,



-
. , C++ SmallTalk, Visual Basic.
- ,
Visual Basic. ,

- , , ,
. ? .
, .
,
.
. ,
, , . ,
.
. ,
!
,
. Private, Public Friend.
, ,
(Public) .
; .
Visual Basic .
(visual). ,
Appearance, BorderStyle, Caption, Name WindowState.
. ,
Load, Unload, Show Hide.
, .
. , ,
.
, ,
. ( )

.
?

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

XYZ.
, .
, .
.
. ,
, .
,
.
XYZ , .
, , .
, ,
. ,
. , .
,
XYZ.
, XYZ , ,
. ,
, .
,
XYZ. , .
, ,
.
, .
,
. , ,
- .
.
,
. , ,
,
.
, -.
,
. . ,
. ,
. ,
.
.
, .

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

. , .

1, . ,
, ,
. ,
. , ,
:
Public IsManager As Boolean

, .
, :
Public Department As String

, .
EmployeelD:
Public EmployeelD As Long

. 15.1 , . ,
.
, .

. 15.1.

, . , -
.
? (. 15.2). ,
, ,
. :
Public Function GetFileO As String
If IsManager and Department = "" Then
GetFile = " "
Else
GetFile = ""
End If
End Function
,
. .
.

. /5.2.

-. ,
-.
, Name, WindowState BorderStyle, Load, Unload Hide.
Visual Basic,
New.
.
10. clsDialogs
YNBox, ErrMsg LoginBox. , - ,
. :
Dim dlg As clsDialog
New:
Set dlg = New clsDialog
, dlg, : YNBox, ErrMsg LoginBox.
clsDialogs.
. New Visual Basic
, .

,
. .
.
.
,
. .
, . ,
. Visual Basic
Private. , ,
Private, , .
, Sub Function
Public:
Public Function Format_Disk(Drive As String)
, . ,
.
.

. ,
. -.
,
.

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

. 15.3.


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

, ,
:
1. Standard EXE.
2. .
Add > Class Module.
3. Name clsHR.
4. (General)(Declarations) :
Option Explicit
Public Manager As Boolean
Public Dept As Integer
Public EmpID As Integer
Public EmpName As String
Public EmpDept As Integer
Public EmpPerformance As String
Public Reason As String
5.
,
:

Public Function GetRecord() As Boolean


If Manager = True Then
If Dept = GetDept() Then
Empname = GetEmpName()
EmpPerformance = GetPerfEval()
Reason = ""
GetRecord = True
Else
Reason = " " _
& " "
GetRecord = False
End If
Else
Reason = " _
& " "
GetRecord = False
End If
End Function
6. , :
Public Function GetDept() As Integer
Select Case EmpID
Case Is = 1
GetDept = 1
Case Is = 2
GetDept = 1
Case Is = 3
GetDept = 2
Case Else
GetDept = 0
End Select
End Function
7. :
Public Function GetEmpNameO As String
Select Case EmpID
Case Is = 1
GetEmpName = " "
Case Is = 2
GetEmpName = " "
Case Is = 3
GetEmpName = ""
Case Else
GetEmpName = ""
End Select
End Function
,
. ,
, .

8. :
Public Function GetPerfEval() As String
Select Case EmpID
Case Is = 1
GetPerfEval = " !"
Case Is = 2
GetPerfEval = " "
Case Is = 3

GetPerfEval = ""
Case Else
GetPerfEval = ""
End Select
End Function
9. .
:
Private Sub Class_Initialize()
Manager = False
Dept = 1
EmpID = 0
EmpName = ""
EmpDept = 0
EmpPerformance = ""
Reason = ""
End Sub
, . : Manager,
Dept, EmpID, EmpName, EmpDept, EmpPerformance Reason.
Manager , . Dept ,
. EmpID , .
, EmpName . EmpDept ,
. EmpPerformance . ,
, Reason .
HR . Get Record
() . .
, .
HR.

1. Form1. Name frmHR, Caption


.
2. .
Name:
Text:
lblDept

lblManager
?
lblEmpID

3. lblDept.
.
Name:
Style:
cboDept
2 - Dropdown List
4. .
Name:
Caption:
Value:
optYes
&
True
optNo
&
5. .
.
Name:
Text:
txtEmpID
6. , .
Name:
Caption:
cmdGetPE
&

, . 15.4.

. 15.4.

7. (General) (Declarations):
Option Explicit
Private hr As clsHR
8. Form_Load():
Private Sub Form_Load()
' HR
Set hr = New clsHR
'
cboDept.Addltem "1"
cboDept.Addltem "2"
End Sub
. New
clsHR. , .
9. Form_Unload() :
Private Sub Form_Unload(Cancel As Integer)
Set hr = Nothing
End Sub
, .
Nothing, 9.
.

10. , cmdGetPE:
Private Sub cmdGetPE_Click()
Dim rc As Boolean
Dim msg As String
hr.Dept = Val(cboDept.Text)
hr.Manager = optYes.Value
hr.EmpID = Val(txtEmpID.Text)
If hr.GetRecord = True Then
msg = " : " & _
Trim$(Str$(hr.EmpID)) & vbCrLf
msg = msg & " : " & _
Trim$(Str$(hr.EmpName)) & vbCrLf
msg = msg & ":
&
hr.EmpPerformance
MsgBox msg
Else
msg = "He !" & vbCrLf
msg = msg & hr.Reason
End If

End Sub
. 1 3.
, , .
. ,
, (. 15.5).

. 15.5. HR

, ,
:
1. , ( ),
[] .
2. , ,
Public Event. (General)(Declarations) clsHR:
Public Event ShowEval(Eval As String)
: ,
() . Visual Basic RaiseEvent.
3. ,
. (General) (Declarations) clsHR:
Public EmpErformance As String
4. (Class)(Initialize) :
EmpPerformance=""
5. GetRecord() .
:
Private Function GetRecord() As Boolean
Dim EmpPerformance As String
If Manager = True Then
If Dept = GetDeptO Then
EmpName = GetEmpName()
EmpPerformance = GetPerfEval()
Reason = ""
GetRecord = True
Else
Reason = " " _
& " "
GetRecord = False
End If
Else
Reason = " _
" "
GetRecord = False
End If

RaiseEvent ShowEval(EmpPerformance)
End Function
6. frmHR.
7. (General)(Declarations) :
Private WithEvents hr As clsHR
WithEvents Visual Basic , ,
.
8. (hr) (ShowEval).
:
Private Sub hr_ShowEval(eval As String)
Dim msg As String
If eval <> "' Then
msg = " : " & _
Trim$(Str$(hr.EmpID)) & vbCrLf
msg = msg & " : " & _
Trim$(Str$(hr.EmpName)) & vbCrLf
msg = msg & ": " & _
hr.EmpPerformance
Else
msg = "He !"
End If
MsgBox msg
End Sub
. ,
.
, , .
, ! .
,
Public Event _ () (General)(Declarations) .
RaiseEvent. ,
WithEvents.

Visual Basic.
, . ,
. ,
, .

, , ,
Visual Basic, .
, .
Visual Basic (. 15.6)
, . ,
View > Object Browser, F2 Object Browser .
, , ,
. .
Classes,
(, ). .
, .
Project/ Library,
Search .
, Project/Library.

. 15.6.
, , ,
Search Search. Search ,
(. 15.7).

. 15.7.

, ,
.
.
, .
?
:

.
, .
Visual Basic.

16
IDE


IDE


, (IDE) Visual Basic
, . Visual Basic
(), IDE
.
, (add-ins), .
IDE ,
. IDE !
,
Visual Basic. ,
IDE. ,
.
IDE

, IDE
Visual Basic.
,
,
(, Microsoft Visual SourceSafe).
, .
: (Add-In Manager) Visual Basic (VB6 Add-In
Toolbar).

IDE Visual Basic


(. 16.1). Add-ins > Add-In Manager
Visual Basic. . ,
Visual Basic. Visual Basic.
, .
, .
. ,
Visual Basic. ,
, . ,
.
, .

. 16.1.
.
VB6. , :
1. VB6 Add-In Toolbar.

2. , Loaded/Unloaded Load on Startup .


3. .
VB6

VB6 (. 16.2) IDE.

. 16.2.
Add/Remove +/-.
Add/Remove Toolbar Items, (. 16.3). ,
, ,
.
. Browse ,
Visual Basic, Delete .
. , ,

Visual Basic.
. 16.3. Add/Remove Toolbar Items
, ,
:
1. Add/Remove, Add/Remove Toolbar Items.
2. VB6 Application Wizard ( ).
3. VB6 Data Form Wizard.
4. .
. 16.4, : Add/Remove, VB6
Application Wizard VB6 Data Form Wizard.

. 16.4.

IDE . ,
.
VB6 Application Wizard
VB6 Application Wizard , Visual Basic.
- Microsoft
( !) . ,
, ,
Windows:
1. , Visual Basic. File > Remove
Project .
2.
VB6 Application Wizard .
- (. 16.5).

. 16.5. VB6 Application Wizard


3. , .
, None
Next, .
(. 16.6) : Multiple
Document Interface (MDI) ( ),

. 16.6. Single Document Interface (SDI) ( )


Explorer Style ( ).
4. Explorer Style Explorer ,
. , Next.
(. 16.7) .
,
.

. 16.7.
5. File Find.
6.
[Separator],
.
7. Send To.
8. [Separator].

, ,
+ . ,
###### i###########.

9. Next, .
, . 16.8, ,
.
. 16.8.
10. (, Back Forward) -
##########<-.
11. Next, .
12. (. 16.9) .
Next.

. 16.9.
13. Web- ,
Yes (. 16.10). ;
Next.

, Application Wizard
, About
(. 16.11).
14. Splash Screen About Box,
About.
15. Next.
. 16.10. Web-?

. 16.11.
16. (. 16.12).
Next, .

. 16.12. !
- , Application Wizard !
, , (...)
.
17. , . 16.13, Finish.

. 16.13.
. ,
,
!

18. , , .
19. Help > About.
. 16.14.

. 16.14. About Explorer


, Application Wizard . ,
, .
, . .
VB6 Data Form Wizard
, , Data Form Wizard.
, ,
. Data Form Wizard
. Wizard ,
.
1. File > New. New Project
Standard EXE .
2. , Form1
Remove Form1 .
3. Name DataBrowser.
4. Data Form Wizard .
, . 16.15.

. 16.15. Data Form Wizard


5. Application Wizard, ,
. , Next .
6. (. 16.16) , .
Access (, Microsoft SQL Server).

. 16.16. 7. Access Next. 8. ,


. 16.17, . Browse,
.
9. Biblio.mdb \Program Files\Microsoft Visual Studio\VB98.
Open.
10. Next, .
(. 16.18) Name .
: , ,
/ , Microsoft FlexGrid Microsoft Chart.

11. frmBrowser
Grid(Datasheet).
12. Binding Type ADO Code. Data Form Wizard
Visual Basic ADO. ,

Next.
, . 16.19, , .

. 16.17.

. 16.18.
. 16.19.
13. Titles Record Source.
14. Available Fields,
( ). .
15. Column to Sort By Title. , Next.
16. (. 16.20) .
,
, .

17. Next.
18. Data Form Wizard (. 16.21)
, .
Finish. .

. 16.20.
19. frmBrowser .

DataBrowser Properties .

. 16.21. !
20. . frmBrowser
Startup Object .
21. .
, . 16.22.
, Microsoft Access ,
. Edit
, ,
Update . ,
Visual Data Manager (. 8). ,
! ,
IDE Visual Basic . ,
, Visual Basic,
. ,
. , IDE.

. 16.22.

, . , .
12, , .
, , , , .
. ,
. ,
. , ,
IDE, .
, , , CodeDoc
( Code Documentation utilities - ).

AppSpecs.bas. ,
, !

. ,
, .bas.
,
. .
,
. ,

, . .

, , CodeDoc App.
. , ,
, . , Visual Basic. .
, , .
1. File > New Project.
2. Add-In (. 16.23) , .
3. Name CodeDocApp.
4. Designers Connect.
-, . 16.24.
5. Add-In Display Name CodeDoc - App.
.
6. Add-In Description CodeDoc -
. .
7. Application Visual Basic, Application Version - Visual
Basic 6.0.
8. Initial Load Behavior Startup. , Addin
is Command -Line Safe .
.
. 16.23. Add-In

. 16.24.
9. Connect
View Code .
10. AddinInstance_OnConnection
Set mcbMenuCommandBar = AdToAddInCommandBar("My Addln")

Set mcbMenuCommandBar = AdToAddInCommandBar("CodeDoc - App")

11. AddToAddInCommandBar()
:
Function
AddToAddInCommandBar(sCaption
As
String)
As
Office.CommanBarControl Dim cbMenuCommandBar As Office.CommandBarControl
Dim cmd As Office.CommandBarButton Dim cbMenu As Object
, On Error Goto
AddToAddlnCommandBarErr
,

Edit
If
cbMenu
=
VBInstance.CommandBars("Edit") If cbMenu Is Nothing Then
, Exit Function End If

Set
cbMenuCommadBar
=
cbMenu.Controls.Add(1, , , 11)
... Set cmd = cbMenuCommandBar

Clipboard.SetData
frmAddln.picButton.Picture
cmd.PasteFace
cmd.ToolTiptext = "
" Set cmd = Nothing

Set
AddToAddlnCommandBar
=
cbMenuCommandBar
AddToAddlnCommandBarErr:
End Function
12. .
13. Connect.
14. frmAddln, .
15. . Name
IblDescription, Caption ...
16. ,
. ,
Cancel.
17. . Name fraOptions, Caption
&.
18. ,
.
19. ,
.
20. . Name chkProject Summary,
Caption &.
21. . Name chkComponents,
Caption &.
22. . Name chkReferences,
Caption &.
23. . Name
picButton, Visible False.
,
. Control Icon
Picture, PasteFace, .
Visual Basic

Clipboard. /.

, Visual Basic,
Paint.
, CodeDocApp.bmp Web-
(www.piter-press.ru).
24. Picture .
25. . ,
\Program Files\Microsoft Visual Studio\ Common\Graphics\Bitmaps\Tlbr_Win95.
26. .
27. . 16.25. . 16.25.

28. Name cmdOK.


29. Name Cancel cmdCancel.
30. cmdOK, .
31. cmdOK_Click:
Private Sub cmdOK_Click()

AddModule
DocumentApp
' Connect.Hide End Sub
32. Load :
Private Sub Form_Load() Dim msg As String
msg = "CodeDoc-App " &
" " & "
" & _ " ."
lblDescription.Caption = msg End Sub
33. DocumentApp():
Public Sub DocumentAppO Dim X As String
Dim msg As String

If chkProjectSummary.Value = 1 Then
X = ListSummaryO End If
If chkComponents.Value = 1 Then
' ,
X = X & ListComponentsO End If
If chkReferences.Value = 1 Then
' ,
X = X & ListReferencesO End If
'

VBInstance.ActiveCodePane.CodeModule
.InsertLines 1, X & .....
End With

With

' msg = " !" MsgBox msg,


vblnformation, "!" End Sub

, .
, ,
. , ,
IDE:
1. (General)(Declarations) :
Private Sub AddModuleO Dim ndx As Integer Dim i As Integer
With VBInstance.ActiveVBProject ' ? For i = 1 To .VBComponents.Count
, If .VBComponents(i).Name = "AppSpecs" Then
.VBComponents(i).Activate

Exit Sub End If Next

'
.VBComponents.Add vbext_ct_StdModule
ndx = .VBComponents.Count
'
.VBComponents(ndx).Name = "AppSpecs" End With End Sub
2. , ,
, :
Public Function ListComponentsO As String Dim i As Integer Dim X
As String
With VBInstance
' X = " " & vbCrLf & '"
: " & _ vbCrLf
If .ActiveVBProject.VBComponents.Count > 0 Then
For i = 1 To _
.ActiveVBProject.VBComponents.Count
X = X & ..... & vbTab & _
.ActiveVBProject.VBComponents(i).
Name & vbCrLf Next Else

X = X & ..... & vbTab & "."
End If End With
ListComponents = X End Function
,
. ,
. AppSpecs
, .

3. (General)(Declarations) :
Public Function ListReferencesO As String Dim i As Integer Dim X As String
With VBInstance
X = ..... & vbCrLf & "' : " & vbCrLf
If .ActiveVBProject.VBReferences.Count > 0 Then ' For i = 1 To
.ActiveVBProject.References. Count
X = X & ..... & vbTab & _

.ActiveVBProject.References(i).
Description & vbCrLf Next Else

X = X & ..... & vbTab & "."
End If End With
ListComponents = X End Function
4.
, (General)(Declarations)
:
Public Function LtstSummary() As String Dim X As String
' X = ..... & vbCrLf & _
" : "
& vbTab & vbCrLf &
" : " & vbTab &
vbCrLf & _
" : " & vbTab & vbCrLf &
" Copyright: " & vbTab
& vbCrLf &

' : " &


vbTab & vbCrLf &
" : " & vbTab
& vbCrLf
ListSummary = X End Function
5.
. ,
Visual Basic,
VB.INI. ,
VB6.
1. File > Make CodeDocApp.dll
, , Edit
. CodeDoc Edit.
2. Edit , View > Toolbars > Edit.
3. Add-Ins > Add-In Manager.
4. , CodeDoc - App
Loaded/Unloaded (. 16.26). :
Description.

. 16.26.
5. , .
6. , Edit (. 16.27).

. 16.27. Edit
7.
.
.
Visual Basic .
. 16.28.

. 16.28. AppSpecs
, CodeDoc
.
, .

,
.

CodeDoc - Module. ,
.
!
1. File > New Project.
2. Add-In , .
3. Name CodeDocModule.
4. Designers Connect.
5. Add-In Display Name CodeDoc - Module.
.
6. Add-In Description CodeDoc -
. .
7. Application Visual Basic, Application Version - Visual
Basic 6.0. 8. Initial Load Behavior Startup. , Addin is
Command-Line Safe .
.
9. Connect
View Code .
10.
(General)(Declarations) Dim mfrmAddln As New
frmAddln

11. AddinInstance_OnDisconnection :
Unload mfrmAddln
Set mfrmAddln = Nothing

12. Addinlnstance.OnConnection
Set mcbMenuCommandBar = AdToAddInCommandBar("My Addin")

Set mcbMenuCommandBar = AdToAddInCommandBar("CodeDoc - Module")


13. AddToAddlnCommandBar
:
Function
AddToAddInCommandBar(sCaption
As
String)
As
Office.CommanBarControl
Dim
cbMenuCommandBar
As
Office.CommandBarControl Dim cmd As Office.CommandBarButton Dim
cbMenu As Object
, On Error
Goto AddToAddlnCommandBarErr
,

Edit
If
cbMenu
=
VBInstance.CommandBars("Edit") If cbMenu Is Nothing Then
, Exit Function End
If

Set
cbMenuCommadBar
=
cbMenu.Controls.Add(1, , , 11)
... Set cmd = cbMenuCommandBar

Clipboard.SetData
frmAddln.picButton.Picture
cmd.PasteFace

cmd.ToolTiptext
=
" " Set cmd = Nothing
'
Set AddToAddlnCommandBar = cbMenuCommandBar
AddToAddlnCommandBarErr:
End Function
14. .
15. Show :
Sub Show()

Dim filename As String Dim x As String


'
filename = VBInstance.SelectedVBComponent. Name
' x = ..... & vbCrLf & _

"' : " & vbTab & vbTab & vbTab & _


filename & vbCrLf & _
"' : " & vbTab & vbTab &
" " & vbTab
"' : " & vbTab & vbTab & _
Format$(Date$, "mm-dd-yyyy") & _
vbCrLf & " ' : " & _
vbCrLf & ..... & vbTab & vbTab & _
vbTab & vbTab & " " & _
" " & _
vbCrLf & '" : " &
vbCrLf & ..... & vbTab & vbTab & _
vbTab & vbTab & "" & _
vbCrLf & .....
' With
VBInstance.ActiveCodePane
.CodeModule.InsertLines 1, x End With End Sub 16.
Hide.
17. frmAddin .
18. Cancel.
19. . Name picButton,
Visible False.
, Visual Basic,
Paint.
, CodeDoc App.bmp Web-
(www.piter-press.ru).

20. Picture .
21. . ,
\Program Files\Microsoft Visual Studio\ Common\Graphics\Bitmaps\Tlbr_Win95.
22. .
IDE ,
.
, . 18.29

. 16.29. Edit
:
1. , .
Connect.
2. CodeDoc - Module Edit.
3. .
. 16.30.
, . , . ,
. . 16.31 , .
!
.
. 16.30.
. 16.31.

. CodeDoc .
1. File > New Project.
2. Add-In , .
3. Name CodeDocProc.
4. Designers Connect.

5. Add-In Display Name CodeDoc - .


.
6. Add-In Description CodeDoc -
. .
7. Application Visual Basic, Application Version - Visual
Basic 6.0.
8. Initial Load Behavior Startup. , Addin is
Command-Line Safe .
.
9. Connect
View Code .
10. (General)(Declarations)
Dim mfrmAddln As New frmAddln

11. AddinInstance_OnConnection
Set mcbMenuCommandBar = AdToAddInCommandBar("My AddIn")

Set mcbMenuCommandBar = AdToAddInCommandBar("CodeDoc - Proc")


12. AddinInstance_OnDisconnection
:
Unload mfrmAddIn
Set mfrmAddIn = Nothing
13. AddToAddInCommandBar
:
Function
AddToAddInCommandBar(sCaption
As
String)
As
Office.CommanBarControl
Dim
cbMenuCommandBar
As
Office.CommandBarControl Dim cmd As Office.CommandBarButton Dim
cbMenu As Object
, On Error
Goto AddToAddInCommandBarErr
,

Edit
If
cbMenu
=
VBInstance.CommandBars("Edit") If cbMenu Is Nothing Then
, Exit Function End

If

Set cbMenuCommadBar = cbMenu.Controls.Add(1, , , 11)
' ...
Set cmd = cbMenuCommandBar

Clipboard.SetData
frmAddIn.picButton.Picture
' cmd.PasteFace
'

cmd.ToolTiptext
=
" " Set cmd = Nothing
'
Set AddToAddlnCommandBar = cbMenuCommandBar
AddToAddlnCommandBarErr:
End Function
14. .
15. Show :
Sub Show()

Dim proc
As String
Dim x As
String
Dim 1 As
String
' proc = GetProcedureName()
With VBInstance.ActiveCodePane.CodeModule '

' = ..... & vbCrLf & _
"' : " & vbTab & vbTab & _
" " & _
vbCrLf & "' : " & _
vbTab & vbTab & _
Format$(Date$, "mm-dd-yyyy") & _
vbCrLf & "' : " & _
vbCrLf & ..... & vbTab & vbTab & _
vbTab & vbTab & " " & _
" ." & vbCrLf & '" : " &vbCrlf & _

" ' " & vbTab & vbTab & vbTab &_ vbTab & " ." & _ vbCrLf & " ' "
.InsertLines 1, End With End Sub

16. Hide.
17. GerProcedureName:
Public Function GetProcedureName() As String Dim a As Long Dim b As Long Dim As Long
With VBInstance.ActiveCodePane
.GetSelection currentline, a, b,
ProcOfLine() GetProcedureName = .CodeModule. _
ProcOfLine(currentline, _ vbext_pk_Proc) End With End Function
18. frmAddIn .
19. Cancel.
20. . Name picButton,
Visible False.
, Visual Basic,
Paint.
, CodeDoc App.bmp Web-
(www.piter-press.ru).

21. Picture .
22. . ,
\Program Files\Microsoft Visual Studio\ Common\Graphics\Bitmaps\Tlbr_Win95.
23. .
IDE ,
.
, . 16.32.

. 16.32. Edit
:
1. , .
Connect.
2. , ,
.

GetProcedureName().
3. CodeDoc - Edit.
4. .
. 16.33.
. 16.33

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

0 .
0 IDE.
0 Add-In.
0 CodeDoc
.
17
ActiveX
Active:
ActiveX
ActiveX Visual Basic
ActiveX Microsoft Word ActiveX o

, (). ActiveX

.
ActiveX COM (Component Object Model,
). ,
,
.
, ,
! ActiveX
, .

ActiveX .
, , ! ,
.
Active

: Microsoft Active ,
-
Internet. , Remote Automation, ActiveX
(ActiveX Documents), ActiveX (ActiveX Controls), ActiveMovie, Active Desktop,
HTML (DHTML), VBScript ( Microsoft Visual Basic) Active Server Pages (ASP).
, Microsoft Active.
ActiveX ,
, . , ActiveX
,
- .
,
ActiveX. ,
.
.
ActiveX,
ActiveX,
. . 17.1, ActiveX
Visual Basic Internet Explorer ( ,
ActiveX ).
. 17.1. ActiveX
ActiveX

ActiveX :
.
Visual Basic ActiveX,
Internet Explorer.
ActiveX
. , ,
,
.
, .
ActiveX

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

;
ActiveX
;

,
;
ActiveX , .
. -,
.
. , ,
, . -,
. ActiveX Web ,
. , . ,
. , -
, ( )
. , ,
. , Internet
Explorer . ,
.
-, .
, . ,
Web-. Web-
HTML .
,
.
Visual Basic. ,
IDE.
, .
, ActiveX ,
. , ,
. , Web-,
.
Web-

Web , Web-
, (HTML).
, Web-.
, (),
Web-, ,
. , Web-
, . ,
, .
. Web- ,
. , Web- .
, .
.
,
. ,
, HTML-, .
, , .
. ,
. , ActiveX
. ,
.
.
ActiveX

, ActiveX - Microsoft.
, ActiveX Visual Basic.
ActiveX Visual Basic, Web-
Microsoft (, Word Excel). Visual Basic
Project Wizard ,
ActiveX (. 17.2). ActiveX EXE, ActiveX DLL, ActiveX Control, ActiveX Document
DLL ActiveX Document EXE. ActiveX Visual Basic.
.

ActiveX, , IDE
. ActiveX , Visual
Basic

Web-
(

Internet
Explorer).

. 17.2. ActiveX
ActiveX

ActiveX Visual Basic


. ActiveX Visual Basic,
Microsoft Internet Explorer 4 ( ).
ActiveX ,
. . ActiveX
Web- - . ,
ActiveX Web- .
ActiveX , a ActiveX DLL .
ActiveX, . 17.1, :
1. File > New Project. Project Wizard
ActiveX Document EXE.
2. Name UserDocument1 docMain.
3. docMain.
.
, 5 .
4. docMain
. , ,
.
5. . ,
,
docMain.
6.
Name
picGraphic.
7. picGraphic . ,
.
, .
. 17.3.

. 17.3. ActiveX
8. , .
9. Change Drivel:
Private Sub Drive1_Change()
' Dir1.Path = Drivel. Drive End Sub

10. Change Dir1:


Private Sub Dir1_Change()
File1.Path = Dir1.Drive End Sub

11. Click File1:


Private Sub File1_Click()
picGraphic.Picture = LoadPicture(Dir1.Path &
"\" & Filel.filename) End Sub

ActiveX Initialize.
, .
12. BMP.
Initialize UserDocument (docMain):
Private Sub UserDocument_Initialize()
BMP Filel.Pattern = "*.bmp" End Sub

13. Resize User Document:


Private Sub UserDocument_Resize()
Filel.Height = (ScaleHeight - Filel.Top)
picGraphic.Height = ScaleHeight picGraphic.Width = (ScaleWidth picGraphic.Left) End Sub

,
.
. Resize ,
. ,
.
14. Run > Start F5.
15. Debugging Project Properties.
: Start Component docMain. .
Internet Explorer .
Visual Basic Internet Explorer .
ActiveX .
BMP . , :
1.
, \Common\Graphics\
Bitmaps\Assorted.
2.
(. 17.4).
. 17.4.

ActiveX .
.
ActiveX . ActiveX .

ActiveX
Visual Basic ( ActiveX document).
ActiveX

ActiveX ,
. Visual
Basic, ActiveX, Microsoft Excel. ActiveX
Web- HTML .
Project Wizard ActiveX Control (. 17.5).
8. ( , )
(. 17.6).

. 17.5. ActiveX
,
. , ,
:
1. ActiveX Control.
2. Name ActiveXButton.
3. Name User Control ctlExit.
4.
.
.
5. Name cmdExit, Caption E&xit.
6. Style 1 - Graphical.
7.
, Picture
MsgBox01.ico \Common\Graphics\Icons\Computer.
. 17.6.

, .

ActiveX Control Interface Wizard:


1. Add-Ins > Add-In Manager.... ,
Components .
16, IDE
.

2. VB6 ActiveX Ctrl Interface Wizard, Loaded/ Unloaded Load


on Startup (. 17.7) . IDE.

. 17.7. Control Interface Wizard IDE


3. Add-Ins > ActiveX Control Interface Wizard.
4. (. 17.8),
Next.

. 17.8. ActiveX Control Interf Wizard


, ,
. ,
, . ,
.
5. Selected Names, , .
17.9. Caption, Enabled Font, Click.
Caption Available Names. ,
Next.
6. .
, Next.

. 17.9.
7.
. Caption Exit, Control
cmdExit. Member Caption (. 17.10).
8. Click Click Exit.
9. Enabled Enabled Exit
10. Font Font Exit.
, (.
17.11). , .
, .
.
11. Finish.

12. .
. 17.10.

. 17.11.
ActiveX. ,
,
ActiveX.
OCX-
IDE. , ,
. ,
.
Web. ActiveX
Web- 18, Visual Basic.
ActiveX DLL
DLL- ActiveX ( ActiveX DLL)
, OCX.
. DLL
Visual Basic. 10 ActiveX
DLL .
.
Word 97. ,
. ActiveX DLL, :
1. .
2. Project Wizard ActiveX DLL (. 17.12).
. 17.12. ActiveX DLL
3.
Name Word Helpers.
Microsoft Word 97.
4. Name Class1 Counters ( -
Word).

5. Project > References Visual Basic.


Microsoft Word 8.0 Object Library .
6. Counters , .
7. ,
Word:
Public Function LineCount(CharactersPerLine As Integer) As Long Dim x As Word.Application Dim cc As
'
Set x = Word.Application
With x.ActiveDocument
c = .Characters.Count End With
Set x = Nothing
, '
(CharactersPerLine) LineCount = Int(cc / CharactersPerLine) End
Function
Long

8.
,
:
Public Function PageCount() As Integer Dim x As Word.Application
, Set x = Word.Application
With x.ActiveDocument
PageCount = .BuiltInDocumentProperties("Number " &
"of Pages") End With

Set x = Nothing End Function

9. , .
10. ActiveX DLL Make WordHelpers.dll (. 17.13).
DLL- , ,
References Visual Basic Word.
, .

. 17.13. DLL
. Word
.
Word 97 Visual Basic for Applications (VBA).
VBA Office.
1. Microsoft Word 97. 2. Visual Basic > >
Visual Basic1 Alt+F11. Visual Basic for Applications ,
(. 17.14).

. 17.14. Visual Basic Word 97


3.
Normal
Insert > Module .
4. Name Utilities.
5. , Visual Basic 6, WordHelpers.
> 2.
6. WordHelpers .
Visual Basic Word IDE Visual Basic 6,

. , References ()
Tools (), Project.
1
2

Tools > Macros > Visual Basic Editor . . .


Tools > References . . .

7. , :
Public Sub LineCount()
Dim wh As WordHelpers.Counters
Set wh = New WordHelpers.Counters
MsgBox Str$(wh.LineCount(65)), vblnformation,
":"
Set wh = Nothing End Sub

8. :
Public Sub PageCountO
Dim wh As WordHelpers.Counters
Set wh = New WordHelpers.Counters
MsgBox Str$(wh.PageCount), vblnformation, ":" Set wh = Nothing End Sub

9. Normal.dot ( > Normal1). 10.


Visual Basic Word 97.
Microsoft Word 97. ,
Visual Basic. , (LineCount Page Count),
Word 97 . ,
Word. , , :
1. Microsoft Word 97, .
2. Word .
3.
Alt+F8.
(. 17.15).
4. LineCount 2.
.
ActiveX Microsoft Word

, ActiveX DLL-, Word 97.


, Word Visual
1

File > Save Normal . . . - Run . . .

. 17.15.
Basic. . Microsoft
Office, Visual Basic ActiveX
Office.
Excel Microsoft Word
.
Office ,
, Microsoft.
Word ,
Word. , VBA
Word. , Visual Basic
Microsoft Word 97. Word 97,
. , !
1. Ctrl+N.
2. Standard EXE New Project. ,
.

3. Name ActiveXAutomation.
4. Form1, . Name
frmMain, Caption ActiveX Automation.
5. frmMain.
6. Microsoft Word,
. Visual Basic Project > References.
7. References Microsoft Word 8.0 Object
Library (. 17.16) .
. 17.16. Word
8. cmdCreate .
9. Click cmdCreate:
Private Sub cmd_Create_Click() Dim x As Word.Document Dim i As Integer
10 For i = 1 To 10
Word Set x = New Word.Document
' With x.ActiveWindow.Selection
.TypeText " " & _ " Visual Basic 6.0 "
.TypeText " Office."
.TypeParagraph
.TypeParagraph
.TypeText " " & Trim$(Str$(i)) &

" 10." .TypeParagraph .TypeParagraph


.TypeText " !" End With
' With x
.SaveAs "c:\Visual Basic " & _ Trim$(Str$(i)) & " !"
.Close End With
, Set x = Nothing Next End Sub

10. .
Create, , Microsoft Word .
Word.
, (. 17.17).
, : 10 !
.
Click, Word. Document. ,
Word OLE. Word. Document
.TypeText . ,
.SaveAs .Close. Word. Document
, .
For...Next, 10 , 10 .
ActiveX .
Office 97 ( Word 97),
. ,
!
Visual Basic DLL
. . 15,
- (),

.
, , , .

. 17.17. Word
ActiveX ,
Visual Basic , Web.
ActiveX ,
Visual Basic HTML-. ,
World Wide Web ActiveX , ,
. ?
:

0 ActiveX. 0 ActiveX. 0 ActiveX DLL.


0 Microsoft Office.
0 Office , Visual Basic.
18
Visual Basic
WebBrowser Winsock
ActiveX DHTML Visual Basic ,

-. ,
HTML- ( ), ActiveX ActiveX,
.
-
- WebComm. Web, , DHTML. , ,
WebComm, ActiveX, Visual Basic.
WebComm WinSock
-.
. Visual
Basic -!
WebBrowser

, WebBrowser ,
Visual Basic, Web-. Web-,
? Microsoft HTML.
Microsoft Internet Explorer 4.01 ,
. , WebBrowser (.
18.1).
, WebBrowser
. ,
, , ?
: Web-, ActiveX

, . , .
1. Ctrl+N. New Project
Standard EXE .
2. Name WebIndex.
3.
Name Form1 frmMain, Caption
WebIndex.
4. Components
. Components, . 18.2.
5.
Microsoft Internet Controls,
WebBrowser .
6. Microsoft Windows Common Controls 6.0 Microsoft
Windows Common Controls-3 6.0.
. 18.1. HTML
WebBrowser

. 18.2. Components

7. Components .
.
8. (CoolBar) frmMain
Name cbrCoolbar.
9. cbrCoolbar . ,
cbrCoolbar, .
10. Name tbrToolbar.
11. .

Name lstSites.
12. WebBrowser , .
Name WebBrowser.
13. , Name imlToolbar.
14. , .
. 18.3.

. 18.3. WebIndex
15. ImageList, (Custom) .
.
16. Images.
17. Insert Image, .
18.
Select Picture Undo.bmp
\Common\graphics\Bitmaps\Tlbr_Win95 Open,
.
19. Insert Image, .
Redo.bmp .
20. Insert Image. Find.bmp .
. . 18.4.

. 18.4.
21. .
22. tbrToolbar , .
(Custom)
.
23. General Image List imlToolbar, Style 1 tbrFlat. , Buttons.

.
.

24. Insert Button, .


Key Back, Image 1.
Apply.
25. Insert Button . Key
Forward, Image 2.
26. Insert Button .
Style 3 - tbrSeparator.
27. . Key Search, Image - 3.
.
28. . ,
(Custom) .
29. Bands.
30. Remove Band , Index 1.
.
31. Child tbrToolbar . ,
. 18.5.

. 18.5. WebIndex
.
:
1. frmMain .
2. Load frmMain:
Private Sub Form_Load()
lstSites.Adltem "www.piter-press.ru"
IstSites.Adltem "www.microsoft.com"
IstSites.Adltem "www.myle.com" End Sub

3. Form_Resize:
Private Sub Form_Resize()
If WindowState <> vbMinimized Then
cbrCoolbar.Move 0, 0, ScaleWidth
With IstSites
.Move 0, cbrCoolbar.Height, .Width,
(ScaleHeight - cbrCoolbar.Height) End With
WebBrowser With webBrowser
.Move .Left, cbrCoolbar.Height, (ScaleWidth - .Left), (ScaleHeight - cbrCoolbar.Height) End With End If End
Sub

WebBrowser Web- Navigate,


Internet Explorer URL
WebBrowser.
4. ,
Click IstSites:
Private Sub lstSites_Click()
webBrowser.Navigate = Trim$(lstSites.Text) End Sub

5. .
ButtonClick tbrToolbar:
Private Sub trToolbar_ButtonClick(ByVal Button As ComctlLib.Button) ' On
Error Resume Next

' ? Select Case UCase$(Trim$(Button.Key)) Case Is = "BACK"


webBrowser.GoBack Case Is = "FORWARD"
webBrowser.GoForward Case Is = "SEARCH"
webBrowser.GoSearch End Select End Sub 6. ,

. F5.
www.piter-press.ru (.
18.6). , WebBrowser
. , HTML-
, Internet Explorer!
. 18.6. Web- WebBrowser
Web ,
Back . ,
Web- Microsoft . ,
Visual Basic.
, . -,
Form_Load.
Add Item.
Click lstSites ButtonClick
tbrToolbar. ,
URL WebBrowser Navigate. ,
ButtonClick .
GoBack .
Back Web.
, Go Forward URL.
, GoSearch ,
Internet Explorer.
, Web-.
Winsock,
.
Winsock

Winsock TCP (Transmission Control Protocol) UDP (User


Datagram Protocol).
. TCP ,
UDP .
(session) ,
. .
, -
- ( ,
). - ( ) ,
. , ,
. , (
).
UDP .
. ,
. UDP IP-
. , .
TCP -,
WebComm.
, . ,
,
TCP/IP.
-, Winsock.
WebComm;

1. File > New Project. New Project


Standard EXE .
2. Name WebCommServer.
3. Name Form1 frmMain, Caption
WebComm.
4.
Icon . W95mbx04.bmp
\Common\Graphics\Icons\Computer. Open, .
5. Tools > Menu Editor.
6. . Name mnuFile, Caption
&File.
7. mnuFile mnuFileExit. Caption E&xit.
8. .
9. lstMessages.
10. , Name tmrTimer, a Interval
1000.
11. Components
.
12. Microsoft Windows Common Controls 6.0 Microsoft Winsock
Control 6.0. . .
13. Winsock. Name wsk,
Index 0. .
, .
14. frmMain . Name stsStatus
, Align 2 -vbAlignBottom.
15. (Custom) ,
.
16. Panels.
17. Text : 0.
18. Insert Panels, .
, Index 2 .
19. Bevel 0 - sbrNobevel, AutoSize 1 - sbrSpring.
20. Insert Panel. , Index
3 ( ). Style 6 - sbrDate.
21. Index 4 ( ).
Style 5 - sbrTime.
22. .
. 18.7.

. 18.7. WebComm
23. , .
.
:
1. frmMain, .
2. (General)(Declarations) :
Option Explicit
Private Const WSK_LOCAL_PORT = 12345 Private Const MAX_SESSIONS = 11
, 12345.
WebComm, .
11. 1
, , -
.
WebComm 10 Winsock
.
3. , - (,
), . UpdateStatus.
(General) (Declarations) frmMain:
Private Sub UpdateStatusO Dim i As Integer Dim actsess As Integer

' For i = 1 MAX_SESSIONS


With wsk(i)
If .State = sckConnected Then
actsess = actsess + 1 End If End With Next
' With stsStatus
.Panels(1),Text = ": " & _
Trim$(Str$(actsess)) End With End Sub

UpdateStatus Winsock .
, - actsess.
actsess .
4. Winsock
. Form_Load:
Private Sub Form_Load() Dim i As Integer
' Winsock With wsk(0)
.Protocol = sckTCPProtocol
.LocalPort = .WSK_LOCAL_PORT
.Listen End With
' 10 Winsock For i = 1 To MAX.SESSIONS
Load wsk(i)
wsk(i).Protocol = sckTCPProtocol
wsk(i).LocalPort = WSK_LOCAL_PORT Next
UpdateStatus End Sub
5. Form_Resize:
Private Sub Form_Resize()
If WindowState <> vbMinimized Then IstMessages.Move 0, 0,
ScaleWidth, _
(ScaleHeight - stsStatus.Height) End If End Sub
6. Click mnuFileExit:
Private Sub mnuFileExit_Click()
Unload Me End Sub
7. .
tmrTimer_Timer():

Private Sub tmrTimer_Timer()


UpdateStatus End Sub

WebComm Winsock.
, wsk.
, Winsock, ConnectionRequest.
, Winsock
.
8. ConnectionRequest () wsk:
Private Sub wsk_ConnectionRequest(Index As Integer, _
ByVal requestID As Long) Dim msg As String Dim i As Integer
... If Index = 0 Then
For i = 1 MAX_SESSIONS With wsk(i)
If .State = sckClosed Then ' i .Accept requestID
Exit For End If End With Next End If End Sub
Index , .
, wsk(0) , ,
. RequestID
, .
Winsock. Winsock ,
Connect .
9. Connection() wsk.

:
Private Sub wsk_Connect(Index As Integer)
'
UpdateStatus End Sub
.
. ,
-. ,
DataArrival(), Winsock , .
GetData.
10. wsk_DataArrival:
Private Sub wsk_DataArrival(Index As Integer, _
ByVal bytesTotal As Long) Dim msg As String Dim rc As Integer Dim i As Integer
wsk(Index).GetData msg, , bytesTotal
IstMessages.AddItem msg
For i = 1 To MAX_SESSIONS With wsk(i)
If .State = sckConnected Then
.SendData msg
', DoEvents End With Next End Sub

.
wsk(Index).GetData msg, , bytesTotal

, wsk(Index). GetData,
, bytesTotal, msg.
,
. , ASCII ADO. ,
( ).
11. , , Close().
.
Close:
Private Sub wsk_Close(Index As Integer)
UpdateStatus End Sub

12. .
F5 , .
, - ( File > Make
WebCommServer.exe Visual Basic). EXE- .

14.

(-)

, ,


. , .
. ,
WebComm !
ActiveX

17, ActiveX
Visual Basic . ActiveX
Visual Basic, Microsoft Internet Explorer 3 (
). ActiveX ,
, .
Web-. , ActiveX Web . ,
ActiveX Web- .
, ,
WebComm WebComm ActiveX ( -):
1. File > New Project.
2. New Project ActiveX Document EXE.
3. Name WebCommClient.
4.
WebCommServer properties .
5. Make Title WebComm.
6. .
7. Name UserDocumentl docWebComm.
8. Components
.
9. Microsoft Winsock Control 6.0.
Winsock .
10. Winsock docWebComm Name wsk.
11. - (Label) . Name
lblName, Caption :.
12. . Name txtName.
Text.

Project Properties (. ) Threading
Model General. Visual Basic 6.
, Visual Basic 5 (service pack),
6 . ActiveX
, .

Visual Basic
(apartment-model threading).
, . ,
. ,
Visual Basic .
,

Visual Basic.

13. txtName. Name


lbl, Caption - :. Enabled
False. 14. lbl. Name txtTx,
Text. , Enabled False.
15. , txtTx,
Name txtRx. Enabled False
Text.
16. Multiline txtRx True, ScrollBars - 2 - Vertical.
, . 18.8.

. 18.8. WebComm 17. .


, ,
Visual Basic. , .
:
1. , .
2. Resize :
Private Sub UserDocument_Resize()
With txtRx
.Move 0, .Top, ScaleWidth, (ScaleHeight - .Top) End Sub

3.

Terminate:

Private Sub UserDocument_Terminate()


wsk.Close End Sub

, , .
,
Name. Enter .
4. KeyPress txtName:
Private Sub txtName_KeyPress(KeyAscii As Integer)
, Enter If (KeyAscii = 13) And _
(txtName.Text <> "") Then With wsk
.Protocol = sckTCPProtocol .RemoteHost = "10.0.0.1" .RemotePort = 12345 .Connect End With
lbl. Enabled = True txtTx. Enabled = True txtRx.Enabled =
True
IblName.Enabled = False txtName.Enabled = False End If End
Sub
: (txtTx) (txtRx)
, Name - .
, RemoteHost
IP- , WebComm.
RemoteHost 10.0.0.1,
TCP/IP.
- .
, . , -
. : , Name,
.
5. txtTx_KeyPress:
Private Sub txtTx_KeyPress(KeyAscii As Integer) Dim msg As String
, Enter If (KeyAscii = 13) And _
(wsk.State = sckConnected) Then
msg = "[" & _

UCase$(Trim$(txtName.Text))& _ "] - " & txtTx.Text


wsk.SendData msg
txtTx.Text = " End If End Sub

, ,
.
6. wsk_DataArrival:
Private Sub wsk_DataArrival(ByVal bytesTotal As Long) Dim msg As String
wsk.GetData msg, , bytesTotal
With txtRx
.Text = msg & _

vbCrLf & _ vbCrLf & _ .Text End With End Sub


7. !
, , , .
.
DataArrival GetData,
SendData. , ! , !
WebComm

WebComm , . ,
, ,
. , .
WebComm

WerbComm ,
; :
1. Package and Deployment Wizard (.
14).
2.
,
. , ,
.
3. , .
4.
WebComm
Windows.
5. .
WebComm

1. WebComm Windows .
2. , WebComm ,
: 0.
WebComm

WebComm, , RemoteHost
txtName_KeyPress ,
WebComm. , , RemoteHost IP . WebComm F5 Visual Basic.
ActiveX, .
Microsoft Internet Explorer. ,
, . 18.9.

. 18.9. WebComm Internet Explorer


2. Name Enter. RemoteHost
, txtTx , Name , .
WebComm !
3. - ? :.
4. Enter, . ,
(. 18.10).
, .
,
, 1. ,
Internet
Explorer. Visual Basic Run > End.
, Visual Basic ,
. Visual Basic .
WebComm , ,
, .
RichText .
, , WAV-
!

. 18.10. !
Web- (www.piter-press.ru).
WebComm .
-, , .
, ! DHTML

DHTML, Dynamic HTML ( ),


Web-. Visual Basic ,
HTML-,
IDE DHTML-. DHTML
, .
DHTML Visual Basic . Dynamic
HTML: (, 1999). , Visual Basic
DHTML, ,
.
DHTML Visual Basic
DHTML (Document Object Model),
Web-. DHTML ,
Visual Basic. DHTML - Visual Basic.
Visual Basic
Web-. Visual Basic
DHTML , .
Web- HTML, ,
HTML- DHTML.
Web- .

DHTML
, WebComm Internet Explorer. DHTML, WebComm:
1. File > New Project.
2. New Project DHTML Application ,
.
3. Name WebCommStart.
4.
DHTMLPagel ,
. . 18.11.
. 18.11. DHTML
, .
( DHTML ). ,
. , .
(, ). , ,
; .
5. ID DHTMLPage1 htmWebCommStart.
6. , WebComm! Enter.
7. WebComm! Arial, Bold, 6
, . ID
pWelcome.
8. Hyperlink ()
. .
9. Hyperlink1 !

10. ! Arial, Italic, 3.


ID pPiter.
11. Properties
Property Pages.
12. www. piter-press.ru Link. Pop-up Text -
! .
13. ID lnkPiter.
14. Button () ,
.
15. ID cmdStart, Value .
, . 18.12.
. , ,
( ID).

. 18.12.
16. , .
17.


(General)(Declarations):
LNK_WEBCOMM_CLIENT = ""

Private

Const

18. WebComm.vbd, .

cmdStart.
DHTML onLoad, Load Visual Basic.
,
.
19. onLoad Base Window:
Private Sub BaseWindow_onLoad() With Document
.bgColor = "lightyellow" .linkColor = "blue" .vlinkColor = "blue" .alinkColor = "blue" End With
' pWelcome.Style.Color = "blue" pPiter.Style.Color = "black" End Sub
, , ( -
). , DHTML Variant. , HTML
.
, Style .
DHTML , ()
Style.
20. ,
cmStart_onClick:
Private Function cmdStart_onClick() As Boolean
WebComm BaseWindow.navigate LNK_WEBCOMM_CLIENT End Function 21.
, ,
. onmouseover()
:
Private Sub lnkPiter_onmouseover()
InkPiter.Style.Color = "red" End Sub
22. , ,
. onmouseout() InkPiter:
Private Sub lnkPiter_oninouseout()
InkPiter.Style.Color = "blue" End Sub
23. .
Internet Explorer DHTML (. 18.13).
, .
, . ,
. WebComm,
.
1. Internet Explorer Run > End Visual Basic.
2. File > Make WebCommStart.dll
3. WebIndex, .
4. lstSites .
( , WebCommStart):
IstSites.Addltem "d:\piter\webcomm start page\" & _ "WebCommStart_DHTMLPage1.htm"
, , .
WebComm, WebComm.
WebCommStart, DHTML WebBrowser.
, Internet Explorer.
WebComm, WebBrowser!

. 18.13. WebComm
IIS

Internet-
IIS (IIS Application). DHTML-,
Microsoft Internet Information Server (IIS). DHTML, Web-, ASP
(Active Server Pages) (, VBScript JScript)
.
, ,
. ,
Microsoft Developer Network , ISAPI, Web- ASP.
?
:

0 - WebBrowser.
0 Winsock .
0 ActiveX -.
0 DHTML.
19
DLL Windows API


(DLL)

DLL

API Viewer


API

WavePlayer


Visual Basic

. Visual Basic
. , Microsoft ,
Windows.
Windows API ,
!
(DLL)

, Visual Basic
, , . :
(, ) Visual Basic;
OLE Automation;
, Windows API.
Windows API DLL- ,
.
Windows.

, C++

, a OLE Automation ,
Visual Basic. Windows API,
, DLL. DLL
, ,
. DLL . DLL
( , 4).
, -
. Windows .
DLL , DLL.
Open/Save, .
, ? ,
. DLL,
.
- Windows API - ,
. API
DLL, Windows.
API ,
, , . DLL
\Windows\System, Windows .
Win32, API, 32- .
, 16- .
16- API,
. API DLL
.
DLL

DLL (
). , DLL, Windows API, ,
Visual Basic. DLL, .
Visual Basic DLL,
. DLL.
Visual Basic , DLL .
Windows API , .
,
. ,
. DLL
,
DLL .
DLL , , !

Windows API , .
, . Declare,
:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal IpszSoundName
As String, ByVal uFlags As Long) As Long , ,

DLL.
API sndPlaySound, WAV-.
, .
DLL

API .
, .

API , ,
Visual Basic. Public ,
Private .
API
. , (. 4),
, .
DLL

Declare Function Visual Basic,


sndPlaySound winmm.dll Alias ,
DLL. 16- 32 API.


. (
ByVal) .
( ByRef), , ,
. C++,
API .

DLL . ,
ByVal. , ,
. , .

Alias , .
, lpszSoundName uFlags, (ByVal). lpszSoundName

.WAV. uFlags ,
. lpsz u
, C++. , (Long),
, .

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

API Viewer
DLL, ,
. Visual Basic API Viewer
(. 19.1).
,
Windows API,
, .
API Viewer :
1. Start API Text Viewer Visual Basic.
2.

API
Viewer

File
>
Load
Text

File.

. 19.1. API Viewer 3. Win32.api Open.


API Viewer API,
. , API Viewer.
, File > Convert Text to Database
(. 19.2).

4. Yes, .
5. , API Type ( )
Declares.
0 API Viewer Add-Ins Visual Basic

, . Windows
API, .
- .
6. sndPlaySound. Add,
Selected Items (. 19.3).

. 19.2.

. 19.3. sndPlaySound
7. , .
.
8. API Viewer. API
, API Viewer API .
, .
, :
1. Visual Basic. Project Wizard, -,
Standard EXE.
2. Form1 .
3. (General)(Declarations) Edit > Paste.
. 19.4.
. 19.4. API
4, Declare Private:
Private Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" (ByVal IpszSoundName
As String, _ ByVal uFlags As Long) As Long
API .
, Declare Private.
, .
5. Form_Load() Form1: Private sub
Form_Load()
Dim filename As String Dim rc As Long
filename = "c:\windows\media\tada.wav" rc = sndPlaySound(filename, 1) End Sub
filename WAV. .
, (r) (Dim rc As Long).
, API. filename flags
. flags 1.
6. , .
, Windows API.

.
, ,
-!. filename ,
. API
. ,
. (screen saver) ,
.
API
API .
, . ,
, API:
Public Sub PlayWav(filename As String, soundon As Boolean) Dim rc As long
If soundon = True Then

rc = sndPlaySound(filename, 1) End If End Sub

.
WAV-. -

, , .
, . ,
, PlayWav. , ,
( ).
WavePlayer

WAV- Windows API.


WavePlayer, .
, , .
Wave Player . :
1. File > New Project. Standard EXE.
2.
Name Form1 frmMain, Caption
WavePlayer.
3. frmMain. Name cmdPlay,
Caption &.
4. .
Add > Class Module .
5. Add Class Module Class Module
Open.
6. Name WavePlayer.
7. (General)(Declarations) WavePlayer:
Option Explicit
Private mFilename As String Private mFlags As Long
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal IpszSoundName As
String, _ ByVal uFlags As Long) As Long

8. , Filename:
Public Property Get Filename() As String
filename = mFilename End Property
Public Property Let Filename(ByVal vNewValue As String)
mFilename = vNewValue End Property

9. , Flags:
Public Property Get Flags() As Long
Flags = mFlags End Property
Public Property Let Flags(ByVal vNewValue As Long)
mFlags = vNewValue End Property

10. :
Public Sub Play() Dim rc As Long
rc = sndPlaySound(mFilename, mFlags) End Sub

11. . 4,
WavePlayer.cls , .
.
12. frmMain (General) (Declarations).
13. WavePlayer, .
:
Option Explicit

Private wav As WavePlayer

14. , .
Form_Load. :
Private Sub Form_Load()
Set wav = New WavePlayer End Sub

15. WavePlayer .
Nothing .
Form_Unload:
Private Sub Form_Unload(Cancel As Integer)
Set wav = Nothing End Sub 16. ,

cmPlay_Click. WavePlayer WAV-:


Private Sub cmdPlay_Click() With wav
.Filename = App.Path & "\Tada.wav" .Flags = 1 .Play End With End Sub
(
tada.wav) . ,
.
7. .
, ,
. , WavePlayer
. API Viewer , WAV. WavePlayer ,
!

, Windows 95 Windows NT 4, -
- , (. ).
,
. ,
, , . 3 Visual Basic ,
ActiveX. ,
.
SysTray
ActiveX , -
\System Windows. :
Systray.vbp \Cornmon\Tools\VB\Unsupprt\Systray - Visual
Basic.
Modules mSysTray,
.
(Global)(Declarations) .
API, CallWindowProc, GetWindowLong Shell_NotifyIcon (. 19.5).
.
,
, , .
. 19.5. API
3. File > Make Systray.ocx.
4. Make Project Save In \System ,
Windows. C:\Windows\System.
5. , .
SysTray .
SysTray
SysTray , .
,
Windows. :
1. File > New Project. New Project
Standard EXE.
2. Name Form1 frmMain.

3.
Components....
4. C:\Windows\System\SysTray.ocx,
SysTray . .
5. SysTray frmMain Name clsSysTray.
6. InTray True, TrayTip
.
7. frmMain, . Tools >
Menu Editor....
8. . Caption &, Name
mnuApp. Next.
9. , .
0. .
1. , . 19.6. .
2. frmMain, .
3. Load:
Private Sub Form_Load()
Me.Hide End Sub
4. MouseDown clsSysTray :
Private Sub clsSysTray_MouseDown(Button As Integer, Id As Long)
If Button = 2 Then PopupMenu mnuApp
End If End Sub
5. Click mnuAppCalc:
Private Sub mnuAppCalc_Click() Dim r As Double
. 19.6.
= Shell("calc.exe", vbNormalFocus) End Sub
16. Click mnuAppCalc:
Private Sub mnuAppExplorer_Click()
Dim As Double
r = Shell("explorer.exe", vbNormalFocus) End Sub
17. Click mnuApp Notepad:
Private Sub mnuAppNotepad_Click()
Dim r As Double
r = Shell("notepad.exe", vbNormalFocus) End Sub
18. Click mnuAppClose:
Private Sub mnuAppClose_Click()
Unload Me
Set frmMain = Nothing End Sub
19. .
.
, Caption
Name

&

mnuAppCalc
& &
mnuAppNotepad
&3
mnuAppClose

mnuAppExplorer
mnuAppSep1

. , ,
(. 19.7):

. 19.7.
, ,
ASCII- .
Visual Basic ,
.
, , ,
.
. ,
, Show MouseDblClick clsSysTray.

Windows API .
, Win32 API:
, .
WNet.
AVICap.

. , Win32 API ,
.
Visual Basic . ,
API. Visual Basic Win32 API .
, Windows API. API Viewer
API, ,
. API
. ,
.
Windows API. ,
.

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

API Viewer API.


0 API DLL.
0 API .
0 .