masj78
Freshman
I am new to VB.NET and unsure of the way this works. I have a form with a variety of controls and to keep things nice and neat I have written some sub routine methods in another class vb file for the form to perform. The class with the sub routine methods in has references to controls on the form. I assumed if you create a link as I have done below and the methods are public then I could reference the methods from the form class. However when I do it this way I get a null reference error and if I add new to the linking instances it gives me a stack overflow error. My code is as follows:
Can someone explain the proper way of going about this as I am a bit confused.
Many Thanks!
Visual Basic:
Public Class Form1
Public objSomeMethods As SomeMethods
objSomeMethods.method1()
objSomeMethods.method2()
End Class
Public Class SomeMethods
Public objForm1 As Form1
public Sub method1()
objForm1.buttonaction
End Sub
Public Sub method2()
objForm1.buttonaction
End sub
End Class
Can someone explain the proper way of going about this as I am a bit confused.
Many Thanks!
Last edited by a moderator: