Functionプロシージャの呼び出し

Functionプロシージャの呼び出し
呼び出し側
Sub プロシージャA ( )
:
呼び出される側
1
変数=プロシージャB(引数)
:
End Sub
Function プロシージャB( 引数 As 型)As 型
:
2
プロシージャB=処理
:
3
End Function
呼び出し側の引数のカッコについて

引数有のSubプロシージャ
引数にカッコを付けない

戻り値を利用するFunctionプロシージャ
引数にカッコを付ける

戻り値を利用しないFunctionプロシージャ
引数にカッコを付けない
①
②
③
④
⑤
⑥
⑦
Private Sub CommandButton1_Click()
Dim a As Single, b As Single, c As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Add(a, b)
TextBox3.Text = Str(c)
End Sub
⑧ Function Add(x As Single, y As Single) As Single
⑨ Add = x + y
⑩ End Function
①
②
③
④
⑤
⑥
⑦
Private Sub CommandButton1_Click()
Dim a As Single, b As Single, c As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Add(a, b)
TextBox3.Text = Str(c)
End Sub
⑧ Function Add(x As Single, y As Single) As Single
⑨ Add = x + y
⑩ End Function
①
②
③
④
⑤
⑥
⑦
Private Sub CommandButton1_Click()
Dim a As Single, b As Single, c As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Add(a, b)
TextBox3.Text = Str(c)
End Sub
⑧ Function Add(x As Single, y As Single) As Single
⑨ Add = x + y
⑩ End Function
①
②
③
④
⑤
⑥
⑦
Private Sub CommandButton1_Click()
Dim a As Single, b As Single, c As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Add(a, b)
TextBox3.Text = Str(c)
End Sub
⑧ Function Add(x As Single, y As Single) As Single
⑨ Add = x + y
⑩ End Function
①
②
③
④
⑤
⑥
⑦
Private Sub CommandButton1_Click()
Dim a As Single, b As Single, c As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
c = Add(a, b)
TextBox3.Text = Str(c)
End Sub
⑧ Function Add(x As Single, y As Single) As Single
⑨ Add = x + y
⑩ End Function