My.Settings.sampleSettings
with adataType boolean
と a sampleVariable
asを使用する 2 つのシナリオがありdata type boolean
ます。
コード: 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 を満たしていますが、これは false です。
Result: False
1
Result: False
1
Result: False
1
コード:このコードでは、sampleSettings をブール変数に入れておらず、正常に動作しています。
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 をブール変数に適切に含めるにはどうすればよいですか?