我遇到的奇怪问题。
我遍历从字符串拆分创建的数组。在迭代中,我对数组中的项目进行了修改。(向项目添加字符(字符串,在这方面)
更改在 for 循环中受到影响,但是在 for 循环之后直接使用此数组时,更改似乎被“删除”,并且与更改之前一样使用原始数组。
这可能是一个 byRef,byVal 问题......但我并没有专门将它传递到任何地方。
也许有人可以对这种行为有所了解。我已经在 for 循环中建立了一个列表,并在我进行字符串更改时添加到它。然后我在我的选择语句中使用该列表。这行得通,但我很好奇为什么数组会放弃它的变化。
问候
Dim descriptionSplit() As String
descriptionSplit = Split(unit.itemDescription, "[")
'add the cut "[" back to the strings . "[" was cut from the strings when it was split ON "["
For Each splitSection As String In descriptionSplit.
'add back the '[' char
splitSection = "[" & splitSection
Debug.Print(splitSection)
Next
'look for and find TAGS
For Each splitSection As String In descriptionSplit
Select Case True
'Look for #UNIT# TAG
'######## HERE, the array has reverted to the original copy....
Case splitSection.Contains("[U]")