|
-
Jun 6th, 2008, 04:23 PM
#1
Thread Starter
Junior Member
[2008] How do I change a text boxs font size?
Code:
TextBox1.Font.Size.Equals(1)
Whats wrong?
-
Jun 6th, 2008, 04:35 PM
#2
Re: [2008] How do I change a text boxs font size?
textbox1.font = new font(textbox1.font.name, 10, textbox1.font.style)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 6th, 2008, 11:33 PM
#3
Re: [2008] How do I change a text boxs font size?
 Originally Posted by Zezombia
Code:
TextBox1.Font.Size.Equals(1)
Whats wrong? 
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.
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:
If TextBox1.Font.Size.Equals(1) Then
'The Font Size is 1.
End If
That said, you wouldn't use the Equals method to do that anyway, as you simply do this:
vb.net Code:
If TextBox1.Font.Size = 1 Then
'The Font Size is 1.
End If
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|