v = 3.14 * h * r ^ 2
End Function
, , , .
, 10 3 5 :
Dim vol As Single
vol = v(10, 3) + v(10, 5)
MsgBox & vol & 3
, ByVal , , , , ByRef.
, , VB . . , . , ByVal . VB .
, :
Function F(ByVal x As Single, n As Integer) As Single
F (Single), : x (Single), , n − (Integer), .
7.1. F (k) k: k! = 1 * 2 * 3 * * k.
:
Function F(k)
Dim i As Integer
F = 1
For i = 2 To k
F = F * i
Next i
End Function
= ! N!/ (M + N)! :
Sub CommandButton1_Click()
Dim As Single
Dim N As Integer, M As Integer
M = Val(InputBox(" "))
N = Val(InputBox(" N"))
C = F(M) * F(N) / F(M + 1)
MsgBox C
End Sub
Excel , VBA . , Excel . Excel .
VBA / (Insert/Module) .
|
|
7.2. , sin(x), x . :
Function MySin(x As Single) As Single
'
Const pi As Single = 3.14159
Dim y As Single
' x
y = (x / 180) * pi
MySin = Sin(y)
End Function
, .
.