troubleshooting Question

Reference to a non-shared member requires an object reference.

Avatar of p-plater
p-platerFlag for Australia asked on
Visual Basic.NET
4 Comments1 Solution61 ViewsLast Modified:
I'm missing something basic but I can't work it out..

I have a Public Class with a Public Function inside it (This is in a BLL DLL)

Public Class CompanySearch
    Public Function Search(ByVal searchText As String) As CompanyName
        Dim companySearchList As New CompanyNameCollection(searchText, False)

        If companySearchList.Count = 1 Then
            Dim company As CompanyName = companySearchList.Item(0)
            Return company
        Else
            Using CompanySearchForm = New CompanySearch()
                With CompanySearchForm
                    .SearchTextBox.Text = searchText
                    .SearchResultDataGridView.DataSource = companySearchList
                    .ShowDialog()
                End With
                Dim company As CompanyName = companySearchList.Item(0)
                Return company
            End Using
        End If
    End Function
End Class

I am trying to call it from the UI

Dim company As New CompanyName
company = CompanySearch.Search(CompanyNameTextBox.Text)

But I am getting the "Reference to a non-shared member requires an object reference" Error.
I thought I was giving it an Object Reference by using a Instance of the CompanyName Class?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros