Save Settings

Posts 16–21 of 21 · Page 2 of 2
Quote Originally Posted by abuckau907 View Post
@OP Lucas is right -> Since you're using VB, you could use the "Settings" class that's built-in. The cool thing is that you must declare the type of each data, so type-safety is enforced (ie. Boolean must == a boolean, not a string, etc)


To get to the "Settings" panel (...there is an interactive GUI for adding new properties), double click on "My Project" in the Solution Explorer window.


On the left side is a tab for Settings, click it.


Adding New Items to the Settings Class


To add a new item, just give it a name, and select the appropriate data type. (Boolean for CheckBox.Checked). And save the project (Ctrl+Shift+S).


Now you can "access" those variables via My.Settings. [variable name here]



Once you have set the values to what you want, just call My.Settings.Save().

This totally avoids the issue of having a separate config file.
You go verrry in-depth in ur tutorials I used to have @Nexero added on skype but he seems kinda u know...
Fixed, thank you all.
Will put who helped me in the credits.
U see how I actually filled in the red arrow for pic2 (vs. pic1) ....all about the little things : p

jk. idk, it is what it is : )

edit: No, I don't know. : p
Try writing the value as Checkbox1.checked.tostring? as you are writing a string, not a boolean. i have no idea if this will help though :/
Quote Originally Posted by Raow View Post
Try writing the value as Checkbox1.checked.tostring? as you are writing a string, not a boolean. i have no idea if this will help though :/
Like @ [MPGH]Biesi said, In general Option Strict should be set to On. Otherwise the compiler will try to convert data types (like allowing a boolean to be == a string). This can make coding easier (?), but at the cost of type-safety. You don't want the compiler trying to guess about data type, so turn Option Explicit on.

Without Option Explicit On,

Dim myStr as String = CheckBox1.Checked '' a String == A Boolean, types don't match, problem.

essentially becomes
Dim myStr as String = CheckBox1.Checked.ToSTring()


The compiler will box the boolean into an "Object" and call it's .ToString() method. That may or may not be what you expect/actually want. Will it output "True" or "true" or "1" or... it's not very intuitive.
Also, writing to Ini files can be useful if there are future versions and then you can just transfer settings from the old Ini file.
And maybe there could be a few ways to customize it and add themes so it's easier for ini files as you would just be able to download them.
Posts 16–21 of 21 · Page 2 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us