Array | Variant : Array(), , . : Dim A AsVariant A = Array(-12, 34, 89, 90, -45, 7.9) ; DimAsVariant = Array(" ", " ", " ", " ", " ", " ", " ") , . |
IsArray | Variant . True, False, . : IsArray(), Variant : Dim X As Variant If IsArray(X) Then MsgBox X - . |
Lbound Ubound | . , VBA. . : Lbound( [, ]) Ubound( [, ]), (Lbound) (Ubound) ; , , . 1, 2 . . , 1. : Dim As Range Dim x() Set = Sheets(" 1 ").Range(" a2 ").CurrentRegion x = MsgBox " = " &UBound(x, 1) MsgBox " = " &UBound(x, 2) |
9. . , .
Sub _1()
Dim x As Range, A() As Integer, S() As Integer
Set x = Range(" A1 ").CurrentRegion
A = Range(x.Address)
ReDimS(LBound(A, 1) To UBound(A, 1))
For i = LBound(A, 1) To UBound(A, 1)
S(i) = 0
For j = LBound(A, 2) To UBound(A, 2)
S(i) = S(i) + A(i, j)
Next j
Cells(i, UBound(A, 2) + 2) = S(i)
Next i
EndSub
: Set x , . Address Range . ReDim S. Lbound() Ubound() . . j, i.
|
|
10. , . .
Sub _2()
Dim x AsVariant
Dim i AsByte, j AsByte, d AsInteger
x = Array(-3, 23, 90, 1, -17, 89, -51, -8, 0, 167)
Range(" A1 ") = " : "
For i = LBound(x) To UBound(x)
Cells(i + 1, 1) = x(i)
Next i
For i = LBound(x) To UBound(x)
For j = LBound(x) To UBound(x) - 1
If x(j) * x(j + 1) < 0 And x(j) >0 Then d = x(j): x(j) = x(j + 1): x(j + 1) = d
Next j
Next i
Range(" B1 ") = " : "
For i = LBound(x) To UBound(x)
Cells(i + 1, 2) = x(i)
Next i
EndSub
: : (.., ), (?), . , , .