.


:




:

































 

 

 

 





 

If - Then - Else

If - Then - Else .

 

.

( 1).

Sub AAAAA()

Dim x As Double

Dim y As Double

x=1.5

y=0

If x>= 7 Then y= exp (x)

Else y =cos (x)

End If

End Sub

 

  ,  

( 2).

Sub AAAAA()

Dim x As Double

Dim y As Double

x=1.5

If x< 7 Then y =cos (x)

If x>= 7 Then y= exp (x)

MsgBox y

End Sub

41) VBA: For Next:

For - Next ;

Option Base 1 Sub BBBB() Dim V(5) As DOUBLE Dim S As DOUBLE Dim i As Integer Dim n As Integer n=5 S = 0 For i = 1 To n Step 1 V (i) =i S = S + V (i) MsgBox V (i) Next MsgBox S End Sub

 

Step , .

 

42) VBA: While Wend:

 

While - Wend , ;

While - Wend .

. , M = 7

Sub CCCC() Dim M As Integer Dim n As Integer M = 0 n=0 Randomize While M <> 7 M = Int(10 * Rnd()) n = n + 1 Wend MsgBox "n="&n End Sub  

 

43) VBA: Do Loop

Do - Loop , ;

, . , . , , , .

. ( 7) .

1.

Sub DoWhileLoop()

Dim Number As Integer

Number = 0

Do While Number <> 7

Number = Int (10 * Rnd ())

Loop

MsgBox "Your number is " & Number & "."

End Sub

 

2.

Sub DoUntilLoop()

Dim Number As Integer

Number = 0

Do Until Number = 7

Number = Int (10 * Rnd ())

Loop

MsgBox "Your number is " & Number & "."

End Sub

44) VBA: Select Case

Select Case ;

45) VBA With:

 

.

With

[]

End With



. .

. , .


With , . , , , With, , , . With .

With MyLabel

.Height = 2000

.Width = 2000

.Caption = " MyLabel"

End With

With . , With .
With . , With , With With.
With. With End With, .


With . MyObject .

With MyObject

.Height = 100 ' MyObject.Height = 100.

.Caption = "" ' MyObject.Caption = "".

With.Font

.Color = Red ' MyObject.Font.Color = Red.

.Bold = True ' MyObject.Font.Bold = True.

End With

End With

46) VBA.

. , . / / / . . ( , , , ).

 

   

. 24. : 1, 2

, . ― (Private Sub CommandButton1_Click()) . Excel, .

 

47) Excel VBA?

 

C Worksheets.

x = Worksheets(1).Range("A1").Value ( 1);

 

 

48) VBA Excel?

 

Worksheets(1).Range("A1").Value = a, .

49) VBA?

Worksheets(1).Range("A1:B2").Value = 10 ( , 10);

 

50) VBA Excel?

 

Worksheets(1).Cells(i + 1, 2).Value = x(i)

x(i) = Worksheets(1).Cells(i + 1, 2).Value

 

 

  ,

 

 

 


 


 

 


 

 

 





:


: 2016-11-12; !; : 262 |


:

:

, , .
==> ...

1777 - | 1457 -


© 2015-2024 lektsii.org - -

: 0.022 .