- , ,
, , , ,
.;
( ) – ;
;
– , ;
- , ,
;
– , VBA;
)
.
VBA , Excel 5.0,
:
. . 19.1);
.
VBA
Excel 5.0.
,
– .
.
.
Visual Basic ( . 19.20).
. 19.20.
( ):
> - ;
> - ;
> – , ,
.
:
> - ;
> – ( – );
> – ;
> – ;
> – .
:
> – ( ) ;
> – VBA ;
> – VBA;
> - VBA .
VBA.
( ), VBA Excel 5.0, . 19.3.
1 9 . 3 . VBA Excel 5.0
|
|
Sheets |
|
Workbooks |
|
Worksheets |
|
Charts |
|
Range |
( , , , |
|
) |
: 1)
19.5.
Workbooks(" ").Worksheets(2)
2)
19.6.
Workbooks (" ").Worksheets (" a")
:
Count – ;
Name – ;
Parent – , .
Add Delete.
Range :
1.Cell – ,
– Cell ( 1; 2)
19.7.
Cell(l;2).Value=5
2
5;
Cells(2, l).Formula= "=SUM(B1:B5)"
2
1: 5.
2. Range – ,
1:
Range ("A2";"G10")
Range ("f4")
.
19.8.
Worksheets("PRIMTR"). Range("A10"; "F12").Value=10
10. Range("D15").Value = "Test"
"Test". Range("Criteria").ClearContents
.
.
Range(Cells(1; 1); Cells(2; 2)).
3. Offset – ,
.
.
19.9.
Selection.Offset(2, 5). Select
, , 1,
F3.
[" "] – .
4. Union – – Union ( 1; 2).
Range.
19.10.
Union(Range(Cells(l; l);Cells(2; 2)); Range(Cells(5; 5); Cells(7; 7)).Select
: 1: 2, E5:G7.
VBA 11 ( . 19.4).
Boolean 2 , 16 , ;
: True False.
Integer 2 , 1
, 15 – .
Long 4 , 32 , ,
1 – , 31 – .
Single 4 ( – 7
) ).
Double 8 ( 15 ) . Currency 8 , 4 5 ,
.
Date 8 .
, – .
String 1 1 1 .
ANSI.
Object 4 Visual Basic. Array .
Variant , ;
.
1 9 . 4 . VBA
. 19.21. VBA
, , .
.
.
( ,
Var0 ).
19.12. var4, var5
. var2 1 2.
(
, ).
, var1 – 1 var3 – 2,
.
var1 1,
2; var3 3.
:
Dim <var> As <type>, <var> As <type>, <var> As <type>, ....
Public <var> As <type>, <var> As <type>, <var> As <type>, ....
<var> – ;
<type> – .
– , ,
. :
Dim <Arr> ( ) As <type>
Public <Arr> ( ) As <type>
19.13.
,
, , : [Private | Public] Type <typename>
<elementname1> As <type>
<elementname2> As <type>
...
End Type
<typename> |
– ; |
< elementname> |
– . |
Dim Public ,
. , .
19.14.
Type Student
FullName As String *20 Group As Single BirthDay As Date Hight As Integer ...
End Type
Dim Student_Card (1 To 1000) As Student
Student Student_Card 1000 ,
: , , , , .
– ,
,
.
:
Const <const> = < >
<const> – ; < > – .
:
Public:
Public Const Datel=#12.12.96#
:
Const Date2=# 12.12.97#
, –
.
VBA ,
vb. Excel 5.0 , xl.
VBA
,
, .
:
<var>= <formula>
<var> – ; <formula> – .
"=" ,
. , , .
19.15.
Place="d:\windows\system"
File="GameTree.Exe" Student_Card( 100).Group= 133
– .
VBA , .
( ) ( . 19.5).
1 9 . 5 . VBA
For therow = 1 To numrows |
|
|
r-Next, |
|
|
|
|
|
For thecol = 1 To numcols |
|
|
|
Selection.Cells(therow; thecol).Value |
= |
|
|
|
Rnd |
|
|
|
|
|
Selection – |
|
|
|
Cells – |
|
|
|
|
Value – |
|
|
" " |
|
Next thecol |
|
|
|
Next therow |
|
|
|
End Sub |
|
|
|
VBA ( ).
–
VBA.
: Sub < > )
..................................
( )
..................................
End Sub
Sub - , , ,
. Sub End Sub.
– VBA.
,
,
. ;
, . « » ( . 19.22)
.
. 19.22.
< >
, , ,
.
.
4 :