views:

28

answers:

1

This is a quite strange problem. I have set a setting variable in Application settings with following data:

  • Name: county
  • Type: integer
  • Scope: user
  • Value: 0

Yet when I reference it with this statement: MsgBox(My.MySettings.Default.county) It alerts 1. Despite being the first to be executed as soon as form loads.

+1  A: 

I'm assuming that the My.MySettings bit is a typo.

Often when someone sees a different value than they expect when reading from My.Settings, it seems to be that they are reading the Default rather than the actual value.
I'd suggest trying to use just MsgBox(My.MySettings.county) and see if that returns what you want.

Otherwise, try to delete the bin and object directories of the project and try to re-compile and re-run and see if it might be something that had gotten "stuck" somewhere.

ho1
This time I used `My.Settings.county` deleting both `obj` and `bin` and still the value comes to `1`.
Shubham
@shubham: Well if you're reading without the `Default` it should definitely be reading from the .config file. What value is in the .config file in the `bin\debug` (or `bin\release` etc depending on what you're running) directory?
ho1
@ho1 - Well I just now deleted the old config files and recompiled and it worked. Thanks!
Shubham