.


:




:

































 

 

 

 


IV




:

1 Run→Run Sub/UserForm. VBA. .

2 1, , ( ).

3 Tab 2. 2.

4 2.

5 3.

6 <>. .

7 , , 1 .

8 .3-7 .. , <End>. , VBA .

V

2. .

. , .

:

1 Visual Basic . , , 33.

 

 

33

 

2 Properties , 26.

26

Caption
Caption
Name TextBox1
Caption
Name TextBox2
Caption
Name TextBox3
Name Caption CommandButton1
Name Caption CommandButton2

 

3 , 34:

 

 

34

 

4 .

- <F5>;

- 1000;

- 25;

- .

. .

 

8

: , , . 8 1 (4 ).

 

3.2 VBA

 

VBA : .

 

3.2.1 (MsgBox)

 

, , , Integer, , .

. , , . , . .

MsgBox MsgBox (). , , .

MsgBox:

MsgBox < > [, ] [, ]

 

MsgBox ():

= MsgBox ( [, ]

[, ]

, , MsgBox ();

MsgBox /;

- , ( );

, , ( ) ;

, ( );

. 27.

 

27 - MsgBox,

vbCritical Critical message ( ) , .
vbExclamation Warning message () ,
vbQuestion Query () ,
vbInformation Information message ( ) . .

 

MsgBox () , 28. Options.

 

28 - MsgBox,

<OK>   vbOKOnly
<>, <>   vbOKCancel
<>, <>, <>   vbAbortRetryIgnore
<>, <>, <>   vbYesNoCancel
<>, <>   vbYesNo
<>, <>   vbRetryCancel

 

, Options , , +. 27, 28. , , , .. , [Enter] (, ). Options 29.

( 30).

, , , .

 

29 - MsgBox,

  vbDefaultButton1
  vbDefaultButton2
  vbDefaultButton3
  vbDefaultButton4

 

30 - , MsgBox

<OK>   vbOK
<>   vbCancel
<>   vbAbort
<>   vbRetry
<>   vbIgnore
<>   vbYes
<>   vbNo

 

1.

. <> <>. <> <Command1> , <> .

:

1 VBA.

2 . CommandButton . <CommandButton1>.

3 <CommandButton1> Private Sub End Sub :

Private Sub CommandButton1_Click()

Dim A As Long

A = MsgBox (" ", vbInformation + vbYesNo, "")

If A = 6 Then

CommandButton1.Caption = ""

ElseIf A = 7 Then

CommandButton1.Caption = ""

End If

End Sub

.

MsgBox , <Yes> <No> .

6.

, , <Yes>, Caption () <CommandButton1> .

6, , 7, <No>, 7.

7, .

.

4 , 35.

 


35

 

3.2.2

 

- ( , , ..), .

, , Cancel.

<> <>,

<>, String, .

<>, (Empty) , .

:

= InputBox ( [, ] [, ] [, xPos] [, yPos])

, ,

InputBox ();

InputBox ;

,

;

,

;

,

;

xPos, yPos

( ).

2.

. .

:

1 VBA.

2 . CommandButton . <CommandButton2>.

3 <CommandButton2> Private Sub End Sub :

Private Sub CommandButton2_Click()

A = InputBox (" ", " ")

If A <> " " Then

CommandButton2.Caption = A

Else

CommandButton2.Caption = " "

End If

End Sub

.

.

.

- , .. , <OK> <CommandButton2> .

( 4) <CommandButton2> .

4 , 36.

 

36

9

VBA

: VBA. 9 31 (2 ).

31

VBA
 
       
  Caption 1
(CommandButton1) Caption , ,
(CommandButton2) Caption , , , , ,
(Image1) Picture , Paint

31

       
  Caption 2
(CommandButton1) Caption
(CommandButton2) Caption , , , ,
(Image1) Picture , Paint
  Caption 3
(CommandButton1) Caption ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 4
(CommandButton1) Caption ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 5
(CommandButton1) Caption ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint

 

 

31

       
  Caption 6
(CommandButton1) Caption ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 7
(CommandButton1) Caption
(CommandButton2) Caption , , \ͻ
(Image1) Picture , Paint
  Caption 8
(CommandButton1) Caption ,
(CommandButton2) Caption , , ,
(Image1) Picture , Paint
  Caption 9
(CommandButton1) Caption , ,
(CommandButton2) Caption , , , ,
(Image1) Picture , Paint
  Caption 10
(CommandButton1) Caption , ,

 

31

       
  (CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 11
(CommandButton1) Caption
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 12
(CommandButton1) Caption ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 13
(CommandButton1) Caption , ,
(CommandButton2) Caption , ,
(Image1) Picture , Paint
  Caption 14
(CommandButton1) Caption , ,
(CommandButton2) Caption , , , /ͻ
(Image1) Picture , Paint

31

       
  Caption 15
(CommandButton1) Caption ,
(CommandButton2) Caption , , ,
(Image1) Picture , Paint
  Caption 16
(CommandButton1) Caption , ,
(CommandButton2) Caption , , ,
(Image1) Picture , Paint
  Caption 17
(CommandButton1) Caption ,
(CommandButton2) Caption , , ,
(Image1) Picture , Paint
  Caption 18
(CommandButton1) Caption ,
(CommandButton2) Caption , , , ,
(Image1) Picture , Paint
  Caption 19
(CommandButton1) Caption , ,

 

31

       
  (CommandButton2) Caption , , ,
(Image1) Picture , Paint
  Caption 20
(CommandButton1) Caption
(CommandButton2) Caption , , , ,
(Image1) Picture , Paint

 

3.3 VBA: -, ,

 

-. OptionButtons () . , ( , ). , . Aligment 0 1 , . Value True False , . , . Value True, False.

(). CheckBox () , . : , . . . R ().

, Value, : 0 ( ), 1 (), 2 (). 2 .

TripleState, . TripleState :

- False ( True False, .. );

- True ( True, False, Null, .. , ).

. Frame () . , -. - , . , , -. . Caption , .

1.

. , . . <>. , . () . <END>. , 37.

 

 

37 ,

()

 

:

1 :

a, b Î Z

= 2; b = 4

: Min (Max) Î Z

2 .

, 32.

 

32 -

1. 18
2. 18
3. 2

 

, , , , , , , ().

Properties Name Caption , 33.

 

33

Name TextBox1
Name TextBox2 b
Name TextBox3 1
Name TextBox4 2
Name TextBox5 3
Name TextBox6
Name TextBox7
Caption Label1
Caption Label2
Caption Label3 b
Caption Label4 Y1
Caption Label5 Y2
Caption Label6 Y3
Caption Label7
Name Caption CommandButton1
Name Caption CommandButton2 End
Caption Frame
Name Caption OptionButton1
Name Caption OptionButton2
  CheckBox1 3-

 

3 , 38.

 

 

38

 

4 .

2. .

. . , 500 . 20 . 60000 . 8% . , .

 

39 .

 

34

Caption
Caption
Name TextBox1
Caption ,
Name TextBox2
Caption
Name TextBox3
Caption ,
Name TextBox4
Caption
Name TextBox5
Name Caption CommandButton1
Name Caption CheckBox1

:

1 , , , 39.

2 Properties Name Caption , 34.

3 PV: PV (0.08/12, 12*20, 500,, 0), -59 777,15 .

, , . (59777,15 .) , (60000 .). , , .

, PV (0.08/12, 12*20, 500,, 1) 60 175,66 . , , .

4 , 40.

 

 

40

 

. , : , , : . , , .

5 .

 

10

: -, ,

: VBA - -, , . 35 (2 ).

 

35

VBA : -, ,
  ; x=-1.23
  x, y, z. : ;  
  x, y, z. :
  ; b=0.251, x=0.004
  ; x=1.14
  ;
  ; x=0.15394

35

  ; a=1.618, b=0.992, x=0.018
  ; y=0.1465, x=2.3864
  ; a=0.647, b=1.546, x=1.667
  ; a=0.361, x=0.852
  ; c=0.983, x=0.89
  ; a=0.185, b=0.256, x=0.246
  ; x=0.29
  ; a=0.357, b=0.128, x=0.634
  ; x=0.324, a=0.421, b=0.722

 

 

35

  ; = 0.256, b = 0.147
  ; = 0.504, = 0.112
  ; = 0.125, b = 1.320, x = 1.257
  ; = 0.849, = 0.560

 

3.4 VBA:

 

ScrollBar ( ) , , . , . , , , .

Change, . 36 , .

36 -

Value
Min
Max
SmallChange . , Value .

36

LargeChange
Orientation . : - fmOrientationAuto -1 ( . ); - fmOrientationVertical 0 ( ); - fmOrientationHorizontal 1 ( )

SpinButton () , , , . Value, Min, Max, SmallChange, .

1.

. , . () ( » ..) , .

 

 

41

 

<>. <END>. , 41.

:

1 :

i, k Î Z

a Î R, a = 2,71

: P Î R.

2 , 37.

 

37 -

1. 18
2. 12
3. 2

3 Properties Name Caption , 38.

 

38

Caption
Caption
Name TextBox1
Caption i
Name TextBox2
Name SpinButton1
Caption i
Name TextBox3
Name SpinButton2
Caption k
Name TextBox4
Name ScrollBar1
Caption k
Name TextBox5

 

38

Name ScrollBar2
Caption
Name TextBox6
CommandButton1
END CommandButton2

4 , 42, 42, 42.

 

 

42 ʻ

 

42 End, 1 (2),

1, ( 2),

 

:

1 ScrollBar1_Change () (ScrollBar2_Change ()), SpinButton1_Change () (SpinButton2_Change ()).

2 TextBox2_Change () (TextBox3_Change (), TextBox4_Change (), TextBox5_Change ()).

Change ( ), k, k, i, i.

k, k, i, i . , , . , Change k, k, i, i. , .

 

 

42 i,

i, k, k

 

2. .

. , 18 50000 . . , 6% , ?

:

1 , , , , , 43.

2 Properties Name Caption , 39.

 

 

43

 

39

Caption
Caption
Name TextBox1
Caption ,
Name TextBox2
Caption ,
Name TextBox3
Caption
Name TextBox4
Name Caption CommandButton1
Name SpinButton1

3 Pmt.

Pmt (0.06/12, 18*12, 0, 50000), -129,08 .

, 129,08 .

4 , 44.

. : SpinButton1_Change TextBox2_Change. Change , , .

 

 

44

 

, . , , . , Change , .

, .

5 .

11

: ,

: - , . 11 4 (2 ).

 

3.5 VBA:

 

ListBox () . , . . - , . 40 .

40 -

ListIndex . . , -1
ListCount
TopIndex
ColumnCount
TextColumn , Text
Text
List , . : List (row, column) Row Column -
RowSource ,
ControlSource (),
MultiSelect . : fmMultiSelectSingle 0 ( ); fmMultiSelectMulti 1 ( , , <>); fmMultiSelectExtended 2 ( <Shift> )
Selected , True, , False . , MultiSelect fmMultiSelectMulti fmMultiSelectExtended
ColumnWidths . : ColumnWidths = String String , . : With ListBox1 .ColumnCount = 3 .ColumnWidths = 20:30:30 End With

40

ColumnHeads , ,
ListStyle . : fmListStylePlain 0 ( ); fmListStyleOption 1 ( , )
MathEntry . : fmMathEntryFirstLetter 0 ( . , , ); fmMathEntryComplete 1 ( ); fmMathEntryNone 2 ( )
BoundColumn , Value. : 0 ( Value , .. ListIndex); 1 ( Value , , BoundColumn)

 

3.5.1

 

Clear, RemoveItem AddItem.

Clear .

RemoveItem .

:

RemoveItem (index)

index .

. , RowSource.

AddItem .

:

AddItem ([item [, varIndex]])

item ( ) ;

varIndex .

AddItem , .

1.

. , . .

:

1 Properties Name Caption , 41.

 

41

Caption
Name Caption
Name Caption
Name Caption
Name ListBox1

2 , 45.

3 ( 46).

. Add . Remove , Clear .

 

3.5.2

 

ColumnCount, , . , ColumnWidths, . , .

, sin (x) b h, ( ) .

1.

. , sin (x). , , , 47.

 

45

 

 

46

 

 

47 sin (x)

 

:

1 Properties Name Caption , 42.

 

42

Caption sin (x)
Caption
Name TextBox2
Caption b
Name TextBox3
Caption h
Name TextBox4




:


: 2016-10-07; !; : 455 |


:

:

, , 1:10
==> ...

962 - | 933 -


© 2015-2024 lektsii.org - -

: 0.295 .