I get error #91 at line 114 (Object reference not set to an instance of an object).
What do I need to do to correct that.
(I get the error either pre-declaring X or as it is now)

Thanks

        Dim iterAAA As Single = 1
54:
55:     Dim arraydciP(3) As String

        Dim quantosDCIa1nosP As Single
59:     Dim quantosDCIa2nosP As Single
60:     Dim quantosDCIa3nosP As Single
61:     Dim quantosDCIa4nosP As Single 
62:         
72:     Dim arrayoa(3) As Object
73:     arrayoa(0) = oa1
74:     arrayoa(1) = oa2
75:     arrayoa(2) = oa3
76:     arrayoa(3) = oa4

77:     Dim arrayop(3) As Object
78:     arrayop(0) = op1
79:     arrayop(1) = op2
80:     arrayop(2) = op3
81:     arrayop(3) = op4


82:     Dim quantosdciAnosP(3) As String
83:     quantosdciAnosP(0) = quantosDCIa1nosP
84:     quantosdciAnosP(1) = quantosDCIa2nosP
85:     quantosdciAnosP(2) = quantosDCIa3nosP
86:     quantosdciAnosP(3) = quantosDCIa4nosP
87:   
92:
104:    For n As Integer = 1 To P
105:        arraydciP(n - 1) = arrayop(n - 1).dci
106:    Next
107:    
111:
112:
113:    Do While iterAAA <= A
114:        Dim X() As String = Array.FindAll(arraydciP, arrayoa(iterAAA - 1).dci)
116:    Loop

Your code looks like it could be reduced by using List(Of String)

Dim myList As List(Of String)

Then you could add elements by valling the .Add function.

myList.Add("Hello,")
myList.Add("World!")

Then to iterate through the list just do a simple for each:

For Each s As String In myList
    MsgBox(s)
Next

This will keep you from having to set size limits for your array. You can scale up as needed.

This article has been dead for over six months. Start a new discussion instead.