The button’s width is 123. Why doesn’t the following change it’s width
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
With Me.Button3
IIf(.Width = 123, .Width = 233, .Width = 150)
End With
End Sub
Does IIF just return a value? i.e if I want to set the button’s width property then do I need to use an If structure?
Very little said about Iif in MSDN
Yes.
No, because you can assign the return value to the
Widthproperty:Note that, in current versions of VB.NET, the If Operator should be used instead of Iif, since it has a variety of advantages (type safety, short-circuiting, etc.). For example, using
If(...)would allow your code to compile without an additional cast even if you hadOption Strict On(which you should).