puckhead
puckhead

Reputation: 49

Form load event not firing after C# to VB conversion

After using a handy converter to go from C# to VB, one line was missing. Apparently the form load syntax confused the converter enough to not even try. I have not had any luck finding the correct VB equivalent and can't get the Form1_Load sub to run. Assistance would be hugely appreciated.

The C#:

     // Form1
     // 
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize = new System.Drawing.Size(1121, 890);
     this.Controls.Add(this.vcGantt1);
     this.Name = "Form1";
     this.Text = "NETRONIC VARCHART XGantt - Tutorial Project 1";
     this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
     this.Load += new System.EventHandler(this.Form1_Load);
     this.ResumeLayout(false);

The VB with the missing line:

        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(1495, 1095)
        Me.Controls.Add(Me.vcGantt1)
        Me.Margin = New System.Windows.Forms.Padding(4)
        Me.Name = "Form1"
        Me.Text = "NETRONIC VARCHART XGantt - Tutorial Project 1"
        Me.WindowState = System.Windows.Forms.FormWindowState.Maximized

        Me.ResumeLayout(False)

Much thanks!

Upvotes: 0

Views: 150

Answers (1)

Jon Roberts
Jon Roberts

Reputation: 2282

Add a Handles MyBase.Load at the end of your Form1_Load, like this:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' ... your code goes here
End Sub

Upvotes: 2

Related Questions