vb.net 将一个表单的类继承到另一个表单类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25821350/
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 18:12:08  来源:igfitidea点击:

Inheriting class of one form to another form class

vb.netvisual-studio-2010

提问by avinashse

I have two form windows form1.vband form2.vb. My code so far:

我有两个窗体窗口form1.vbform2.vb. 到目前为止我的代码:

'form1.vb
class form1
    function print(byval i as integer) as boolean
End class

'form2.vb
class form2
    inherits form1
end class

The code can not compile and it is showing the following error: Error 1 Base class 'form1' specified for class 'form2' cannot be different from the base class.

代码无法编译,并显示以下错误:Error 1 Base class 'form1' specified for class 'form2' cannot be different from the base class.

Is there any way to inherit one class from one form to another class of another form as I am writting some common functions which I dont want to rewrite every where?

有什么方法可以将一个类从一种形式继承到另一种形式的另一个类,因为我正在编写一些我不想到处重写的常用函数?

Please guide me in correct direction.

请指导我正确的方向。

回答by Vivek S.

goto> Form2.Designer.vband change

转到>Form2.Designer.vb并更改

Inherits System.Windows.Forms.Form

to
Inherits WindowsApplication1.Form1or Inherits Form1


Inherits WindowsApplication1.Form1Inherits Form1