FirstRun of the program startup form is one and after firstrun the startup form changes vb.net

0

I need help, I have a game in vb.net where I want in the firstrun of the program to open a form that gives for the nick and has a mini tutorial etc, and after firstrun the startup form changes to the game, without appearing the form for the nick.

I've tried to do:

    Private Sub Inicio_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If My.Settings.FirstRun = True Then
            My.Settings.FirstRun = False
            My.Settings.Save()
        ElseIf My.Settings.FirstRun = False Then
            Dim Inicio As Inicio
                Inicio = New Inicio
            Inicio.Hide()
            Dim Form1 As Form1
            Form1 = New Form1
            Form1.Show()
        End If
    End Sub
  End Class

But the main form (Home) appears along with Form1

    
asked by anonymous 26.04.2016 / 19:40

1 answer

0

Next, for this to work, the correct thing is to check this when starting the system before giving load in any form whatsoever. To do this you must first create a boot class in the root of your project:

Module Program
    Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)

        If (My.Settings.FirstRun) Then
            My.Settings.FirstRun = False
            My.Settings.Save()
            Application.Run(New Form1) 'aqui seria seu form para inserir o usuário e senha
        Else
            Application.Run(New Form2) 'aqui seria seu form Inicio
        End If
    End Sub
End Module

Then, in your project settings, uncheck this option:

AndchangetheStartupobjectoptiontothenewclassyoucreated(inmycasecalledProgram)

Now, run the project and see that before showing any form, the system will go through this class, so you can intercept and display the form you want.

I hope I have helped. Any questions just ask.

Hugs!

    
27.09.2016 / 01:54