vb.net 打开表单时对非共享成员的引用需要对象引用错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21126288/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 16:26:38  来源:igfitidea点击:

Reference to a non-shared member requires an object reference Error When Opening Form

vb.netvisual-studiovisual-studio-2013

提问by user2678408

I got the following error when Trying to Open a Form in Visual Basic

尝试在 Visual Basic 中打开表单时出现以下错误

Error   1   Reference to a non-shared member requires an object reference.  c:\users\alex96\documents\visual studio 2013\Projects\Home Work Calendar\Home Work Calendar\StartUp.vb  25  13  Home Work Calendar

and Here is the code I used to open the form (the not working line)

这是我用来打开表单的代码(不工作的行)

 frmCourses.Show()

Normally, this would work, but now it isn't and I don't think I did anything different when creating the other form

通常,这会奏效,但现在不行,我认为我在创建其他表单时没有做任何不同的事情

回答by Scott Savage

Create an instance of the object.

创建对象的实例。

Dim xForm as new frmCourses
xForm.Show