
Originally Posted by
obi1kenobi
Oh, wait, I didn't see that the variable is in a different class.Try this: (in order to avoid having to make an instance)
yes that worked, but looks like I should explain why i need this, since I got loads of errors after I tried to modify this.
My code is getting bigger & bigger & its pretty hard to navigate in it so I thought ill split it by putting some functions from Form1 for example Private Sub Button2_Click(....) into other file like class1.vb & then simply use Class1.Button1_Click() under form1 button1 click functon. & theoretically by clicking on button1 it should click on button2. Well let me make a sample:
take function from form1.vb & put it in class.vb & then call that functon from form1.vb at formload
Form1.vb
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'we attempt to call a function from Class1.vb file hire
Class1.sample()
End Sub
End Class
class1.vb
Code:
Public Class Class1
Public Shared sampletext As String = "flowers"
Public Sub sample()
MsgBox(sampletext)
End Sub
End Class