简体   繁体   中英

VB.net my.settings not auto icrementing and storing

I have a class that has a list of messages that cycle through based on a given integer stored in the settings. Here is a code snippet that is not working. Am I not incrementing properly for settings?

Public Class Messages

Public Sub Punchinmsg()

    Dim msgint As Double = My.Settings.msgint

    If msgint = 0 Then
        MsgBox("You have been punched in... Good thing I don't have arms.")
        msgint = msgint + 1
        My.Settings.Save()
    ElseIf msgint = 1 Then
        MsgBox("Great time for work...")
        msgint = msgint + 1
        My.Settings.Save()

My settings are msgint is Double and USER to allow it to be written to at run time.

You are setting a local variable, but not the setting that has the same name. Before calling My.Settings.Save, you must set the setting. Example...

msgint = msgint + 1 'This only updates the local variable.
My.Settings.msgint = msgint 'Assigns a new value to the setting named msgint.
My.Settings.Save()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM