5 Replies - 647 Views - Last Post: 16 September 2012 - 11:34 PM Rate Topic: -----

#1 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

My.settings on startup

Posted 16 September 2012 - 11:54 AM

Hi,

I'm having a problem with my.settings. I have a form which is the "Startup from" form in "My project". In the _load event I've something comparable with this:

    Private Sub Home_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        If My.Settings.[name of setting]= "1" Then
            Form2.show()
        End If
    End Sub


If My.Settings.[name of setting] is 1, it doesn't show form2...

I can't save it in .txt file (so the program can read it) because of safety issues...

Does anybody have a solution?

Is This A Good Question/Topic? 0
  • +

Replies To: My.settings on startup

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: My.settings on startup

Posted 16 September 2012 - 12:11 PM

Take a look at this.
Was This Post Helpful? 0
  • +
  • -

#3 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: My.settings on startup

Posted 16 September 2012 - 12:19 PM

Tried but didn't work :(
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: My.settings on startup

Posted 16 September 2012 - 05:37 PM

If this code resides inside Form2 then the if statement doesn't have any effect as the form is already being loaded.

If you were to make a splash screen and make it your startup form and inside the splash screen use this code, then you should see that Form2 is not loaded when the setting = "1"
Was This Post Helpful? 0
  • +
  • -

#5 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: My.settings on startup

Posted 16 September 2012 - 09:54 PM

View PostWhazabazaa, on 16 September 2012 - 11:54 AM, said:

Hi,
I'm having a problem with my.settings. I have a form which is the "Startup from" form in "My project". In the _load event I've something comparable with this:

    Private Sub Home_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.[name of setting]= "1" Then
            Form2.show()
        End If
    End Sub


If My.Settings.[name of setting] is 1, it doesn't show form2...

I can't save it in .txt file (so the program can read it) because of safety issues...

Does anybody have a solution?


I just wrote a quick little test, and it works just fine for me.

Create a form with one button.
Create a user-level setting called "Form2Available" in the project. Make the type Boolean, and the value True
Create another form (Form2). I put a label on it with text of "OK, so I'm available"
In the form1 class, paste the following code

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If My.Settings.Form2Available Then
            Form2.Show()
        Else
            MsgBox("Sorry, Form2 is not available", vbOK, "Oops!")
        End If
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If My.Settings.Form2Available Then
            My.Settings.Form2Available = False
        Else
            My.Settings.Form2Available = True
        End If
    End Sub


Run the program.
You should get an apologetic messagebox.
Click the button
Close the program with the window close button.
Run the program again.
You should see both Form1 and Form2.
Was This Post Helpful? 1
  • +
  • -

#6 Whazabazaa  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 39
  • Joined: 24-July 12

Re: My.settings on startup

Posted 16 September 2012 - 11:34 PM

I've found a solution,

I had tried a several types in the my.settings (string, char, integer etc.). But when the my.settings type was a string, I replaced the = "1" with = "Yes" and that worked flawless. I find it really weird because I didn't changed anything accept the "1" into "Yes".

Boolean, as mentioned by lar3ry, did also worked!

Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1