     . .,  . . 
    Microsoft Visual Basic 5.0: 
    ActiveX, DLL, Internet   ... 

    Microsoft Visual Basic         
  Windows. 
            ,  
    Visual Basic.    
  Visual Basic  - , 
    Visual Basic,    
 ,      
 .        
   :       Data   
 D.       D  
   . 
              
(   ""),       
 .       
.     ,  
 ,         
.   , :       
 (DLL);     ( 
 );   AciiyeX   , 
   ;   Visual Basic  
      Internet   ; 
       . 

       .  
       .  
     .  
    ISBN 5-85954-072-8	 "" 1998 
      . .,  . . 


      3

     

    Microsoft Visual Basic        
   Windows.  Visual Basic    
      
       () 
 ,    ,     
 .    ,  
,   -      
  Visual Basic           
.    Visual Basic      . 
       Microsoft Corporation      
 .  :   
     Windows!   
           
 Visual Basic ,   Microsoft,   , 
            
,     ,   
  . 
    Visual Basic  5.0     
,          
, ,     -  ( 
   Standard  Learning),   ""   
( Professional  Enterprise). , ,    
 Application Wizard      ,  
          
 Visual Basic.      Visual Basic  
:      ActiveX,    
  ,    Internet, , , 
     Windows. 
            ,  
    Visual Basic.    
  Visual Basic  - , 
    Visual Basic,    
        
 .        
   ,        
 ,        
. 
      6-  12-    .  
  "" ,   : 
       (DLL);   
   (  );  
    ActiveX   , 
   ;    Visual 
Basic        Internet   
;        
  Visual Basic. 

4  - 

     1.     Visual Basic 

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

    1.1. -  

     ,  ,    
!     .  
          
;       . 
    Visual Basic      BASIC.  
, ,   -  .  
- npk      . 
          . 
   ;  ,     
     .    
   . ,    
     . 
      -    
 ,     ,   
   Visual Basic   - 
   ,  . 
         ,  
,   ,       
.       . 

        


    . 1.1.  . 

     , -    
 (     )  , 
    :

    IF  THEN , 

        ,  ,  
   Visual Basic. 

     1.   Visual Basic	5 

    1.2.  Visual Basic 5 

    Visual Basic  5 .^,    
    . 

    Standard Edition	Visual Basic Standard Edition    
       Microsoft Windows 95  Windows NT.   
     Visual Basic,   
(data-bound)  . 
    
    Professional Edition	 Professional  
-      
 ,   .    
 Standard Edition     ActiveX, 
 '^ ~ Internet    Crystal Reports 
 Visual Basic (   5). " 

    :   ActiveX   ,  
   ,      
  .    ActiveX  
,         .   
     .. 

    Enterprise Edition	 Enterprise    
   .     
 Professional     , ,  
Automation Manager, Component Manager,    
   Microsoft Visual SourceSafe  -  
  . 

    1.3.    Visual Basic 

       Visual Basic     : 
    1.    . 
    2.   ,    , 
   . 

    1.3.1.    

         Visual Basic   
 ,     ,     
 . 
       ,      
     .    
   ,  ,   
 ,   . 

    1.3.2.    

      ,       
 ,    .  
  

6

       Visual Bas,    Visual Basic  
   Active    ,  
   .  /  ,   , 
         Toolbox 
  View.     t  . 

    . 1.2.   Visual Basic (  ). 

         ,     
  ,         
   . 

          

             
 Acl veX.    ActiveX   
 Visual Bas Professional  Enterprise.    
  ActiveX     . 
        ActiveX   : 
    1.   Project   Components   <Ctrl + >. Visual 
Basic      Components (. 1.3). 
    2.   Controls    ,  
 ,   ,      . 
    Visual Basic      . 

       

           
       . 
       .    
   ,     () 
 .        
  Visual Basic. 

      		 

    AniButton	ani	aniMailBox 
    CheckBox	chk	chkReadOnly 
    ComboBox	cbo	cboRussian 
    CommandButton	cmd	cmdExit 
    CommonDialog	dig	dlgFileOpen 

      (  ,     )	ctr	ctrUnknown 

    re  1.   Visual Basic	7 

    Components 

    Controls I Designers ) Insertabie Objects 

    [V] Microsoft Internet Controls 
    LJ Microsoft Internet Transfer Control 5.0 
     Microsoft MAPI Controls 5.0 
    U Microsoft Masked Edit Control 5,0 
    i ] Microsoft Multimedia Control 5.0 
    G Microsoft Outline Control 
    LJ Microsoft PictureClip Control 5.0 
     Microsoft Rich Textbox Control 5.0 
     Microsoft Syslnfo Control 5.0 
    ,3 
    Microsoft Tabbed Dialog Con1 
    JJ    M    jrr 
    -_ ! aaa '"'     fe-_   2B 
    L^] 
     Microsoft Windows Common Controls 5,0  Microsoft Windows Common 
Controls-2 5.0 V1 Microsoft Winsock Control 5.0 LJ RealAudio ActiveX Control Library 
    Microsoft Tabbed Dialog Control 5.0   Location:    : 
\WINDOW5\5YSTEM\TABCTL32. OCX 
    Browse,,. 
    ^J     $~~ Selected Items Only 
    OK 
     
     

    . 1.3.   Components. 

      		 

    Data control	dat	datOrders 
    Data-bound ComboBox	dbcbo	dbcboLanguage 
    Data-bound Grid	dbgrd	dbgrdQueryResult 
    Data-bound list box	dblst	dblstSchetType 
    Directory. ListBox	dir	dirSource 
    Drive ListBox	drv	drvSource 
    File ListBox	fil	filSource 
    Form	frm	frmSchet 
    Frame	fra	fraLanguage 
    Gauge	gau	gauStatus 
    Grid	grd	grdTovar 
    Horizontal ScrollBar	hsb	hsbVolume Image	img	imglcon 
    Label	Ibl	IblHelp 
    Line	lin	linVertical 
    ListBox	1st	IstOrder 

    MAPI message	mpm	mpmSentMessage 

8

       Visual Ba 
      		 
    MCI	mci	mciVideo 
    MDI Child Form	mdi	mdiNote 
    Menu	mnu	mnuFileOpen 
    MS FlexGrid	msg	msgClients 
    MS Tab	mst	mstFirst 
    OLE	ole	oleWorksheet 
    Outline	out	outOrgChart 
    Picture	pic	picVGA 
    PictureClip	clp	cIpToolbar 
    Shape	shp	shpCircle 
    Spin	spn	spnPages 
    TextBox	txt	txtFlO 
    Timer	tmr	tmrAlarm 
    UpDown	upd	updDirection 
    Vertical ScrollBar	vsb	vsbRate 
    Slider	sld	sldScale 
    ImageList	ils	ilsAlllcons 
    Toolbar	tlb	tlbActions 
    StatusBar	sta	staDateTime 
    ListView	Ivw	IvwHeadings 
    ProgressBar	prg	prgLoadFile 
    RichTextBox	rtf	rtfReport 
    V 

         

         ,    . 
    ,      . 
     . 
       ,   ,        
  ".      ,  ,  
.   Kaj<jgjiH^O3,qaHbjj^cy^LyecTBYtgT   ,  
           
 ,    . 
     Visual Basic     .   
    .      
, ,      . 
         
         .   ,  
      .    
,       . 
    ,    Show,     
 .
          ,    
 ,      .    
 !     ,    
   

     1.   Visual Basic 9 

    1.3.3.    

         Visual Basic  
    . 
    '       .  
  ,        
( Property Pages). 

    :      .   
"  "   9 "   ActiveX". 

    "    ,    Properties   
          
Properties,    View 
    -   Properties Window,   _<4>.   
   ,    ' , 
   -1  .  ,  
 ,   1  .  . 1.4  
  _ -,      
 ( )     ( ). 

    :d 

    . 1.4.         . 

     Appearance 
    Appearance 
    iBackColor 
    Caption 
    DisabledPicture 
    DownPicture 
    MaskColor 
    Style UseMaskColor 
    ,1-3D 
    Command 1 .(None) ""7     ~"J~~ '(None) 
     &HQOCDCQCQ& (None) 0 - Standard False 
     
    i  
    BackColor  Behavior 
    DragMode 
    Enabled 
    OLEDropMode 
    RightToLeft 
    TabStop 
    Visible 
    1 -3D 
    0 - Manual 
    True 
    0 - None 
    False 
    True 
    True 

    10    Visual , 

        ,     
       . 
            , 
    .      
 txtData     . 
    txtData.Font.Bold =  True   '         
    Text   txtData: 
    txtData.Text  =   "Visual   Basic   5"   '          
    ^  ,    
^ . ,     
"Text,    (Label)   Caption.     
          Text  
Caption    : 
    txtData = "  Text   " IblData = 
"  Caption " 
          
          ,   
  : 
    Dim sName As  String sName  =  txtName.Text 

    1.3.4.    

       ,     . 
Mi        . 
    Menu Editor   ,     
   .   Menu Editor   
   ,       
,      ,    
     
        : 
    1.   Menu Editor    (   
Menu Editi  Tools     <Ctrl + >),    
   Menu Editor. 
    2.   Caption     ,     
  
    3.       ,    
  . 
    4.       ,    
 Mei    ( )      . 
    5.    Checked     (  
   .  " "  . 1.5). 
    6.     Enabled,      
(.   " "). 
    7.  Shortcut        
^ . 


    12     

      KOI 

       ,        
        
Object Brows*      ,   
Visual Basic,  _    . 

    1.4.1.   

     Visual Basic    :     
  

       

    Visual Basic         
 ,    . ,   
     Click ( ). ,   
 [   Click,  ,    . 
        ,     
 /     Code   View. 
            
!/ (    ).    
       Procedure   . 

    IP Project! - Form'1 (Code) 
    Form 
    *      Load 
    Priuate Sub cndOK_Clicg^ MsgBox "UisualgJH J^djSub_____________ Deactivate 
    DragDrop Drag Over 
    r,   	f.   ..   r-          .       .., GotFocus Priuate Sub Form_Load( ҹ 
    KeyDown 
    End   Sub	KeyPress 
    KeuUp Link Close 
    
    . 1.6.  Procedure  . 

           Click   
 cmdOK: 

    Private  Sub  cmdOK_Click() 
    MsgBox   "Visual   Basic"   '          End  Sub 


      

        Sub  Function,    
  .      ,   
  ,    . 
       ,       Add 
Procedure i  Tools.     ,    
   ;   Sub,   . 
  

     1.   Visual Basic 13 

     ,    
   '         
 . 
    ( Sub 
     Sub  _      
 [ .   Sub ,    
_ ' .  Call     . : 
    h 
    all   sortList("namel") 
    z    Call,      
 . -  Call ,      
 . /         ~~~-~""~  Function 
    1  Function     .   
  Function       . 
    i  Function   Square(I   As   Integer)   As   Integer I        Square  
=1*1 End  Function 
        ,    
   ,    : 
    j   =  Square (5) 
       ,   { ^""^^ 
4ft l~"vPg1
    """"""?iijiL.        ...i^.-.	at If   -"''" '"'' 
-:-..!- '      ' '        '       -            *"    '"^V, -,   n,t     
      -1...,.              ",-.- '*>|i"f"*1"**lw~!''"*.'V '-*">-' 
1W*"'"**1'"'1'                 """"""""        """                        
  T-J^^^ 
      ,    , '   
,   . :	~      - -   ---... 
    Square   5 
    :  Sub  Function     . 
    ,    
 Optional. 

    1.4.2.     

    I     ,   ,   
    .   ^ 
 Visual Basic;     ,   
   . 
    ?\    Private  Public.  Private 
 -" !""11^'"|]1  
,   . 
    1     Public      .  
     ,     . 
     Publjc^^ni^cjHHbie_BgTajjfla^HjC^M_M^c^ne,    
         . 
       Public: 

    Public   Sub   Prod () 
    End  Sub 
          ,    : 
    Forml. Prod 
    V 

    14   

         ,   : 

    Prod 

             ,  
    ,     : 

    Modulel.Procl 

     Object Browser 

     ,       ,   
Object Brov     ,    
          . 
      Object Browser  ,     
,    . 
        Object Browser,   <F2>,   
  Browser   ,    Object Browser 
  View. 
         Object Browser. 

    n, Projectl - Microsoft Visual Basic [design] - [Object Browser] 
    L.lDix] 0 File   Edit   View   Project   Format   Debug   Bun   j_0ols   
Add-Ins   Window   Help   _-1 ff I XJ 
    -13. 
    & B,| * 
    SI     
    * 
    / 
    ^  * '..JJ JSb* _JLJ 
    !	,___ 
    Members of Classr	?  
    1 gsUser -\  
    Forml 
    = ShowDate 
     4=) Copy 
    Private Class Class 1 Member of Proiectl 
    / \    
    View Definition 
    Find Whole Word Only Group Members Show Hidden Members : References... Properties,,, 
    f Hejp 
    Dockable 
    Hide 

    . 1.7.  Object Browser    Object Browser. 

    i.  1.   Visual Basic	15 


    1.4.3. ,     

      

         Dim.    
  iCounter  Integer. 

    Dim  iCounter  As   Integer 

     Visual Basic    ,  
      ,     
.      ,    General 
Declarations      Option Explicit.    
    Visual Basic   . 
      Option Explicit      : 
    1.   Tools   Options. 
    2.    Options   Editor    
Require Variable Declaration.  . 

      

       Const.    
 . 
         PI  Single: 

    Const   PI   As   Single   =3.14 

    Visual Basic     ,   
   . 
          MsgBox   
 vbYesNo  vbYes: 

    iResult   =  MsgBox   ("?",   vbYesNo) 
    If  iResult  =  vbYes  Then '      
    End If 

    1.4.4.    

         ,    
,    . ,  ,  
     ,      Integer. 
    Visual Basic       Integer 
(), Long ( ), Single (     
), Double (     ), Decimal 
( )  Currency ( ).    
     ,   Variant.  
     : 

    	_                                                          

     	 
          	  
,    . -             "    
_____  -922,337,203,685,477.5808  922,337,203,685,477.5807. 

    16       KOI 

     		   

    Double	     .   
   -1.7976931 3486232308  -4.94065645841 247-324.  
                    4.94065645841 247-324  1. 
7976931 3486232308.	8  
    Integer	  .   -32,768  32,767.	2  
    Long	  .   -2,147,483,648  2,147,483,647.	4  
    Decimal	( )  79 228 162 514 264 337 593 543 950 335 
  ; 7,9228162514264337593543950335  28    
;             
0,0000000000000000000000000001.      
   Decimal     Variant,   
    Decimal . , ,  
    Variant   Decimal   
 CDec.	14  
    Single	     .   
   -3.40282338  -1.401298-45.     
 1.401298-45  3.40282338.	4  

         ,     
   Byte.   Byte    
       . ,  
 Strir    ANSI  Unicode,   
    . Visual Basic   
   ANSI  Unicode  
         ; 
         ; 
        DLL; 
           . 
     ,     ,     
 Byt<    .   Byte    
    255,      . 
        Visual Basic  
 Byte     . 
           ,   
  String: 

    Private   S  As   String 

            
    : 

    S  =   "Database" S   =  Left (S,   4) 

        : 

    '    1.   Visual Basic	17 

      ,      2 
 (2   ) "~; 
        ,     1   
64 (216) I       . 
    '	 :        
 ,     Public. 
     ,        ; 
         . 
         : 
String *  

    ,  ,     50 ,  
 : 

    Dim  strName  As   String   *   50 

          50 , strName  50 
 _...     
 , Visual BisTcfnpocTo   . 
           ,  
       Trim  RTrim,    . 
              
Public  Private.   ,       
   Private. 
      ,       
/, /  /,        
 Boolean.        False.   
  blnRunning  Boolean   /: 

    Dim blnRunning  As   Boolean 
    '   ,        :	If   CDPlayer.Direction  =   1  
 Then 
    blnRunning  =   True End  if 

             8- 
  Date,     Variant.      
 ,     .      1 
 100 .  31  9999 . 
           Date    
    ,       
 .    0,   0.5.  
     30  1899 . 
    06bjiCTHbj^egeMeHHbie_xpaHflTcgjsaK 32- (4-]| , 
__              . 
     , JOJJ5efl..J<a)<_.Qbject,    
 (   Set)    , 
 : 

    '         

    Dim  objDb  As   Object 

    '             -     

    Set   objDb  =  OpenDatabase(":\office\sample\dbl.mdb") 

    18    

           
  (,  TextBox  Control ,   , 
Database  Object)    Object. Visual Basic   
           
.  <      . 
  )     Object Browser. 
             
Variant  Obje      ,     
   OKI Object Browser.  ,  Visual Basic 
         . 
     Variant       . 
-         
    Variant Visual Basic   
   . : 

    Dim VarVariant        '   Variant      

    VarVariant  =   "2"   '   VarVariant      "2"    (   
). 
    VarVariant  = VarVariant  +  3   '   VarVariant       
   5 
    VarVariant   =   "Visual   Basic   "   &'VarVariant   '   VarVariant   
    
    '    "Visual   Basic   5"    () 
       Variant   ,     
   ,       , 
     : 
           Variant     
 Variant   ,     ; 
             &   +. 
            ,  
 jv Variant. ,   Variant    
,    .       
, ,   ,    . 
          ,  
 ; , , ,      : 
    '    sFname        Variant, Dim  sFname,   sLname  As   String 
    a   sLname-String: 
    '              : Dim  sFname  As   String Dim  
sLname  As   String 

       

       Visual Basic   . , 
      , Visual 
Basic,        . 
        ,     
*         
. ,  ^     
     : 

    Private   Sub   Commandl_Click () Dim  intX  As   Integer Dim   strY  As   String 

     1.   Visual Basic	19 

    strY  =   "100.23" 
    intX  =   strY  '           
    Textl.Text   =   intX '         
    '           
    Texts.Text  =  Cos(strY)    '                 
    strY  =  Cos (strY)	'           
'                
	Text2.Text   =   strY '          
    '                End  Sub 

    Visual Basic       
.          : 
        
.         
         
,      -        
Windows.         1      , 
    (  ,  
  "100.23"). 
        ,  Visual Basic  1  
   : 

    Dim  iNewRate  As   Integer 
    txtRate.Text  =   "5" iNewRate  =  txtRate.Text   +   1 

    Visual Basic   ,    
       . ,  
   Currency,    CCur: 
    Summa   =  CCur(Kol   *   Cena) 

                

    Cbool	Boolean _______CByte________________Byte_______ 
    CCur	Currency _______CDate      _____   _______Date      _____ 
    CDbl	Double 
    Clnt	Integer 
    CLng	Long 
    ________CSng________________Single_______ 
    ________CStr________________String_______ 
    ____CVar _______      _____Variant_______ 
    ________CVErr________________Error_______ 

    ,    ,     
  ,   . 
    ,    Long  Integer  Long  
       Integer. 


    20   

    1.4.5.    

         ,    
 - .      
,     ( ,   )   
  ( Public 1 Private). 

      	foj/lYfi%& 

    ,   ,     
.          Integer: 

    Dim  iTest  As   Integer 


       

    ,    General Declarations ,  
 Private  Public. 
     Private     ,    
   . 
     Public      .  
  Public       
  _. 
    : 
    Public fTotal As Integer frm.fTotal = 4 
          
        
    ,    General Declarations ,  
 Private  Public. 
     Private    . 
     Public     .  Public  
   ,  _ . : 
    '           Public  giTest  As   Integer 
    '          giTest   =   5 
    '                        
 Modulel.giTest  =  5 

    1.4.6.    

       ,     . 
        ,    
(   )     ( Static   Static). 

       

       ,   .  
     . 

     1.   Visual Basic	21 

    ^^&        
,     Static*.	" "~ ~...  . 
    ,   Static,      
;        
". "" 
        iRetryCount     
   Prod.  iValue     0: 

    Sub  Prod () 
    Static iRetryCount As Integer 
    Dim iValue As Integer 
    iRetryCount = iRetryCount + 1 End Sub 


       

    ,    ,    ,  
 ._?..&/   Nothing.    
,          . 
         Nothing    
^;  Terminate .**** 
          Form2   Nothing: 
    ;   Set   Form2   =  Nothing 

        

    ,    ,      
 . 

    1.5.       

       Visual Basic    
       ,   
.         , 
    . 
        ,      . 

    1.5.1.    

    Visual Basic      
       . 
         ,   Debug  View 
   Debug. 
      Visual Basic : 

    22	     ! 

    i View  Eroject   Fgrrnat   Debug   R.jn 
    -6 <*1 ?s < i:  P P <ftf 
    Toggle Breakpoint I 
    Step IntoI Step Over I Step OutJ 
    L, 
     iJi-'J'111-1- oru'/v^cr 
    Immediate Window    Ctrl+G 
    L Call Stack Quick Watch         Q L Wat  h Wi n d ow	 Locals Window  
Immediate Window           |?3 watch Window Locals Window                      
   ^ Cay stack... 
    Ctri+L Prni-h Fynlnrw	ri-i-l-i-R 
    il        Debug  Run   Tools   Add-lns   Window   Hell 
    I Step Into	F8 tl Step Over                         5hift+F8 
    *1 Step Out	Ctrl+Shift+F8 Run To Cursor 
    add Watch,,. 
    6V Quick Watch... 
    Shift+F9 
    	LEefauK]	<:Wrongnrniber of argun Object 
    	Actwe Control	Hottrmg                        Control 
    	Appearance	1                               Integer 
    ' ...)       & loggle Breakpoint	F9 gear  Breakpoints   Ctrl+Shift+F9 
     Set Mext Statement	Ctrl+F9 ^ Show Ne^t Statement 
    .jd 

    . 1.8.   Visual Basic. 

     	 
      (Toggle Breakpoint)	  .  
    ,   Visual Basic  
 .         
  ,     (Break Mode). 
       (Step Into)	     
    . 
       (Step Over)	     
    . 
       (Step Out)	     
       . 
      (Quick Watch)	   ,  
       . 
      (Call Stack)	       
 (Call Stack),     ,    
() . 

    1.   Visual Basic	23 

    -,	 	             __                 ____ 
    1		  ()   
    :		   Watches    . 
    J	       
    1	. 
    I       
    1      Immediate	      , 
         Immediate. Visual Basic 
    1	 .      
    ,,j     ______________ CjieD^op^Debug^Print.___________________ 
     Locals	        
    1     ______________       ._____ 

    1.5.2.    

                  
  ,       
     I        . 

          

             
 ,     . 
    ,      
   ,    .   
     ,     
 . 
           
,      . 

     MaxLength 

     MaxLength       . 
    J       ,     
,  -|      .     
   ,  ^1^]. . 
KeyPress ( KeyAscii). 

     Locked 

     Locked ,       
 . '      Locked  True,    
    . 

    i       KeyPress    

              
 KeyPress, KeyDown  KeyUp.      
    (,    
  )      
 (,      ). 
     KeyPress   ,    
  ASCII. 
         , ,  
 ,      Delete.  
    ,    KeyDown  KeyUp. 

    24       

              

    Sub  Textl_KeyPress(KeyAscii  As   Integer) KeyAscii   =  
Asc(UCase(Chr(KeyAscii))) End  Sub 
       KeyPress      
  ,   : 
    Private   Sub   Textl_KeyPress(KeyAscii  As   Integer) Sub   Private   
Textl_KeyPress    (KeyAscii      Integer) 
    If  KeyAscii   <>   8   Then   '            
    '            
    If   Chr(KeyAscii)   <   ""   Or  Chr(KeyAscii)   >   "9"   Then KeyAscii 
  =   0   '              End   If End  If 
End   Sub 

    1.5.3.      

              
      ,    
     .    Visual 
Basic      . 

       

             
,         ,   
    .   ,   
  ,       ,     : 

          
      
    JOQ1836-AKJ 
     

    . 1.9.    . 

             ,  
   ^ KeyPreview .     
   ,     . 
          ,    
   : 

    Private   Sub   Form_Load() 
    Me.KeyPreview = True 
    cmdOK.Enabled = False End Sub 
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) '  
 ,       

     1.   Visual Basic__________________________25 

    Dim curControl As Control For Each curControlTn Controls *Tf" TypeOf 
"cTTrContTroT Ts Text Box Then 
    If curControl.Text = "" Then '    
    cradOK.Enabled = False '   OK 1         Exit Sub End If 
    '  ,        ' 
  
    :     End If     ',-'-	'  -         -     ,  ';,,^,,;^.. , /'  
    Next 
    '      cmdOK.Enabled = True End Sub 

         

               
     Click  . 
            
     .      
,       . 
    ,         
   ,       : 

    Private   Sub  cradOK_Click()	/-                                    
    If  Not    (IsNumeric(txtOtdelNo.Text) )    Then	tyWflArVU/l/Q   j/^f,   
l^Afr MsgBox   "     "                                      
  '             / txtOtdelNo.SetFocus ELseLf Not   
(rsffumeczcC^JfC^ec-ircy-f-A^.jre'^^^   ^^ 
    ^^S5^. 
    txtSectorNo.SetFocus i    Else !      MsgBox " " 
    Unload Me ;    End If !  End Sub 

      QueryUnload 

     QueryUnload     Unload, 
  . 
     QueryUnload  ,     
Unload,   ^_^'1 Unload.  ,  
  " ^       
     . 
     QueryUnload    : 
       UnloadMode ,     Unload; 
       Cancel   Unload.  Cancel   
True,    ,     
 . 
        Unload ,    
    : 

    26       

    Private Sub Form_QueryUnload(Cancel As Integer, _ 
    UnloadMode As Integer) Dim iResult As Integer 
    iResult = ' ,   ?", vbYesNo) If iResult = 
vbNo Then 
    Cancel = True End If End Sub 

       

      ,    ,   
    .      
,     ,       
 .      ,  
    

        

          : 
    1.    ,  ,   
  ,    . 
    2.    . 
    3.     . 
     On Error GoTo     ,  
 ,   .    
      ,    
On Error GoTo.     ,   
Resume,  ,   . 
       ,    On Error GoTo  Resume. 

    Private   Sub  Commandl_Click() 
    Dim AppName  As   String 
    On  Error   GoTo   CheckError 
    AppName  =   InputBox ("    ") 
    Shell  AppName Exit   Sub 
    CheckError: 
    I    f  Err.Number  =   53   Then   '         sgBox   
"      " 
    If  MsgBox("     ?",   vbYesNo)   =  vbYes   Then AppName  
=   InputBox("     ") Resume   '      Else 
    Resume  Next   '         End  If Else 
    MsgBox   "         " End  If End  Sub 

            ,  
!         
 Err. 

     1.   Visual Basic	27 


      Err 

     Number   ,     
.        Err.Number. 
             
 ,   .      
   ,    ,  
 . 
     Description  ,    . 
     Source   ,   .  
   . ,    
Microsoft Excel    , Err.Number    
 , a Err.Source   Excel.Application. 

      Err 

     Clear   Err.Number  . 
     Raise  .      
 .  Bbi3biBj^ytqjT|)oue.Qypy     
. : 

    Err.Raise 53 '   "  " 


     Resume 

       Resume  ,   
    .      
  Resume,   Visual Basic: 

    	 
    Resume	  ,   . Resume  
     . 
    Resume Next	  ,    , 
  . 
    Resume   	     Resume, 
   .  ,     
,    ,    
,  .       , 
   ,  ,  
  . 

    :   Resume  -   
 ,   . 

    1.5.4.    

             
. Visual Basic     ,  
     . 
        : 
    1.   Tools   Options. 
    2.   General   Options,   Error Trapping 
     . 

    28     - 

      Error Trapping  General   : 

    	 
    Break on All Errors	   ,    
   Visual Basic     Error  
   (Break). 
    Break in Class Module	      
 Active]    ActiveX     
BMI     -. :  
ActiveX    (, .exe, .dll, . 
    Break on Unhandled Errors	Visual Basic     
  ! ,       
  

    1.6.     - 

              
 KOf ,      
 . 
        Visual Basic   .  : 
    1.   File   Make _.. 
    2.     . 
    3.      :    Make EXE 
File   Options.    Project Properties.  
 Make        ;  . 
         Version Number  Make: 

    Proiecll - Pioject Properties 
    Make | Compile) , Version Number 1 Major;    Minor;     Revision:   ', , 
    \W~ F~ F~   .: 
    " Auto Increment 
    Version Information :   Tffe;	-|; 
    Application 
    Iftte:   | Project 1 
    Icon:   JForml 
    d 
    ^ j 
    Command Line Arguments;	| Conditional Compilation Arguments: j 
    OK 
    Cancel 
    Help 

    . 1.10.  Make   Project Properties. 

    :     Project Properties   
  /     Project \ Project Properties 
(. . 1.11). 

     1.   Visual Basic	29 

       Visual Basic      
MS-DOS.      .   
        
  . 
      ,     
 : vb32 /make _ __ 
             
  DLL   .     
Setup,      . 
     Setup Wizard Visual Basic     
     .    
        
  Setup. 
        Setup .   12 " 
 Setup   ". 

    1.6.1.     

     Visual Basic Professional  Enterprise   
       Visual Basic (-), 
    .     
      ,   
 -. 
    -         
Visual Basic     ,    . 
       Visual Basic    -  
 .        
   - . 
         : 
    1.   Open Project    Project Explorer  ,  
 . 
    2.   Project   Project Properties. 
    3.    Project Properties   Compile. 
    4.       . 
         ,    
Advanced Optimizations. 
     . 1.11    . 
             : 

     

     
    Optimize For Fast Code 

        , 
"" ,    .   
  Visual BailcfB      
    ,    
    .     
   .    , , 
    ,      
   ,      
  . 

    30     - 


    Project! - Pioject Properties 
    Senetal) Make    Compile j Component j 
    f" Compile to P-Code 
    (* Compile to Native Code ~....._~..~.. ...... 
    (" Optimize for Fast Code     |~ Favor Pentium Pro(tm 
     Optimise for Small Code    " Create Symbolic Bebu       " Assume No aliasing 
    I Advanced Optimizations 
    Warning: enabling the following optimizations may prevent correct 
execution of your program 
    No Optimization 
    Advanced Optimizations... 
    OK 
    Cancel 
     Remove Array founds Checks 
    I    Remove Integer Overflow Checks 
    " Remove floating Point Error Checks 
    ? Mm Unrounded Floating Point Operations! 
    I" Remove Jafe Pentium(tm) FDIV Checks 
    * I	Cancel      j	Help 

    . 1.11.     . 

     
     
    Optimize For Small Code 

        , ; 
,    .     , 
,      , \- 
    ,    
      . 

    No Optimizations 

      .    ,   
 ,        ,  npt 
   . 

    Favor Pentium Pro 

            
 Pentium Pro (P6). ,    ,   
     ,   .  
   ,   Pentium Pro,   
     80386, 80486  Pentium.  , 
   ,       , 
 ,  Pentium Pro. 

    Create Symbolic Debug Info 

            
. ,         
,     Visual C++ 5.0    . 
      .pdt    . 

    Asume No Aliasing 

     ,       ( 
).   ,     ,    
 .      ByRef,  
   .      
 ,    ,   
      .     
   ,     
,    c . 


      1.   Visual Basic    31

                  

    Remove Array Bounds Checks 
             
 .  , Visual Basic     
  , ,      . 
    ,  .    
   ,      . 
    ,       ,   
   ,      
   .     
   . 

    Remove Integer Overvlow   
        ,   ,  
 ,       -.  
, Visual Basic       Checks 
    (Byte, Integer, Long  Currency),  
,       
.     ,  . 
          ,    
 .        
   ,      . 

    Remove Floating-Point Error Checks 
      , ,   , 
    ,     
              
 .  , Visual Basic    
         (Single  
Double),  ,      
 .     ,  
.      . 
         ,     
  .         
   . 

    Remove Safe  Pentium FDIV Checks Pentium Unrounded  Allow 
       ,     
   (FDIV  floating-point division)     ,  
   .      
          
 Pentium,    FDIV.      
   ,         
  . 
            
       . 

    Floating-Point Operations Allow Unrounded 
             
      (Single  Double). 
    ,      
 ,       .  
      .   
   ,        
,  ,      ,    
 ,   . 
        ,       
    . 
            
       . 
