vb.net - Make a label or button behave as a checkbox? -
i want code when click label changes boolean true, if false , false if true. , can loop, checkbox.
private sub label3_click(sender system.object, e system.eventargs) handles label3.click dim clickedlabel = trycast(sender, label) if bool1 = true if clickedlabel isnot nothing bool1 = false end if if bool1 = false if clickedlabel isnot nothing bool1 = true end if is there way this?
sure, handle click event of label.
public class form1 private _mybool boolean private sub label1_click(sender object, e eventargs) handles label1.click _mybool = not _mybool label1.text = iif(_mybool, "mybool true", "mybool false") end sub end class using not operator easy way toggle boolean value - whatever was, not operator flip it. otherwise, problem code have missing end if statements if bool1 = ... sections.
Comments
Post a Comment