Subプロシージャの呼び出し(引数有)

Subプロシージャの呼び出し(引数有)
呼び出し側
呼び出される側
Sub プロシージャA ( )
Sub プロシージャB (引数 As 型)
:
:
1
2 処理
プロシージャB 引数
:
:
End Sub
3 End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
引数の渡し方

参照渡し
引数の値を呼び出される側で変更すると
→呼び出し側の変数の値に影響を与える

値渡し
引数の値を呼び出される側で変更すると
→呼び出し側の変数の値に影響を与えない
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ Inp a, b
④ c=a+b
⑤ Out c
⑥ End Sub
⑦ Sub Inp(x As Single, y As Single)
⑧ x = Val(TextBox1.Text)
⑨ y = Val(TextBox2.Text)
⑩ End Sub
⑪ Sub Out(z As Single)
⑫ TextBox3.Text = Str(z)
⑬ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub
① Private Sub CommandButton1_Click()
② Dim a As Single, b As Single, c As Single
③ a = Val(TextBox1.Text)
④ b = Val(TextBox2.Text)
⑤ Add a, b, c
⑥ TextBox3.Text = Str(c)
⑦ End Sub
⑧ Sub Add(x As Single, y As Single, z As Single)
⑨ z=x+y
⑩ End Sub