title: VB: Object "inaccessible due to its protection level" (Visual Studio 2012)
body: <p>I'm having problems with this <code>SearchButton</code> code in VB (Visual Studio 2012):</p>
  
  <p>This code in Form1.VB: </p>
  
  <pre><code>Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click 
      Dim results As Artist 
      results = Array.SearchArray(artistArray(), SearchTextBox.Text) 
  End Sub 
  </code></pre>
  
  <p>and I'm getting an error that <code>artistArray</code> is inaccessible due to its protection level. </p>
  
  <p>I'm new to VB, so I'm sure it's something I'm doing wrong, but I can't find it.</p>
  
  <p>I have checked spelling, visibility (<code>Public</code>), and so on.  </p>
  
  <p>array.vb at the moment: </p>
  
  <pre><code>Public Class Array 
      Public artistArray() As Artist 
      Public searchResults(artistArray.Length) As Artist 
      Dim searchString As String 
  
      Public Function SearchArray(ByVal artistArray(), searchString) As Artist() 
          Dim x As Integer ' artist index variable for loop 
          Dim index As Integer = 0 ' index for results 
          For x = 0 To artistArray.GetUpperBound(0) 
              Dim temp As Artist = artistArray(x) 
              If temp.Name.ToLower().Contains(searchString.ToLower()) Then 
                  searchResults(index) = artistArray(x) ' if search hit then add current item to result array 
                  index += 1 ' and incr. result index 
              End If 
           Next 
           ReDim Preserve searchResults(index) 
           Return searchResults 
      End Function 
  
      ' ...
  End Class
  </code></pre>