Skip to content

Instantly share code, notes, and snippets.

@ron623
Last active August 2, 2018 06:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ron623/90308d3f01f411e0fb723156d82a8b75 to your computer and use it in GitHub Desktop.
Save ron623/90308d3f01f411e0fb723156d82a8b75 to your computer and use it in GitHub Desktop.
' ★★★ 値渡しの例 その2★★★
Sub Sample_Val_2()
Dim str As String
str = "もとの文字です(*`▽´*)"
' 値渡しで関数を呼び出す
str = CallByVal_2(str)
' 上記の関数内で処理した文字列をメッセージボックスにて表示
MsgBox str
End Sub
' ★★★ 値渡しの関数 その2 ★★★
Function CallByVal_2(ByVal msg As String)
'受け取った文字列msgを"値を変えました!"に変更
msg = "値を変えました!"
' 値渡しの場合でも変更した文字列を戻り値として返せば、変更された文字列がメッセージボックスに表示される
CallByVal_2 = msg
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment