robbremington Posted February 17, 2003 Posted February 17, 2003 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 Quote
Heiko Posted February 17, 2003 Posted February 17, 2003 Class1 knows no object with the name Form1. Quote .nerd
robbremington Posted February 17, 2003 Author Posted February 17, 2003 I know that, but what code do I add to make it work? Quote
Heiko Posted February 17, 2003 Posted February 17, 2003 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 Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.