2016-08-10 13 views
0

配列「UIDList()」に割り当てられた値を取得するには、以下のコードがあります。しかし、これまでの理由のために、それは最後の価値しか得ていない。間違っていた可能性のあるものを修正してください。配列が値を取得しない

Dim strTest As String 
Dim strarray() As String 
Dim UIDList() As String 
Dim intCount As Integer 
Dim TotUID As Integer 

Set oFS = oFSO.OpenTextFile("C:\Pro\test.txt") 
txtpro = oFS.ReadAll 

strTest = txtpro 
strarray = Split(strTest, "=") 

For intCount = LBound(strarray()) To UBound(strarray()) 
    If InStr(strarray(intCount), "NAME") Then 
     UIDList() = Split(strarray(intCount), "NAME") 
    End If 
Next 

For TotUID = LBound(UIDList()) To UBound(UIDList()) 
Debug.Print UIDList(TotUID) 
Next 

答えて

0

不適切な営巣:これまで

変更:

For intCount = LBound(strarray()) To UBound(strarray()) 
    'Erase the array 
    Erase UIDList 
    If InStr(strarray(intCount), "NAME") Then 
     UIDList() = Split(strarray(intCount), "NAME") 
    End If 

'/ Check if UIDList() has any elements 
If Not (Not UIDList()) Then 
    For TotUID = LBound(UIDList()) To UBound(UIDList()) 
     Debug.Print UIDList(TotUID) 
    Next 
End If 
Next 
+0

は、UBound関数(UIDList())にTotUID = LBOUND(UIDList())のためにラインで "スクリプト範囲外" エラーを取得 – user3323922

+0

配列が初期化されているかどうかを確認する必要があります。更新された回答を参照してください。 – cyboashu

+0

これは機能しますが、次の値が見つかるまで同じデータを印刷し続けます。私はちょうどそれぞれの新しい価値のために一度それを印刷したかった。 – user3323922