Firstrun from the startup form program is one and after firstrun the startup form changes Vb.net

Asked

Viewed 30 times

0

I need help, I have a Vb.net game in which I want the firstrun of the program to open a form to put the nick and has a mini tutorial etc, and after firstrun the startup form changes to the game, without appearing the form to put 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 (Start) appears together with Form1

1 answer

0


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

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:

inserir a descrição da imagem aqui

And change the option Startup Object for the new class you created (in case mine called Program)

inserir a descrição da imagem aqui

Ready, now run the project and see that before showing any form, the system will pass through this class, so you can intercept and show the form you want.

I hope I’ve helped. Any questions just ask.

Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.