Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Error:

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

Question:

How do I amend this code to make it work?

 

Public Class Form1

Inherits System.Windows.Forms.Form

 

Dim NewClass1 As Class1

Private Sub Form1_Load(ByVal sender As System.Object,

ByVal e As System.EventArgs) Handles MyBase.Load

NewClass1 = New Class1()

Call NewClass1.Class1Sub() '***** Call Class1Sub

End Sub

Public Sub Form1Sub()

TextBox1.Text = "Yes"

End Sub

End Class

Public Class Class1

Public Sub Class1Sub()

Form1.Form1Sub() '****** this line is highlighted in error

End Sub

End Class

Posted


Public Class Form1
Inherits System.Windows.Forms.Form

Dim NewClass1 As Class1

Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
NewClass1 = New Class1(me)
Call NewClass1.Class1Sub() '***** Call Class1Sub
End Sub
Public Sub Form1Sub()
TextBox1.Text = "Yes"
End Sub
End Class

 


Public Class Class1

private mParentObject as Form1

Public Sub New (ByRef myParent as Form1)
myclass.New()
mParentObject = myParent
end Sub

Public Sub Class1Sub()
mParent.Form1Sub() 
End Sub
End Class

.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...