Whats wrong? :confused:Code:TextBox1.Font.Size.Equals(1)
Printable View
Whats wrong? :confused:Code:TextBox1.Font.Size.Equals(1)
textbox1.font = new font(textbox1.font.name, 10, textbox1.font.style)
Font objects are immutable, which means that, once you have created them, you cannot change them. If you want to change anything about a Font you must create a new Font object with the desired configuration, as .paul. has demonstrated.Quote:
Originally Posted by Zezombia
Your code would be wrong anyway, even if Fonts were mutable. The correct code in that case would have been:What you're code is doing is testing whether the current Size is equal to 1. That expression will return either True or False, which you're obviously ignoring anyway. Your code would only be used where you wanted to test the current Size of the Font, e.g.vb.net Code:
TextBox1.Font.Size = 1That said, you wouldn't use the Equals method to do that anyway, as you simply do this:vb.net Code:
If TextBox1.Font.Size.Equals(1) Then 'The Font Size is 1. End Ifvb.net Code:
If TextBox1.Font.Size = 1 Then 'The Font Size is 1. End If