I solved the problem if anyone wants to know. In the code:
For Each varName In Me.variable_names
If allowed_variable_names.Contains(varName) Then
items(position) = New Opc.Da.Item()
items(position).ItemName = varName
position += 1
End If
Next
... in this for each i fill items with allowed variables, but in some cases i had positions on items with nothing values, here is the code to fix it using a StringCollection:
Dim vars As StringCollection = New StringCollection
For Each varName In Me.variable_names
If allowed_variable_names.Contains(varName) Then
vars.Add(varName)
End If
Next
Dim items As Opc.Da.Item() = New Opc.Da.Item(vars.Count - 1) {}
Dim position As Integer = 0
For Each var In vars
items(position) = New Opc.Da.Item()
items(position).ItemName = var
position += 1
Next
Me.items_list_vars = items
If items.Count <> 0 Then
items = Me.variables.AddItems(items)
End If
This code runs correctly and now i have all item values, thanks!