skip to Main Content

I’ve searched for hours and tried bunches of stuff with no luck.

I’m using VB.net. My main form (Form1) is not loading another form (ECR_ECO_Details). It did just hours ago. Somehow ECR_ECO_Details ended up in the My Project folder. I dragged it back to where it used to be, same place as Form1. No errors, warnings or joy.

Additionally, I have a MsgBox in the Load and Shown events. The MsgBox does not present so my program is not even finding the second form.

It has to be something simple but this is my first time in Visual Studio. I’m convinced it’s something in the IDE, not code.

    Private Sub NewECR_Click(sender As Button, e As EventArgs)
        Dim NewECRForm As New ECR_ECO_Details
        NewECRForm.ShowDialog()
    End Sub

Pretty much same effective code as above, same result. Used to work tho.

    Private Sub NewECR_Click(sender As Button, e As EventArgs)
        Using NewECRForm As New ECR_ECO_Details()
            NewECRForm.ShowDialog()
        End Using
    End Sub

TIA!

2

Answers


  1. this code is on my Form1 click the button and it loads and shows frmSSUpdate and Close’s Form1

     Private Sub btnSSDeposit_Click(sender As Object, e As EventArgs) Handles btnSSDeposit.Click
        frmSSUpdate.Show()
        Close()
    End Sub
    
    Login or Signup to reply.
  2. You’ve simply lost the Handles clause on the end of your method, meaning it NEVER runs when the button is clicked. *You can lose the Handles clause if you cut/paste the button to somewhere else on your form.

    You can add it back in from the IDE by selecting the Button. Then in the Properties Pane, make sure the events are listed by clicking on the "Lightning Bolt" icon. Now find the "Click" entry and change the dropdown so it says "NewECR_Click".

    Alternatively, you can simply add the Handles clause back onto the end of your existing method (look at the END of the first line):

    Private Sub NewECR_Click(sender As Button, e As EventArgs) Handles NewECR.Click
        Dim NewECRForm As New ECR_ECO_Details
        NewECRForm.ShowDialog()
    End Sub
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search