I must have done something wrong, because i can still start my program, but i can not enter my design form anymore and my code is gone. All I See is code with a lot of me.xxxxx starting. What have i done wrong?

dick zelvelder 21 Reputation points
2021-02-05T23:19:40.507+00:00

After a evening of programming, I changed the name of my Form (Form1) to soemthing else and got an incomprehensible error. I was stubborn and said yes and now all seems lost. I can still start my program and it works still fine, but i can not get back to my design screen or my code.

The code now starts with this:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<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

Anyone have clues for me? And sorry, tag is probably not good; do not recognize/understand any tag

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,606 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,201 Reputation points
    2021-02-06T13:09:33.613+00:00

    Hello,

    If we look at a new form the designer part (in this case Form1.Designer.vb) should look like this (I removed the default comments)

    64764-11111111111.png

    <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _  
    Partial Class Form1  
        Inherits System.Windows.Forms.Form  
      
      
        <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  
      
      
        Private components As System.ComponentModel.IContainer  
      
        <System.Diagnostics.DebuggerStepThrough()>  
        Private Sub InitializeComponent()  
            components = New System.ComponentModel.Container  
            Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font  
            Me.ClientSize = New System.Drawing.Size(800, 450)  
            Me.Text = "Form1"  
        End Sub  
    End Class  
      
    

    Then under project properties ensure you can see the form name
    64782-222222.png

    Also, look at ApplicationDesigner.vb (under project menu in Visual Studio select show all files and inspect e.g. in this case we can see DataGridViewForm is the startup form. If it did not exists it would need to change which should not be done here but under project properties as per above.

    64805-333333333333.png