Link to home
Start Free TrialLog in
Avatar of indy500fan
indy500fan

asked on

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

Friends,

I am getting an error.  Does anybody know how to fix it?

Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        SetBlendLine = New BlendLine
        BlendLine.Show()

    End Sub

I am wanting to display a form upon Load of Main, and the code above is what I am using to do that.  However, the line BlendLine.Show() is getting the error:

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

What does this mean?

The only reference that that form has to main is a variable:

Public Class BlendLine
    Inherits System.Windows.Forms.Form

    Dim OtherDecoder As String
    Dim DecoderSet As String

    Public Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOKbl.Click
        Main.DecodersToUse = DecoderSet
        Me.Close()

    End Sub

    Public Sub ckbUseAnotherDecoder_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckbUseAnotherDecoder.CheckedChanged

        OtherDecoder = txtOtherDecoder.Text

        If ckbUseAnotherDecoder.Checked = True Then
            DecoderSet = ("250 or " & OtherDecoder)
        ElseIf ckbUseAnotherDecoder.Checked = False Then
            DecoderSet = ("250")
        End If

    End Sub
End Class


Avatar of cyberdevil67
cyberdevil67

Hi indy500fan,

 It means the method Show in that class is erroring, and can't be of type non-shared.

Cheers!
Avatar of indy500fan

ASKER

cyberdevil67,

How do I fix that?

Thanks!
In Blendline, define show like this:

Public Shared Sub Show()
...
...
End Sub

By the way, I think your code is messed up anyway. Don't you mean to do this (which would not require a shared function in the first place)?

   SetBlendLine = New BlendLine
        SetBlendLine.Show()
ASKER CERTIFIED SOLUTION
Avatar of cyberdevil67
cyberdevil67

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
cyberdevil67,

Duh, that was pretty dumb of me.  Yep, that worked!  Thanks
I could of sworn that was what I just said. Oh well - glad you got it working! :)
The joys of posting via a dialup, my comment made it in after yours....