Randomizers Randomizers - 2 years ago 69
Vb.net Question

Run a function from another form vb.net

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?

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download