我有一個字符串數組作爲參數子:子/功能數組參數改變
Private Sub des(ByVal array() As String)
Dim i As Integer
For i = 0 To UBound(array)
array(i) = "hy"
Next
End Sub
當我打電話給我的主要功能內部的功能,即使在陣列被傳遞到的STR的值變化函數ByVal:
Dim str() As String
str = {"11111", "22222", "33333", "44444", "5555", "66666"}
des(str)
我試圖在Sub中製作一個數組的副本,但它仍然在主函數中更改。
Private Sub des(ByVal array() As String)
Dim i As Integer
Dim array2() As String
array2 = array
For i = 0 To UBound(array)
array(i) = "hy"
Next
End Sub
我在一個網站上閱讀,你不能傳遞數組ByVal。這是真的?如果是這樣,我該如何繼續?