From: J.B. Moreno on
Armin Zingler <az.nospam(a)freenet.de> wrote:

> - If you add a new Form to the project, it does not have a visible
> constructor, too. With a Form class, VB also creates a default
> constructor but that one also contains a call to InitializeComponent.

Actually, if you add a form to a project it DOES have a constructor.
This constructor is in the designer file, but is present.

And if you need to put your own code inside of it, that is OK -- it
won't mess anything up, as long as you do it after the call to the base
constructor and after the call to InitializeComponent.

--
J.B. Moreno
From: Armin Zingler on
J.B. Moreno schrieb:
> Armin Zingler <az.nospam(a)freenet.de> wrote:
>
>> - If you add a new Form to the project, it does not have a visible
>> constructor, too. With a Form class, VB also creates a default
>> constructor but that one also contains a call to InitializeComponent.
>
> Actually, if you add a form to a project it DOES have a constructor.
> This constructor is in the designer file, but is present.

Before writing all this, I was not sure in every case. So I've tried it.
If I add a new form, it does not contain a constructor in the source code.
I would not have written it without trying it first. I'm using VS 2008 Prof.

This is the whole designer file:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form

'Das Formular �berschreibt den L�schvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Wird vom Windows Form-Designer ben�tigt.
Private components As System.ComponentModel.IContainer

'Hinweis: Die folgende Prozedur ist f�r den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer m�glich.
'Das Bearbeiten mit dem Code-Editor ist nicht m�glich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Text = "Form1"
End Sub

End Class

I do not see a constructor there. The compiler creates it when compiling.


> And if you need to put your own code inside of it, that is OK -- it
> won't mess anything up, as long as you do it after the call to the base
> constructor and after the call to InitializeComponent.

As I wrote

>>And inside Form1.designer.vb change the constructor to make it look like this:
>>
>> sub new
>> InitializeComponent
>>
>> mytextboxes = new textbox() {text0, text1, text2} '<<<<<<< line to add
>> end sub

I agree. However, putting additional constructor code into form1.vb, you have your
own constructor code all there and always visible.



--
Armin
From: J.B. Moreno on
Armin Zingler <az.nospam(a)freenet.de> wrote:

> J.B. Moreno schrieb:
> > Armin Zingler <az.nospam(a)freenet.de> wrote:
> >
> >> - If you add a new Form to the project, it does not have a visible
> >> constructor, too. With a Form class, VB also creates a default
> >> constructor but that one also contains a call to InitializeComponent.
> >
> > Actually, if you add a form to a project it DOES have a constructor.
> > This constructor is in the designer file, but is present.
>
> Before writing all this, I was not sure in every case. So I've tried it.
> If I add a new form, it does not contain a constructor in the source code.
> I would not have written it without trying it first. I'm using VS 2008 Prof.

Everyone: sorry, Armin Zingler is exactly right. And I was entirely
wrong: an explicit constructor is not created. I was *sure* one was,
but of course I was wrong...

--
J.B. Moreno