传递数组byref不会编辑原始数组

blu*_*ear 2 ms-access vba

我正在尝试在Access 2003中编写一个子例程,它从数组中的字符串中删除所有引号字符.子例程在例程本身中成功删除了引号,但在程序返回到传递函数时则不会.我很困惑,因为它是由ByRef完成的.

怎么称呼:

Call removeQuotes(wbs_numbers())
Run Code Online (Sandbox Code Playgroud)

和子程序本身:

'goes through a string array and removes quotes from each element in the array'
Sub removeQuotes(ByRef string_array() As String)
    For Each element In string_array()
    'chr(34) is quotation character. visual basic does not have escape characters.'
    element = Replace$(element, Chr(34), "")
    Next
End Sub
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下我做错了什么吗?我永远爱你!

Dav*_*d M 11

您的数组可能是参考,但element不是.按索引迭代,并在操作后将字符串设置回数组.