Home > Back-end >  Form Me.close doesn't work, Close all forms?
Form Me.close doesn't work, Close all forms?

Time:12-31

I use this code

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Settings.Str -= 1
        My.Settings.Save()
        Label2.Text = My.Settings.Str
        If My.Settings.Str >= 0 Then
            FrmLogin.Show()
            Me.Close()
        End If

        If My.Settings.Str <= 0 Then

            MsgBox("Your trial has Expired, Please Buy a key", MsgBoxStyle.Information, "Trial Expired")
            FrmRegister.ShowDialog()

        End If
    End Sub

But when i run the form and press the button will close all forms when i use me.hide the code running whitout any problem can i know if there is any porblem on the code please

CodePudding user response:

With default project settings, your application will be closed when the startup form is closed. If you want to change this behaviour:

  1. Right click on your project in the Solution Explorer
  2. Select Properties
  3. Select the Application tab
  4. Under Shutdown mode, select "When last form closes" (see image below)

Screenshot

Another idea would be to leave the default settings and change your startup form...

  • Related