none
In Visual Basic / Visual Studio 2019 How is code written for opening another Form RRS feed

  • Question

  • Hi Good People

    Can someone tell me how code is written for opening another form in Visual Basic 2019. Using a Menu strip Label. 

    It seems that the way of writing code 

     Private Sub msiDeleteAccount_Click(sender As Object, e As EventArgs) Handles msiDeleteAccount.Click
            frmDeleteAccount.Show()
            Me.Hide()
        End Sub

    Does not seem to work anymore. So can anyone please tell me how this is done.

    Kind Regards

    Gary


    Gary Simpson

    Tuesday, August 20, 2019 6:19 PM

Answers

  • Hi

    When you say 'Does not seem to work anymore.' what exactly do you mean? Presumably there is an exception - what is the exception message?

    Loosely speaking, the code you posted should work (altjough it is better to create a new instance first)

    To do it that way, try:

      Private Sub msiDeleteAccount_Click(sender As Object, e As EventArgs) Handles msiDeleteAccount.Click
        Dim newForm As New frmDeleteAccount
        newForm.Show()
        Me.Hide()
      End Sub


    Regards Les, Livingston, Scotland

    • Marked as answer by Gary Simpson Tuesday, August 20, 2019 6:40 PM
    Tuesday, August 20, 2019 6:34 PM

All replies

  • Hi

    When you say 'Does not seem to work anymore.' what exactly do you mean? Presumably there is an exception - what is the exception message?

    Loosely speaking, the code you posted should work (altjough it is better to create a new instance first)

    To do it that way, try:

      Private Sub msiDeleteAccount_Click(sender As Object, e As EventArgs) Handles msiDeleteAccount.Click
        Dim newForm As New frmDeleteAccount
        newForm.Show()
        Me.Hide()
      End Sub


    Regards Les, Livingston, Scotland

    • Marked as answer by Gary Simpson Tuesday, August 20, 2019 6:40 PM
    Tuesday, August 20, 2019 6:34 PM
  • Hi Les

    Thank you for getting back to so quickly. There seems to be changes in how things are written in the new Visual Basis 2019. It is good you get a list of choices on how to fix the issue. but in the list I had Didn't.

    Thanks again Les

    Regards Gary


    Gary Simpson

    Tuesday, August 20, 2019 6:46 PM