Книга - Visual Basic для новичков. Шаг за шагом. Самоучитель / справочник
Warning: mb_convert_encoding(): Unable to detect character encoding in /var/www/u2150601/data/www/ae-books.online/wp-content/themes/twentyfifteen/content.php on line 442
Visual Basic . . /
Visual Basic, , Windows. Visual Basic .
Visual Basic .
/
,2023
ISBN978-5-4483-0400-2
Ridero
Π ?
Microsoft Visual Basic 6.0, Visual Basic Windows, .
Visual Basic, .
, , , .
, :
Microsoft Visual Basic 6.0 ,
,
,
Windows,
,
,
,
,
,
,
,
,
,
!
, , Visual Basic.
, , , Visual Basic:
Microsoft Windows,
,
Basic.
Visual Basic
(), 50- ՠ .
, , .
, Dartmouth College BASIC. , Beginners All-purpose Symbolic Instruction Code ( ). Basic , . , .
Basic , . - (Altair), 1975 4 . Microsoft (Bill Gates) (Paul Allen).
IBM, Microsoft GW-Basic, DOS. Ӡ GW-Basic 100 .
Basic DOS : Microsoft QuickBasic Borland TurboBasic. , , exe-.
Microsoft Windows, 1991 Microsoft Visual Basic for Windows 1.0. , 頖 .
Microsoft Visual Basic for Windows, , , Windows, , Microsoft Office.
Visual Basic
, , , , Basic, Visual Basic.
, .
: , , , . ., Visual Basic . , .
Visual Basic QuickBasic, TurboBasic Basic DOS, , Windows, .
Visual Basic , , , .
, , .
Visual Basic , , .
, Visual Basic , Windows.
Visual Basic
Microsoft Visual Basic 6.0 , , , , :
Learning Edition ( ) ,
Professional Edition ( ) , ,
Enterprise Edition ( ) - , , .
, Visual Basic, , .
Visual Basic 6.0Enterprise Edition, , , , Microsoft Visual Studio 6.0, .
, Microsoft Visual Basic Microsoft Visual C++, Microsoft Visual FoxPro, .
, , .
, - , :
1,
2,
..
, :
, , , : [F1]. , , , : [Ctrl] + [Break].
, : File Open (렖 ).
: Microsoft Visual Basic.
, , , :
If Check1.Value = CheckedThen
Frame1.Enabled = False
Else
Frame1.Enabled =True
EndIf
1. Visual Basic
:
Microsoft Visual Basic 6.0 ,
Microsoft Visual Studio6.0.
1.1.
Microsoft Visual Basic 6.0 Microsoft Visual Studio 6.0, .
Microsoft Visual Basic 6.0 CD-ROM - Microsoft Visual Studio 6.0 . , CD- Windows, .
Microsoft Visual Studio 6.0(.1.1).
.1.1.
Microsoft Visual Studio6.0
View Readme ( Readme), , , .
Next (). End User License Agreement ( ) Microsoft (.1.2).
.1.2. End User License Agreement
( )
Iaccept the agreement ( ) Next (). .
Product Number and User ID ( ) (.1.3).
.1.3. Product Number and User ID
( )
Please enter your products ID number (, ) Microsoft.
Your name ( ). , .
Your companys name ( ) , , .
Next () , Microsoft Visual Studio 6.0(.1.4).
.1.4.
Enterprise Setup Options ( ) Custom (). ࠖ Visual Basic Visual Studio .
Next () Choose Common Install Folder ( ) (.1.5).
.1.5. Choose Common Install Folder
( )
, Next (). 堖 .
Microsoft, (.1.6).
.1.6. Microsoft
Continue ().
Product ID ( ) , Microsoft Microsoft Visual Studio 6.0(.1.7).
.1.7. Product ID ( )
OK Product ID, Microsoft.
, (.1.8).
.1.8.
Microsoft Visual Studio 6.0, . , Select All ( ).
Microsoft Visual Studio 6.0, Visual Basic, :
Microsoft Visual C++6.0,
Microsoft Visual FoxPro6.0,
Microsoft Visual InterDev6.0,
Microsoft Visual SourceSafe6.0.
Continue (). , (.1.9).
.1.9.
, , 頖 ()(.1.10).
.1.10.
No (), , .
Windows(.1.11).
.1.11. Windows
CD- , , .
Restart Windows ( Windows). MSDN Library ( Microsoft)(.1.12).
.1.12. MSDN Library
( Microsoft)
CD-ROM - MSDN Library ( Microsoft).
Install MSDN ( Microsoft).
Next (). Microsoft, , Other Client Tools ( )(.1.13).
.1.13. Other Client Tools
( )
InstallShield ( ) Client Tools ( ) Install (). , .
Next (), Server Setups ( )(.1.14).
.1.14. Server Setups ( )
, , . , Server Components ( ) Install ().
Next (). Microsoft Visual Studio 6.0(.1.15).
.1.15. Microsoft Visual Studio6.0
Register Now ( ), - Microsoft, Finish () Microsoft Visual Studio6.0.
1.2. /
ꠖ ࠖ (Start Settings Control Panel). (Control Panel)(.1.16).
.1.16. (Control Panel)
(Add/Remove Programs). : (Properties: Add/Remove Programs)(.1.17).
.1.17. :
(Properties: Add/Remove Programs)
Microsoft Visual Studio 6.0Enterprise Edition, , / (Add/Remove), .
Microsoft Visual Studio 6.0 (.1.18).
.1.18. Microsoft Visual Studio6.0
Ѡ :
Add/Remove (/) ,
Reinstall () ,
Remove All ( ) ,
Exit Setup ( ) - Microsoft Visual Studio 6.0Enterprise Edition.
Add/Remove (/), Microsoft Visual Studio 6.0, .
2. Visual Basic
:
Visual Basic,
,
,
,
,
,
,
,
.
2.1.
Windows ꠖ Microsoft Visual Studio 6.0 Microsoft Visual Basic 6.0(Start Programs Microsoft Visual Studio 6.0 Microsoft Visual Basic 6.0) Visual Basic New Project ( ), New ()(.2.1).
.2.1. New ()
New Project ( )
New Project ( ) , . . , , :
(*.frm),
(*.frx),
(*.bas),
(*.cls),
(*.ocx),
(*.vbp),
(*.res),
.
New (), .
, , .. , .
, New () New Project ( ):
Standard EXE ,
ActiveX EXE ActiveX ,
ActiveX DLL ActiveX ,
ActiveX Control ActiveX Visual Basic ,
VB Application Wizard Visual Basic,
VB Wizard Manager ,
Data Project ,
IIS Application Microsoft Internet Information Server,
Addin Visual Basic,
ActiveX Document Dll ActiveX ,
ActiveX Document Exe ActiveX ,
DHTML Application web-,
VB Enterprise Edition Controls Windows .
New Project ( ) Existing ()(.2.2).
.2.2. Existing ()
New Project ( )
Existing () , , , , (Folder), (Open).
Recent () New Project ( )(.2.3).
.2.3. Recent ()
New Project ( )
Visual Basic, (Open).
Visual Basic, . .
New () (.2.1) New Project ( ), Standard EXE ( ) Open (). Project1, , Visual Basic design ()(.2.4).
.2.4. Visual Basic
design ()
Visual Basic, :
(Window Header),
(Menu Bar),
(Tool Bar),
(Tool Box),
(Project Explorer),
(Properties Window),
(Form Layout Window).
(Window Header) Visual Basic, .
(Menu Bar) Visual Basic(.2.5).
.2.5. (MenuBar)
, Windows, (Tool Bar), Visual Basic. , , , (.2.6).
.2.6. (ToolBar)
Visual Basic (Tool Box)(.2.7).
.2.7. (ToolBox)
. .
(Project Explorer), Project Project1 ( Project1). , . Form1(.2.8).
.2.8. (Project Explorer)
, , , :
,
,
,
,
..
Visual Basic , .
(Properties Window), Properties Form1 (ࠖ Form1)(.2.9).
.2.9. (Properties Window)
Ѡ , , . : , , ..
, . : ࠖ . , Caption () Form1.
, , : Alphabetic () Categorized (). , , .
, 젖 (Form Layout Window)(.2.10).
.2.10.
(Form Layout Window)
Windows , , . .
Visual Basic. MDI Multiple Document Interface ( ). Visual Basic , SDI Single Document Interface ( ), .
, Tools Options ( ). Options (), Advanced ()(.2.11).
.2.11. Advanced ()
Options ()
SDI Development Environment ( ) OK, SDI Single Document Interface ( ).
MDI Multiple Document Interface ( ), Docking () (.2.12).
.2.12. Docking ()
Options ()
Visual Basic, ࠖ .
Visual Basic, (.2.4) , Project1 Form1 (Form) (Project1 Form1 ()), (.2.13).
.2.13. Form1
Project1
. Windows: , , , .
.
-, (.2.14).
.2.14. Form1
, Visual Basic. , , , , .
Visual Basic, , , , , .
Visual Basic . View (). Code Window ( ), , .
View Code (䠖 ), (.2.15).
.2.15. Code Window
( )
Object Browser ( ), , (.2.16).
.2.16. Object Browser
( )
Visual Basic .
2.2.
Visual Basic , . , , , .
, Visual Basic. , , .
- Visual Basic [F1].
- , , , , Visual Basic, .
Visual Basic . , ProgressBar ( ).
ProgressBar ( ) ToolBox ( ) [F1]. Visual Basic (.2.17).
.2.17. Visual Basic ProgressBar ( )
, , , :
See Also ( ) ,
Example () ,
Properties () ,
Methods () ,
Events () .
, ProgressBar ( ).
, Example (). , . , , ProgressBar ( )(.2.18).
.2.18. Visual Basic ProgressBar
( )
, Visual Basic, , .
Windows [Ctrl] + [C] [Ctrl] + [Insert].
[Ctrl] + [V] [Shift] + [Insert] .
Visual Basic, , .
, Search (), . Search () Visual Basic(.2.19).
.2.19. Search ()
Visual Basic
Search for following words ( ) , : And (), Or (), Near (), Not (). , , .
, , Topics () . , .
Visual Basic. Help Contents ( ), Help Index ( ), ꠖ Help Search ( ). Ѡ Help, , Web- Microsoft .
2.3. Visual Basic
Visual Basic Hello, World! (, !). : .
, !, 䠖 .
Hello, World! (, !), , .
Project1, .
Visual Basic Project Project1 Properties ( Project1). Project1 Project Properties (Project1 ), General ()(.2.20).
.2.20. General ()
Project1 Project Properties
(Project1 )
Project Name ( ) Project1 頖 HelloWorld. OK Project1 Project Properties (Project1 ).
. Form1, Properties Form1 (ࠖ Form1) (.2.21).
.2.21. Properties Form1 (ࠖ Form1)
Name (), Form1. Name () , Visual Basic -, .
Name () , [Enter].
Caption (). Form1 堖 , ! , , . (.2.22).
.2.22. HelloWorld
? Name () Visual Basic. , , , . : HelloWorld (Form). . .
Caption () , , , , Form (), CommandButton ( ) Frame (). Ӡ , ! , , , .
, , , . . ,!
Paint. CommandButton ( ) (Tool Box) , :
, , , . Command1.
. , (.2.23).
.2.23.
, . Visual Basic , , :
, , , .
Left (), Top (), Width () Height () Properties Window ( ). , 堖 .
, Command1 Command2, , .
Command1, Properties Window ( ) .
Caption () Command1 . , .
Name (), 堖 cmdHello.
Command2, Name () Caption () cmdExit .
, , , .
. cmdHello_Click, (.2.24).
.2.24. cmdHello_Click
Visual Basic, , , .
, 젖 , Visual Basic.
, .
, . cmdHello Click (). :
Private Sub cmdHello_Click()
EndSub
Sub, Subroutine (), (Declaration) cmdHello_Click, cmdHello.
, "_" . Visual Basic Click () cmdHello. , .
Private () , , 堖 . EndSub.
, , - , .
Ѡ (Coding), , .
. Visual Basic , , .
, , Visual Basic, , !:
MsgBox (, !)
:
Private Sub cmdHello_Click()
MsgBox (, !)
EndSub
. .
cmdExit_Click End, Click().
:
Private Sub cmdExit_Click()
End
EndSub
, , ! , .
, Start () [F5].
Visual Basic Hello, World! (, !)(.2.25).
.2.25.
Hello, World! (, !)
. (.2.26).
.2.26.
Hello, World! (, !)
OK .
. Visual Basic .
2.4.
, Visual Basic , . , Microsoft Office.
Save Project ( ) (Tool Bar), File Save Project (렖 ) . Visual Basic . Save File As ( ) (.2.27).
.2.27. Save File As ( )
File Name ( ) . (Save). , Save Project As ( ) (.2.28).
.2.28. Save Project As ( )
Save () File Name ( ).
. Save Project ( ) .
, , , .
(Project Explorer) Forms () . (.2.29).
.2.29. HelloWorld
(Project Explorer)
. , (.2.30).
.2.30.
(Project Explorer)
Save .frm ( .frm) .
Tools Options ( ). Options (). Environment ()(.2.31).
.2.31. Environment ()
Options ()
When aprogram starts ( ) Save Changes ( ) OK.
, . .
, , File Open Project (렖 ). Open Project ( ), Existing ()(.2.32).
.2.32. Existing ()
Open Project ( )
Folder () , , Open ().
, -. Recent () Open Project ( )(.2.33).
.2.33. Recent ()
Open Project ( )
, Open ().
, Visual Basic , .
(Project Explorer) (.2.29), , (.2.30) View Object ( ).
3.
:
Visual Basic,
,
.
3.1. Visual Basic
, Visual Basic , , VB Application Wizard ( Visual Basic).
File New Project (렖 ). New Project ( )(.3.1).
.3.1. New Project ( )
VB Application Wizard ( Visual Basic) OK. Visual Basic(.3.2).
.3.2. VB Application Wizard
( Visual Basic)
, , , , From what profile do you want toload your settings? ( ?). Open Profile ( )(.3.3).
.3.3. Open Profile ( )
VB Application Wizard ( Visual Basic)
(Open). Finish () (.3.2) .
, Next (). ࠖ Interface Type ( )(.3.4).
.3.4. Interface Type ( )
VB Application Wizard
( Visual Basic)
What type ofinterface would you like for your application? ( ?) :
Multiple Document Interface (MDI) ( ) , , Microsoft Word,
Single Document Interface (SDI) ( ) , , (Notepad),
Explorer Style ( ) , SDI, , Windows (Windows Explorer).
What name do you want for the application? ( ?) Project1.
Next () Menus () (.3.5).
.3.5. Menus () VB Application Wizard
( Visual Basic)
, , Menus ().
Menus () :
Add aTop Level Menu ( ),
Delete the Selected Top Level Menu ( ),
Move the Selected Item Up ( ),
Move the Selected Item Down ( ).
, Menus () ࠖ Sub Menus (). Sub Menus () , .
Next (). VB Application Wizard Customize Toolbar ( )(.3.6).
.3.6. Customize Toolbar
( )
VB Application Wizard
( Visual Basic)
. , , ࠖ , . , .
, , :
Move the Selected Button tothe Right ( ),
Move the Selected Button tothe Left ( ),
Move All Buttons tothe Left ( ),
Move the Selected Button Up ( ),
Move the Selected Button Down ( ),
Load an External Bitmap or Icon ( *.bmp *.ico).
, , , . Button Attributes ( )(.3.7).
.3.7. Button Attributes ( )
VB Application Wizard ( Visual Basic)
Button Name ( ), Tool Tip Text ( ) Change Bitmap ( ) , OK.
Next (). Resources () (.3.8).
.3.8. Resources () VB Application Wizard
( Visual Basic)
Would you like touse aResource file for the strings inyour application? ( ?) Yes (), . No ().
Internet Connectivity ( ) Next ()(.3.9).
.3.9. Internet Connectivity ( )
VB Application Wizard ( Visual Basic)
Do you want your users tobe able toaccess the Internet from your application? ( ?) Yes (), , . , web-, :
http://elstrana.ru
Next () Standard Forms ( )(.3.10).
.3.10. Standard Forms ( )
VB Application Wizard ( Visual Basic)
, :
Splash screen at application start up ( ),
Login dialog toaccept an ID and Password ( ),
Options dialog for custom settings ( ),
About Box ( ).
- , Form Templates ( ). (.3.11).
.3.11. Form Templates ( )
VB Application Wizard ( Visual Basic)
:
Dialog (),
ODBC Log In( ODBC),
Tip ofthe Day ( ),
Web Browser ( web-).
OK, Form Templates ( ).
Next (). Data Access Forms ( )(.3.12).
.3.12. Data Access Forms
( )
VB Application Wizard
( Visual Basic)
Create New Form ( ). , . Create another Data Form? ( ?)(.3.13).
.3.13. Create another Data Form?
( ?)
VB Application Wizard ( Visual Basic)
(Yes), , , (No).
Next () Visual Basic(.3.14).
.3.14. VB Application Wizard
( Visual Basic)
, .
Towhat profile do you want tosave your settings? ( ?). Save Profile ( )(.3.15).
.3.15. Save Profile ( )
VB Application Wizard ( Visual Basic)
(File Name) (Save).
, View Report ( ). .
Finish () Visual Basic. Application Created ( )(.3.16).
.3.16. Application Created ( )
VB Application Wizard ( Visual Basic)
OK . (.3.17).
.3.17. , VB Application Wizard
( Visual Basic)
3.2.
Data Form Wizard ( ) , .
, .
Data Access Forms ( ) Visual Basic (.3.12). Data Form Wizard ( )(.3.18).
.3.18. Data Form Wizard
( )
, From what profile do you want toload your settings? ( ?) , Finish ().
Next (), ࠖ Database Type ( )(.3.19).
.3.19. Database Type ( )
Data Form Wizard ( )
, :
Access Microsoft Access, ,
Remote (ODBC) , ODBC, .
Access, Next () Database ( )(.3.20).
.3.20. Database ( )
Data Form Wizard ( )
Database Name ( ) Microsoft Access, Browse () Access Database ( Access)(.3.21).
.3.21. Access Database ( Access)
Data Form Wizard ( )
, (Open). Database Name ( ) .
Next () Form ()(.3.24).
- , Database Type ( ) (.3.19) Remote (ODBC).
Next () ࠖ Connect Information ( )(.3.22).
.3.22. Connect Information
( )
Data Form Wizard
( )
ODBC Connect Data ( ODBC) :
DSN ,
UID ,
PWD ,
Database ,
Driver ODBC,
Server .
, , , , Next ().
, : Incomplete Data. You must enter valid connect information before you can continue. ( . , .)(.3.23).
.3.23. Incomplete Data ( )
Data Form Wizard
( )
Form () Data Form Wizard ( )(.3.24).
.3.24. Form ()
Data Form Wizard
( )
What name do you want for the form? ( ?) .
Form Layout ( ) :
Single Record , ,
Grid (Datasheet) ,
Master/Detail ,
MS HFlexGrid ,
MS Chart .
Form Layout ( ).
Binding Type ( ) , (ADO Data Control).
Next (). Record Source ( )(.3.25).
.3.25. Record Source ( )
Data Form Wizard ( )
, , Record Source ( ). Available Fields ( ) .
Ѡ Move the Selected Field tothe Right ( ) Move All Fields tothe Right ( ) , , Available Fields ( ) 頖 Selected Fields ( ).
Selected Fields ( ) Move Field Up inList ( ) Move Field DowninList ( ).
, , Column toSort By( ).
Next () ࠖ Control Selection ( )(.3.26).
.3.26. Control Selection ( )
Data Form Wizard ( )
Available Controls ( ) , :
Add Button ( ),
Edit Button ( ),
Delete Button ( ),
Refresh Button ( ),
Close Button ( ).
, , Next () (.3.27).
.3.27. Data Form Wizard
( )
, Towhat profile do you want tosave your settings? ( ?) .
Finish () .
3.3.
Visual Basic , , - VB Wizard Manager ( Visual Basic).
VB Wizard Manager ( Visual Basic), File New Project (렖 ). New Project ( )(.3.28).
.3.28. New Project ( )
VB Wizard Manager ( Visual Basic) OK.
: No Wizard Form Found! Main Wizard must be called frmWizard. Create aNew Wizard Project? ( ! frmWizard. ?)(.3.29).
.3.29. No Wizard Form Found!
( !)
VB Wizard Manager
( Visual Basic)
(Yes), VB Wizard Manager ( Visual Basic) Save New Wizard As ( )(.3.30).
.3.30. Save New Wizard As
( )
VB Wizard Manager
( Visual Basic)
(File Name) (Save). VB Wizard Manager ( Visual Basic)(.3.31).
.3.31. VB Wizard Manager
( Visual Basic)
VB Wizard Manager ( Visual Basic), (), :
Move All Steps Off Screen ( ),
Add aNew Step tothe Wizard ( ),
Insert aStep Ahead ofthe Current Step ( ),
Move the Current Step Up ( ),
Move the Current Step Down ( ),
Refresh the List ofSteps ( ).
VB Wizard Manager ( Visual Basic). (.3.32).
.3.32. VB Wizard Manager
( Visual Basic)
, , , , :
Delete ,
Edit Name ,
New Wizard ,
Help ,
Show Toolbar .
Refresh (), .
VB Wizard Manager ( Visual Basic) , (.3.33).
.3.33. VB Wizard Manager
( Visual Basic)
Introduction Screen ( ). (.3.34).
.3.34. ,
VB Wizard Manager ( Visual Basic)
. , Visual Basic.
, , , , .
4.
:
Visual Basic,
,
.
4.1.
, , Visual Basic, .
(Syntax) , , . , SetFocus ( ) :
.SetFocus
:
cmdHello.SetFocus
Print (), , :
[.] Print [[] [{;|,}]]
, :
([]) ,
([] ) , ,
, ({|}) , ,
, , .
, Print () :
Print
Form1.Print 1, 2, 3, 4,5
Picture1.Print ; ;
Debug.Print Name: & cmdHello.Name Caption: & cmdHello.Caption
.
4.2. Visual Basic
Visual Basic (Statements), . :
1 2
(Operands) (Expressions) , . , , :
2+2
varX> 4And varX<10
Form1.Caption & " " & Form1.Tag
:
,
,
,
,
.
4.3.
Visual Basic , :
_ = _
"=" , , _ _ .
, , :
Number1 =500
Form1.Caption =
Number1 500. Caption () Form1 ( , ).
, , :
Form1.Caption = : & Form1.Name
Visual Basic , .
4.4.
Ѡ . (.4.1).
.4.1.
, , , :
Print (1+2) *3
. , , . , 1000 Integer () 100000 Long ( ), Long ( ).
4.5.
. : "&" "+. , . .
:
strWelcome = & " " & !
ࠖ !, strWelcome. , . " " , : !.
4.6.
, (.4.2).
.4.2.
True () False (), .
:
bolYesNo = varX>4
bolYesNo varX> 4. varX , True (), 堖 False ().
4.7.
, , Visual Basic (.4.3).
.4.3.
, 蠖 . Boolean ().
Not. , True (), False (), (.4.4).
.4.4.
Not
And . True (), True (), 堖 False ()(.4.5).
.4.5.
And
Or . True (), True ()(.4.6).
.4.6.
Or
Xor Or, , True ()(.4.7).
.4.7.
Xor
Eqv True (), . , Xor(.4.8).
.4.8.
Eqv
Imp , . True (), , True (), 頖 False ()(.4.9).
.4.9.
Imp
4.8.
, , (.4.10).
.4.10. Visual Basic
, .
:
Form1.Visible = 2<> 3And Not 2^ 3> 2+3
, , . , , :
Form1.Visible = (2<> 3) And (Not ((2^ 3)> (2+3)))
5.
:
,
,
, .
5.1.
, . , , . Visual Basic, :
,
,
,
.
, . .
. , 堖 , .
.
5.2. IfThenElse
IfThen Else. , :
If Then [Else _else]
If () . , , :
= True (), Then (),
= False (), Else (), Else () .
IfThen Else:
If 5
If Form1.Width <> 3800Then Form1.Width =3800
If Button = 2Then PopupMenu mnuSelColor Else PSet (X,Y)
IfThen Else, , . :
If Then
[]
[ElseIf -nThen
[_elseif]
[Else
[_else]]
EndIf
, : False (), Else () ElseIf ( ). End If ( ).
, Value () HScrollBar ( ). Value () (HScroll1.Value = HScroll1.Min) (HScroll1.Value = HScroll1.Max) , 堖 :
If HScroll1.Value = HScroll1.MinThen
MsgBox !
ElseIf HScroll1.Value = HScroll1.MaxThen
MsgBox !
Else
varY = varX / HScroll1.Value
EndIf
IfThen Else , , :
If varX> =1And varX <= 1000Then
If varX <500Then
MsgBox 500
ElseIf varX> 500Then
MsgBox 500
Else
MsgBox 500
EndIf
Else
MsgBox !
EndIf
5.3. SelectCase
Select Case IfThen Else, , , , . Select Case :
Select Case
[Case __-n
[-n]]
[CaseElse
[_else]]
End Select
, Select Case, Visual Basic Case (). Case () . , Case ().
, , :
,
,
,
.
Ѡ . To() , :
_ To_
:
1To5
varX TovarX+20
Is (), :
Is _
Case () , True (). :
Is <>0
Is>varX
Case Else ( ) , Visual Basic Case ().
Select Case Mark, , . Mark ( ), .
Select CaseMark
Case1
MsgBox
Case2
MsgBox
Case3
MsgBox
Case4
MsgBox
Case5
MsgBox
CaseElse
MsgBox !
End Select
5.4. GoTo
GoTo , . :
GoTo
, . , . :. :
L2:
Good_Place:
ThisIsLabel800:
, . Ѡ , , GoTo, IfThen Else Do Loop.
GoTo . Visual Basic Basic.
5.5 ForNext
ForNext . :
For = To [Step]
[]
[ExitFor]
[]
Next []
, , .
, Step () . Next.
Exit For, , , .
Exit For , .
, 5:
For i= 1To5
Beep
Nexti
For i , . Next i.
, Next . Beep . .
. , i j:
For i= 100To0Step-10
For j = 1To20
varY = varY * (i/j)
Nextj
If i<20Then ExitFor
Nexti
5.6. For EachNext
, For EachNext . :
For Each In
[]
[ExitFor]
[]
Next []
, MyArray, :
For Each ArrItem InMyArray
Print ArrItem
Next
5.7. DoLoop
Do Loop , , , .
( ):
Do [{While | Until} ]
[]
[ExitDo]
[]
Loop
( ):
Do
[]
[ExitDo]
[]
Loop [{While | Until} ]
( ) , , :
, While ( []), False (),
, Until ( []), True ().
, , , .
Do Loop . ExitDo.
, :
intDig1 =5
Do While intDig1>0
print 100/ intDig1
intDig1 = intDig11
Loop
5.8. With
With , , .
Form1 .
With Form1
.Left =3500
.Top =2500
.Width =4000
.Height =3000
EndWith
6.
:
,
,
.
6.1.
. .
(Procedure) Visual Basic , , , .
:
,
,
.
(Event Procedures) Visual Basic, , . 2 , Click () cmdHello cmdExit.
(General Procedures) . , . , . , .
(Built-In Procedures) Visual Basic. , . , . , , .
(Procedure Call) :
_ [(_)]
(Arguments), (Parameters), , . , , .
, - . :
Sub () ,
Function () .
Sub () . Function () Visual Basic , .
, Sub () , Function () .
:
MySub 5, varX +3, varY /varX
Form1.Caption = Now()
MySub, . Now , , Caption () Form1.
, .
6.2. Sub ()
Sub () Visual Basic, , . :
[{Private|Public}] [Static] Sub ([_])
[]
[ExitSub]
[]
EndSub
Private () , , Public () .
Static () Visual Basic , .
Sub () 堖 , . , .
Exit Sub ( ) , .
Sub () , :
Public Sub Trill (intCount As Integer)
If intCount <1Then Exit Sub intCount <1,
For i= 1TointCount ForNext 1intCount
Beep
Next ForNext
EndSub
, Visual Basic , , .
Visual Basic , Rem. Visual Basic , .
Trill 젖 :
Trill10
, , . , Trill , :
.Trill10
, Static (). , - :
Public Static Sub Proc1 () Proc1
Dim CallCount As Integer
If CallCount> =5Then Exit Sub CallCount> =5
CallCount = CallCount +1 1
-
End Sub
, CallCount. Proc1 - 5- , .
, CallCount .
6.3. Function ()
Function () Sub (). , :
[{Private|Public}] [Static] Function [()] [As]
[]
=
[Exit Function]
[]
End Function
As () , . Function () , , :
Private Function GetValue()
[]
GetValue =3
[]
End Function
Visual Basic , , . , .
Str strTemp:
Dim strTemp As String
strTemp = Str (-19.436)
, , Sub. . , :
MsgBox Now()
Visual Basic. MsgBox , . Now , .
6.4.
Sub () Function () :
(ByRef),
(ByVal).
, . , , ByVal, :
Sub Proc2 (ByVal Arg1)
EndSub
, , . Optional ():
Sub Proc3 (Arg1, Optional Arg2)
EndSub
Optional () , . , . , , .
, :
Proc3 10,15
Proc310
, . , , .
, (:=) .
, Proc3 :
Proc3 10,15
Proc3 Arg1:=10, Arg2:=15
Proc3 Arg2:=15, Arg1:=10
Proc3 . Arg1 Arg2.
7. ,
:
, ,
,
.
7.1.
, Visual Basic, , , , .
(Data Type) , (Bytes), . , . , - .
, Visual Basic , (.7.1).
.7.1. Visual Basic
Boolean () . :
True () , ,
False () .
Byte (), Integer () Long ( ) .
Single ( ), Double ( ), Currency () Decimal (). , Windows. Decimal () , Variant ().
Date ().
String (), .
Object () , .
Variant (), . : Visual Basic .
(Range) (Precision). , , . , .
, 123456789 Long ( ) Double ( ). Single ( ), 2 1,234568E+08, , 123456800 123456789:
Dim Dig1 As Single Dig1 Single
Dig1 = 123456789 123456789
MsgBox Dig1 Dig1
7.2.
, .
Visual Basic. , (.7.2).
.7.2. Visual Basic
, , .
cmdHello_Click .
, Private Sub
.
.
, (https://www.litres.ru/book/evgeniy-matveev-8990/visual-basic-dlya-novichkov-shag-za-shagom-samouchite-19488692/) .
Visa, MasterCard, Maestro, , , , PayPal, WebMoney, ., QIWI , .
- Жанр: Другие справочники, Книги о компьютерах, Прочая образовательная литература, Руководства
- Язык: Книги на русском языке
- Объём: 450 стр. 308 иллюстраций
- Возрастные ограничения: 12+
- ISBN: 9785448304002
- Дата выхода книги: 22 июля 2016
- Версия: 📚 Электронная книга
Для самостоятельного изучения языка Visual Basic, позволяет без помощи преподавателя, «с нуля» разобраться в основах программирования и научиться создавать полноценные приложения для Windows. Большое количество информации о Visual Basic также даёт возможность использовать книгу и в качестве справочника.
Как скачать книгу - "Visual Basic для новичков. Шаг за шагом. Самоучитель / справочник" в fb2, ePub, txt и других форматах?
- Нажмите на кнопку "полная версия" справа от обложки книги на версии сайта для ПК или под обложкой на мобюильной версии сайта
Полная версия книги
- Купите книгу на литресе по кнопке со скриншота
Если книга "Visual Basic для новичков. Шаг за шагом. Самоучитель / справочник" доступна в бесплатно то будет вот такая кнопка - Выполните вход в личный кабинет на сайте ЛитРес с вашим логином и паролем.
- В правом верхнем углу сайта нажмите «Мои книги» и перейдите в подраздел «Мои».
- Нажмите на обложку книги -"Visual Basic для новичков. Шаг за шагом. Самоучитель / справочник", чтобы скачать книгу для телефона или на ПК.
В разделе «Скачать в виде файла» нажмите на нужный вам формат файла:
Для чтения на телефоне подойдут следующие форматы (при клике на формат вы можете сразу скачать бесплатно фрагмент книги "Visual Basic для новичков. Шаг за шагом. Самоучитель / справочник" для ознакомления):
- FB2 - Для телефонов, планшетов на Android, электронных книг (кроме Kindle) и других программ
- EPUB - подходит для устройств на ios (iPhone, iPad, Mac) и большинства приложений для чтения
Для чтения на компьютере подходят форматы:
- TXT - можно открыть на любом компьютере в текстовом редакторе
- RTF - также можно открыть на любом ПК
- A4 PDF - открывается в программе Adobe Reader
Другие форматы:
- Сохраните файл на свой компьютер или телефоне.
Видео по теме - Шаг #1. Excel для Начинающих