Reputation: 71
I've got Module Main() with a function called Main() in Form1
Public Module Main
Public Sub Main()
End Sub
End Module
And I want to run this from Form2 doing Form1.Main() won't work because that will look for a class in form2 named form1.
So how can I do this?
Upvotes: 5
Views: 13572
Reputation: 1
you can also use the structure of the Form1 and Form2 class to target your routines that you wish to run.
public class form1
public shared sub testsub()
msgbox("hello world")
end sub
end class
public class form2
public shared sub testsub2()
' this will allow you to call a sub from form1 this also works with variables, functions, ect
form1.testsub()
end sub
end class
Upvotes: 0
Reputation: 18310
I believe I've found your problem. Main
seems to be a reserved keyword (or it at least serves some other purpose to Visual Studio), so you cannot use it as a class or module name.
If you rename the module to for example MainModule
, you are then able to call:
MainModule.Main()
Upvotes: 5