.


:




:

































 

 

 

 


, , , .




, . VBA. . , ( ) . , .

/ .

2. VBA1. . .

2.

 

- .

. / . , .

3. / :

Public Sub ()

Dim str As String

str = InputBox (" ", " ", "")

MsgBox Prompt:=str & "! ! "

End Sub

InputBox :

InputBox ( , , )

 

MsgBox , & c . ,

b = 10

MsgBox( b = & b)

- b = 10.

. , , , . .

. . .

3.

4. :

1. .

2. .

3. .

.

4.

8.8. VBA

1 .

 

1
/ VBA
  , . ; Public Sub ImProgram()
  . : a, b, c ; d, k ; mas(5, 5) ; mas1(5,5) ; Dim a, b, c As Single Dim d, k As Integer Dim mas(1 to 5, 1 to 5) As Integer Dim mas(5, 5) As Single
  . (a, b, d, k); a = InputBox( a) b = InputBox( b) d = InputBox( d) k = InputBox( k)
  . (a, b, d, k); MsgBox a & a MsgBox b & b MsgBox d & d MsgBox k & k
  (). c = 2a + √b c:= 2 * a + Sqr(b); c = 2 * a + Sqr(b) (. 1)
  . > 10 := 3*; := + 2*b; - ; If c > 10 Then = 3* Else = + 2*b End If
  . performance=1 Bonus = salary * 0.1 performance=23 Bonus = salary * 0.09 performance>=4 performance<=6 Bonus = salary * 0.07 performance>8 Bonus = 100 Bonus = 0,   performance , Bonus, salary . Select Case performance Case 1 Bonus = salary * 0.1 Case 2, 3 Bonus = salary * 0.09 Case 4 To 6 Bonus = salary * 0.07 Case Is > 8 Bonus = 100 Case Else Bonus = 0 End Select
  . i = 1 10 2; a:= 34/b; c:= √a + 2*c; b:= b + 1; (); i; For i = 1 To 10 Step 2 a:= 34/b; c:= √a + 2*c; b:= b + 1; MsgBox & Next i
  . , . myNum > 10; myNum = myNum 1; counter = counter + 1; ; Do While myNum > 10 myNum = myNum - 1 counter = counter + 1 Loop
  . , . myNum > 10; myNum = myNum 1; counter = counter + 1; ; Do myNum = myNum - 1 counter = counter + 1 Loop While myNum > 10
  . ; End Sub

 

1. VBA Visual Basic : ? / / / Visual Basic / Visual Basic .

 

. . . . .

 

8.9.

Public Sub Massiv() '

'

Dim a, b, c, d As Integer '

Dim mas(4, 4) As Integer '

'

' 4 4

For i = 1 To 4 ' i,

For j = 1 To 4 '

' InputBox

' InputBox

 

mas(i, j) = InputBox (" mas(" & i & ", " & j & ")",, 10)

 

Next j ' j

Next i ' i

'

b = mas(1, 1) ' b mas(1,1)

For i = 1 To 4

For j = 1 To 4

If mas(i, j) > b Then '

b = mas(i, j) ' b

c = i '

d = j '

End If

Next j

Next i

' MsgBox

 

MsgBox " mas(" & c & ", " & d & ")" & ", " & b

End Sub '

 

8.10.

. VBA , , . Word. :

1

VBA Y, :

;    

 

x .

 

2

,

:

 

VBA x y A1, B1, C1, A2, B2, C2, .

3

VBA (), A 1 :

). X ]0;1[

4

VBA Y, :

X Z .

5

X A B.

8.11.

.

Do...Loop: , True True

Sub ChkFirstWhile()

counter = 0

myNum = 20

Do While myNum > 10

myNum = myNum - 1

counter = counter + 1

Loop

MsgBox " " & counter & " ."

End Sub

For...Next: . .

For Each...Next:

Sub TwosTotal()

For j = 2 To 10 Step 2

total = total + j

Next j

MsgBox " " & total

End Sub

. .

 

Public Sub ()

Dim strImya As String

Dim i, a As Integer

For a = 1 To 5 Step 1

strImya = InputBox(" - ")

MsgBox (strImya & "! ! ! ")

Next a

End Sub

 

1.

 

Public Sub ()

Dim strImya As String

Dim i, a As Integer

a = 5

Do While a >= 1 '

a = a - 1

strImya = InputBox (" - ")

MsgBox (strImya & "! ! !")

Loop

End Sub

 

:

Public Sub ()

Dim strImya As String

Dim i, a As Integer

a = 5

Do

a = a - 1

strImya = InputBox (" - ")

MsgBox (strImya & "! ! !")

Loop While a >= 1 '

End Sub

. .

 

6

VBA, :

). :

7

, Y=f(x) X1, X2,...,Xn:

).

8

. , Y=f(x) . , .

) =-2, =8, D=2.

9

, n {Ai}, i=1,2,.....,n :

) i

 

 

8.12.

- .

:

) Word.

) i , i- , - .

) / / VBA, .1.

.

 

. 1.

) / / VBA VBA.

VBA ( , , ).

/ UserForm .

( . 2.).

.

. 2.

) , .

: - VBA .

) Word.

, , ( . 3.).

:

. 3.

) , VBA.

( Public) VBA ( .4.)

VBA, .

. 4.

Word :

. VBA 33i (i- ) "4", 1, .

 

:

, :

Private Sub Document_Open()

Load UserForm1

UserForm1. Show

' 5

UserForm1.TextBox1.SelStart = 5

'

UserForm1.TextBox1.SetFocus

End Sub

Public Sub 1()

Call Document_Open

End Sub

Private Sub CommandButton1_Click()

UserForm1. Hide

End Sub

 

Private Sub CommandButton2_Click()

'

TextBox1. SelStart = 0

' .

TextBox1. SelLength = Len (TextBox1.Text)

'

TextBox1. SetFocus

End Sub

 

Private Sub CommandButton3_Click()

'

'

TextBox2.Text = Val (TextBox1.Text) * 10

End Sub

. VBA 33i (i- ) "6", 1, . VBA. ThisDocument , :

Public Sub ()

UserForm2.Show

End Sub

. ! Word, VBA.

1 . . . , 10 : Value? Caption? ScrollBar1? Label1.Caption? . . . .

Dim Var1 As Integer

Private Sub ScrollBar1_Change()

' ,

Label1.Caption = Trim$ (Str$ (ScrollBar1.Value))

Var1 = ScrollBar1.Value

Label2.Caption = Trim$ (Str$ (Var1 * 8))

End Sub

2 , , .

Private Sub CheckBox1_Click()

If CheckBox1.Value = True Then

Label1.Visible = True

Else

Label1.Visible = False

End If

End Sub

Private Sub SpinButton1_Change()

CheckBox1.Caption = " "

Label1.Font.Size = 26

SpinButton1.Min = 3

SpinButton1.Max = 60

TextBox1.Font.Bold = True

TextBox1.Font.Size = 26

TextBox1.AutoSize = True

TextBox1.Value = SpinButton1.Value

Label1.Caption = SpinButton1.Value * 100

End Sub

, , . :

1. - CheckBox1, Label1, TextBox1, SpinButton1?

2. , 26 ?

3. SpinButton1.Max = 60?

4. ?

5. ? (Size- )

6. ?

7. ?

8.13.

. VBA 33i (i- ) "8", 1. VBA. ThisDocument , :

Public Sub ()

( )

End Sub

. ! Word, VBA.

. 8 , , Word Art. :

1. , , .

2. .

3. .

4. , : - Word Art ; - .

5. , Word Art . , , (AddTextEffect(msoTextEffect16, UserForm1.TextBox2.Text, "Arial",).

Word Art .


 





:


: 2017-02-25; !; : 554 |


:

:

, .
==> ...

1668 - | 1487 -


© 2015-2024 lektsii.org - -

: 0.166 .