.


:




:

































 

 

 

 





. MsgBox , - , - . " ", .

. MsgBox , - , - . " ", .

 

 

, () , .

, , . , "".

, VBA . .

 

 

. , - . , , , . .

MsgBox :

 

MsgBox (Prompt [, Buttons] [, Title] [, HelpFile, Context])

 

Prompt, , . - .

Title - .

HelpFile - , Windows ( ).

Context - , , .

Buttons - , . , Windows .

InputBox

InputBox - .

InputBox :

 

InputBox (Prompt [, Title] [, Default] [, XPos] [, YPos] [, HelpFile, Context])

Prompt ( ), Title, HelpFile, Context - MsgBox.

Default - , .

XPos, YPos - . . XPos - . YPos - . (1 = 1/20 = 0,0007 ). , .. "" .

InputBox , , .

 

InputBox .

VBA

VBA.

N - . , .

()
Abs(N) N
Atn(N) N ()
Cos(N) N ()
Exp(N) ( = 2.718282...), N
Int(N) N. , . N , , N
Log(N) N
Rnd(N) : .
Sgn(N) : -1, N - ; 1, N - ; 0, N 0
Sin(N) N ()
Sqr(N) N. N -
Tan(N) N ()

 

VBA

, VBA - VBA () , End Sub (End Function). -:

, , . -:

 

 

, - , .

If..Then; If..Then..Else. ( -), ( -) , True False.

 

IF..THEN

1:

If Condition Then Statements

2:

If Condition Then

Statements

End If

Condition - ;

Statements - , VBA.

 

, Statements , .

.

: VBA , Condition; True () Statements; VBA If..Then ( 1) End If ( 2). False, Statements , .

If..Then:

- :

 

, Statements ( ). . - .

If..Then..Else

 

1:

If Condition Then Statements Else ElseStatements

 

2:

If Condition Then

Statements

Else ElseStatements

End If

 

Condition - ;

Statements, ElseStatements - , VBA.

If..Then - , Statements ElseStatements , .

.

: VBA , Condition; True () Statements; VBA If..Then ( 1) End If ( 2). False, ElseStatements.

, If..Then..Else ( 2) . , , Statements ElseStatements .

If..Then..ElseIf..End If:

 

:

If Condition Then

Statements

ElseIf Condition1 Then

Statements1

.

ElseIf ConditionN Then

StatementsN

Else

ElseStatements

End If

: VBA , Condition; True () Statements; VBA End If. False, Condition1; True () Statements1; VBA End If. Condition2 .. ConditionN; True () StatementsN; VBA End If. False, ElseStatements.

Sub sample3()

Dim value As Long

Const MSG = " , "

value = InputBox(prompt:=" ", Title:=" 4")

If value = 0 Then

MsgBox (MSG & " 0")

ElseIf value > 0 Then

MsgBox (MSG & " 0")

Else

MsgBox (MSG & " 0")

End If

End Sub

 

 

VBA

.

, , .

, , . . .

, " ".

.

For..Next

For counter = Start To End [Step StepSize ]

Statements

Next [ counter ]

Counter - VBA

Start - , counter

End - , counter

Statements - , VBA ( ).

VBA counter 1 . (SterSize - ), counter.

Next VBA , . counter Next counter, For .

For..Next, 1 10:

For..Next :

! For..Next , , , , .

For Each..Next

For Each..Next . For Each..Next , , ( ). , For Each..Next .

:

For Each Element In Group

Statements

Next [ Element ]

Element - ,

Group -

Statements - , VBA ( ).

For Each..Next , .

SheetExists, For Each..Next , Excel:

Do.. While

, .

:

Do While Condition

Statements

Loop

Condition -

Statements - , ,

Loop - , , VBA

VBA , Condition, True.

Do While (Condition); True - . Loop . , False. False - , Loop.

! False Do While, , Loop, , . , Do While .

Do While, 1 10:

Do.. Until

, .

:

Do Until Condition

Statements

Loop

Condition -

Statements - , ,

Loop - , , VBA

VBA , Condition, False.

Do Until Do While.

, Do Until 1 10, :

, , Loop, .

 

Do.. Loop While

, .

:

Do

Statements

Loop While Condition

Condition -

Statements - , ,

Loop While - , , VBA

VBA , Condition, True.

Do Loop While , Loop (Condition); True - . , False. False - , Loop While...

! Do Loop While False . , , Condition, , , .

, Do Loop While 1 10, :

Do.. Loop Until

, .

:

Do

Statements

Loop Until Condition

Condition -

Statements - , ,

Loop - , , VBA

VBA , Condition, False.

Do Loop Until Do Loop While.

, Do Loop Until 1 10, :

, , . .

. . .

:

For..Next ;

For Each..Next element-;

Exit For Exit Do , . VBA .

For..Next:

VBA

- , . , , . , , .

. .

- , . :

 

, , , , , , , , ,

 

, 10 .

My_Array.

0. .

, , , . . : My_Array(3) - "" ( , 0).

(.. 1, 0), VBA , "": Option Base.

:

Option Base 0 - 0 ( )

Option Base 1 - 1

 

, . Option Base . Option Base , , .

. , Excel. . , ( ) , ( ) - . . , . VBA , 60 .

, , . My_Array, 10 .

, , , . .

, .

Dim :

Dim VarName ([ Subscripts ]) [As Type ]

VarName - , ;

Subscripts - . , Subscripts .

Subscripts :

[ lower To] upper [,[ lower To] upper ]..

Lower - ( );

upper - ( ).

:

Dim Array_Str (1 To 10) As String- , 10 ;

Dim Array_Var() - ;

Dim Array_Mult (0 To 5, 0 To 7) As Integer - , 6*8=48 .

, Subscripts , Subscripts , Option Base .

, , .

( ):

:

 





:


: 2016-11-24; !; : 451 |


:

:

- - , .
==> ...

1937 - | 1890 -


© 2015-2024 lektsii.org - -

: 0.12 .