结束子 或者我可以拨打那个以某种方式添加的那个吗? Public Sub New( ) CallDefaultNew()''某种程度上 ''我的代码在这里 End Sub 猜猜我试图将我的代码与.designer.vb代码离婚,这可能会在某一天改变。 (假设他们决定调用InitializeComponent的东西 else。) I believe that with VS2005 if I don''t include sub New it is somehow addedbut not visible. But if I need a New with arguments or if I have to insert code into New Ican write my own. Should it be put into the .designer.vb or into the .vb file? If you recommend putting it into the .vb file should it be: Public Sub New() MyBase.New() InitializeComponent() ''my code here End Sub or can I call the one that was somehow added? Public Sub New() CallDefaultNew() ''somehow ''my code here End Sub Guess I''m trying to divorce my code from the .designer.vb code which couldchange some day. (Suppose they decide to call InitializeComponent somethingelse.)推荐答案 1月19日,10:01 * pm, "学术和QUOT; < academiaNOS ... @ a-znet.comwrote: On Jan 19, 10:01*pm, "Academia" <academiaNOS...@a-znet.comwrote: 我相信如果我没有包含新的VS2005,它会以某种方式添加 但不可见。 但是如果我需要一个带参数的New或者我必须将代码插入New I 可以写我的它应该被放入.designer.vb *或.vb文件中吗? 如果你推荐把它放入应该是.vb文件: Public Sub New() MyBase.New() InitializeComponent() ''我的代码在这里 结束子 或者我可以拨打以某种方式添加的那个吗? Public Sub New() CallDefaultNew()''不知何故 ''我的代码在这里 结束子 猜猜我试图离开我的代码.designer.vb代码可能会在某一天改变。 (假设他们决定调用InitializeComponent的东西 else。) I believe that with VS2005 if I don''t include sub New it is somehow addedbut not visible.But if I need a New with arguments or if I have to insert code into New Ican write my own.Should it be put into the .designer.vb *or into the .vb file?If you recommend putting it into the .vb file should it be:Public Sub New()MyBase.New()InitializeComponent()''my code hereEnd Subor can I call the one that was somehow added?Public Sub New()CallDefaultNew() ''somehow''my code hereEnd SubGuess I''m trying to divorce my code from the .designer.vb code which couldchange some day. (Suppose they decide to call InitializeComponent somethingelse.) 我看到默认情况下在应用程序中生成的代码如下: /> #Region" Windows窗体设计器生成的代码 Public Sub New() MyBase.New() ' 'Windows窗体设计器需要此调用。 InitializeComponent() ''在InitializeComponent()调用后添加任何初始化 结束子 我认为你应该通过这一步并将你的东西作为编码和 设计两者。 更多建议会更好。 I saw that code generated by default in an app follows as: #Region " Windows Form Designer generated code " Public Sub New()MyBase.New() ''This call is required by the Windows Form Designer.InitializeComponent() ''Add any initialization after the InitializeComponent() call End Sub I think you should past this step and do your stuff as coding anddesigning both.More suggestions would be better. 1月19日,10:01 * pm,Academia < academiaNOS ... @ a-znet.comwrote: On Jan 19, 10:01*pm, "Academia" <academiaNOS...@a-znet.comwrote: 我相信如果我没有包含新的VS2005,它会以某种方式添加 但不可见。 但是如果我需要一个带参数的New或者我必须将代码插入New I 可以写我的它应该被放入.designer.vb *或.vb文件中吗? 如果你推荐把它放入应该是.vb文件: Public Sub New() MyBase.New() InitializeComponent() ''我的代码在这里 结束子 或者我可以拨打以某种方式添加的那个吗? Public Sub New() CallDefaultNew()''不知何故 ''我的代码在这里 结束子 猜猜我试图离开我的代码.designer.vb代码可能会在某一天改变。 (假设他们决定调用InitializeComponent的东西 else。) I believe that with VS2005 if I don''t include sub New it is somehow addedbut not visible.But if I need a New with arguments or if I have to insert code into New Ican write my own.Should it be put into the .designer.vb *or into the .vb file?If you recommend putting it into the .vb file should it be:Public Sub New()MyBase.New()InitializeComponent()''my code hereEnd Subor can I call the one that was somehow added?Public Sub New()CallDefaultNew() ''somehow''my code hereEnd SubGuess I''m trying to divorce my code from the .designer.vb code which couldchange some day. (Suppose they decide to call InitializeComponent somethingelse.) 你也可以访问那些网站: http://www.vbinfozine.com/a_disposable_comp.shtml http://www.developerfusion.co.uk/show/4369/ 并看看构造函数: http://www.startvbdotnet.com/oop/constructor.aspx 希望这些帮助。 Also you can visit that sites: http://www.vbinfozine.com/a_disposable_comp.shtml http://www.developerfusion.co.uk/show/4369/ and take a look at constructors: http://www.startvbdotnet.com/oop/constructor.aspx Hope these help. Academia写道: Academia wrote: 我相信VS2005如果我不包括sub New它就会以某种方式增加 但不可见。 I believe that with VS2005 if I don''t include sub New it is somehowadded but not visible. 如果你没有添加它,那么你将得到一个默认的公共构造函数,它接受 没有参数并执行任何默认值你的 班需要初始化。 (对于普通班级来说,通常没什么,或者调用表格的 表格初始化代码)。 If you don''t add it then you''ll get a default Public constructor that takesno parameters and performs any default initialisation required by yourclass. (Which is generally nothing for a general class, or calling into theform initialisation code for a form). 是否应该放进入.designer.vb或进入.vb文件? Should it be put into the .designer.vb or into the .vb file? 我总是把它放在.vb文件中。 .designer.vb文件用于自动生成的 代码,用于用户生成代码的.vb文件。构造函数的内容 将是您自己的代码,因此请将其放在.vb文件中。 I always put it in the .vb file. The .designer.vb file is for auto-generatedcode, the .vb file for user-generated code. The content of the constructorwill be your own code, so put it in the .vb file. 如果您建议将其放入应该是.vb文件: Public Sub New() MyBase.New() InitializeComponent() ''我的代码在这里 结束子 If you recommend putting it into the .vb file should it be:Public Sub New()MyBase.New()InitializeComponent()''my code hereEnd Sub (表格)是的。如果您输入以下空白行: \\\ Public Sub New /// ....然后按回车键,你会看到VB自动为你添加所有代码 ,所以你可以添加你的它所代表的代码。 HTH, - (O)enone (For a form) Yes. If you type on a blank line the following: \\\Public Sub New/// ....and press Return, you''ll see that VB automatically adds all that code infor you, so you can just add your own code where it indicates. HTH, -- (O)enone 这篇关于New Sub应该放入什么文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 10:00