我有一个2场景,涉及使用My.Settings.sampleSettings
与dataType boolean
和sampleVariable
作为data type boolean
。sampleVariable As Boolean = My.settings.sampleSettings(boolean dataType)does not work
代码:由于两个sampleVariable和sampleSettings是布尔我声明他们像
Dim sampleVariable As Boolean = My.Settings.sampleSettings
Console.WriteLine("Result: " & sampleVariable)
If sampleVariable = False Then
Console.WriteLine("1")
sampleVariable = True
Else
Console.WriteLine("2")
sampleVariable = False
End If
My.Settings.Save()
输出:输出似乎不满足条件1时,它总是满足条件2这是假
Result: False
1
Result: False
1
Result: False
1
代码:在这个代码,我没有把sampleSettings为布尔值v可靠和它工作正常。
Console.WriteLine("Result: " & My.Settings.sampleSettings)
If My.Settings.sampleSettings = False Then
Console.WriteLine("1")
My.Settings.sampleSettings = True
Else
Console.WriteLine("2")
My.Settings.sampleSettings = False
End If
My.Settings.Save()
输出:每当我点击它会触发不同的状态按钮,这是我的目标。
Result: False
1
Result: True
2
Result: False
1
问题:如何正确地将My.Settings.sampleSettings包含到布尔变量中?