I was trying to pass a boolean and assign a value (true/false) to it after passing it to another method
I want it to work with multiple booleans, For example:
'My.Settings.boolean1 = False
'My.Settings.boolean2 = True
Private Sub Button1_Click() Handles Button1.Click
DoSomething(My.Settings.boolean1)
End Sub
Private Sub Button2_Click() Handles Button2.Click
DoSomething(My.Settings.boolean2)
End Sub
Public Shared Sub DoSomething(aBoolean As Boolean) 'BooleanName As String
if aBoolean then
aBoolean = False '(Sets locally not the main boolean)
'etc...
Else
aBoolean = True
'etc...
End If
End Sub
It assigns the value to aBoolean and does not actually touch the original boolean, which is the target
(clearly it doesn't work that way), so
I tried to use a string to pass the boolean name to DoSomething(aBoolean As Boolean, BooleanName As String)
so I can use the boolean to know the condition, and the string to know the boolean name to assign using Convert.ToBoolean(BooleanName)
.. It did not work too
Is it even possible to do such a thing? I feel yes but I'm still trying to wrap my head around it
Real code example:
Private Sub PopupMessages_Button_Click(sender As Object, e As EventArgs) Handles PopupMessages_Button.Click
Button_MouseClick(PopupMessages_Button, My.Settings.PopupMessages, ToolTip, PopupMessages_Button_Tooltip)
End Sub
Public Shared Sub Button_MouseClick(aButton As Button, aBoolean As Boolean, aToolTip As ToolTip, aToolTip_txt As String)
If aBoolean Then
aButton.BackColor = Color.WhiteSmoke
aBoolean = False
aToolTip.SetToolTip(aButton, "(Disabled) " + aToolTip_txt)
Else
button.BackColor = Color.Green
aBoolean = True
aToolTip.SetToolTip(aButton, "(Enabled) " + aToolTip_txt)
End If
My.Settings.Save()
End Sub