Member Avatar for Micheal87

Hi, how can I clean all saved settings in my.settings ? Do I need only to put
my.settings.[name].clear() or a My.settings.reset() can do a good job for all the user setting added into the program?
Also how can I add an exception if there is nothing in that setting or all settings? Can I put like
the isnullorempthy and referring it to that particular setting?

If ask = Msgboxresult.Yes then
my.settings.[name1].clear()
my.Settings.reset()
if ask = msgboxresult.no then
end if

Recommended Answers

All 5 Replies

Member Avatar for Micheal87

Found out that:
My.settings.reset() ----> only reset setting like background images,ecc.
While
My.settings.[name of the setting].clear() --->will clean that settings

Still asking for help how to put null exception to all of the settings stored (if there's any) or how to do it with a for next cycle.

Are you asking for this?:

            For Each prop As System.Configuration.SettingsProperty In My.Settings.Properties
                prop.DefaultValue = ""
            Next
Member Avatar for Micheal87

@xrjf thanks, I will try it, I keep getting exception if a My.settings return a "is nothing", but I think I need to move the code on a if statement (like if My.settings.Properties is nothing or isnot nothing, then,ecc) or a form load. Thanks again :)

Add a check, like this:

        If My.Settings?.Properties IsNot Nothing Then
            For Each prop As System.Configuration.SettingsProperty In My.Settings.Properties
                prop.DefaultValue = ""
            Next
        End IF

Let's see if (I am right and) I can explain the difference between My.Settings.Reload and My.Settings.Reset.
Reload recovers the values from design time, i.e., the values you enter manually in the application's settings.
Reset recovers the values saved in the last call to My.Settings.Save.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.