从另一个表单vb.net运行一个函数 [英] Run a function from another form vb.net

查看:112
本文介绍了从另一个表单vb.net运行一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 公共模块Main 
Public Sub Main()

End Sub
End Module

我想从Form2运行
做Form1.Main()将不起作用,因为它会在名为form1的form2中寻找一个类。



那么我该如何做到这一点? 我相信我发现了你的问题。 Main 似乎是一个保留关键字(或者它至少为Visual Studio提供了其他用途),因此您不能将其用作类或模块名称。



如果您将模块重命名为例如 MainModule ,则可以调用:

  MainModule.Main()


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?

解决方案

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()

这篇关于从另一个表单vb.net运行一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆