Hey there, so i have small problem, my application has mainForm and settingsForm, so is there only possible way to get settingsForm to be started only on first time user starts application so he can configure correct configs and then after it any other starting of application user gets mainForm started?? Is it possible? How if it is?

You can create a boolean settings variable with a name like FirstTime and set it to True. When your app starts, check the value of FirstTime. If it is true then hide the main form and display the settings form. Then set FirstTime to false and save it. If you give it User scope then the settings form will be displayed the first time for each user.

Edited 2 Years Ago by Reverend Jim

Can't get it working :/ Can someone make me simple project about it if its not a problem?

Sure thing. See attached vb 2010 project. Note, the Hide and Show are optional. It depends on whether or not you want the main form to be visible. I included a Reset button so you could reset the flag back to True otherwise you'd only be able to test it once.

you can use conditional statments that if settings are enabled then form main.show else setting form.show

Okay so now there is another problem :3
When i run app on first start, if i click at top window X to close settings it works fine but when i click button that has:

 Private Sub btn_close_Click(sender As Object, e As EventArgs) Handles btn_close.Click
        Close()
        mainForm.Form1_Load(Me, New EventArgs)
    End Sub

I get error Form that is already visible cannot be displayed as a modal dialog box. Set the form's visible property to false before calling showDialog.

I need since i made some textboxes to load files and when user click button on form 1 it should open those files so if i change twice files i will need to close app and start it again right? anyway My.Settings.FirstTime = False on close button fixed problem :)

I installed visual Studio 2012 (hate the look and feel of the "flat" interface) and loaded up your project. The reason it isn't working is because you didn't add the suggested code. If you want to display Settings on first run then you have to add code in the Form_Load event handler. Have another look at the sample project I posted earlier.

This is so very simple. On your Main form on it Form_Load try this.

Dim firsttime As String = "done"
' Check from file if the file exist or not, if the file
' Exist that means the program is not running the first time
If My.Computer.FileSystem.FileExist("C:\firsttime.txt")
Then
Me.show()
Else
My.computer.FileSystem.WriteAllText("C:\firsttime.txt", firsttime, True)
Me.Hide()
'Call the form2 as Setting form
Form2.show()
End If

Creating a file when a flag will do is not the way to go, especially a file in the location (root of C) that you are suggesting. The location is unrelated to the application and the filename gives no indication of what the file is for. All in all a very bad idea.

No that was to show how to start and it was just a sample he could change from creating a file and go with Setting, I was just showing him because he's seem to be lost.

ok,
What you can do is: create a boolean property in the setting and named it as : firsttime and value=true

add the code to mainform.

if my.setting.firsttime = true then
   settingform.show()
   me.close()
Else : ' do nothing.
End if

add the following code to setting form.

if me.setting.firsttime = true then
   my.setting.firsttime = false
   my.setting.save()
Else : my.setting.firsttime = false
   my.setting.save()
End if

and the error you get on btn_close event
type the following code to close the application:

application.exit()

Note: you have to change the setting last from closing.

Edited 2 Years Ago by Deep Modi

Sorry, I don't read those solution, I just go to thread and find some few solution at top most and answer as he passed with those error

This question has already been answered. Start a new discussion instead.