Hi all,
I am a beginner in VB.Net. Allow me to ask a question about Font Style.
I hope that you guys -as a expert in VB.Net- can help me.
Here is my problem:
I want to change a font style in a textbox by clicking (check and uncheck) a checkbox.
My code is like this :
Private Sub cbxBold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxBold.CheckedChanged
If tbxTeks.Font.Bold Then
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, tbxTeks.Font.Style Xor FontStyle.Bold)
Else
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, tbxTeks.Font.Style Or FontStyle.Bold)
End If
End Sub
But I got an error message :
An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll
Additional information: Overflow or underflow in the arithmetic operation.
I have also tried with this way, but I got a same error.
If cbxBold.Checked Then
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, FontStyle.Bold)
End If
The error occurs at the line where NEW takes place.
Can anybody help me please !
Thanks in advance,
Juliando
I am a beginner in VB.Net. Allow me to ask a question about Font Style.
I hope that you guys -as a expert in VB.Net- can help me.
Here is my problem:
I want to change a font style in a textbox by clicking (check and uncheck) a checkbox.
My code is like this :
Private Sub cbxBold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxBold.CheckedChanged
If tbxTeks.Font.Bold Then
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, tbxTeks.Font.Style Xor FontStyle.Bold)
Else
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, tbxTeks.Font.Style Or FontStyle.Bold)
End If
End Sub
But I got an error message :
An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll
Additional information: Overflow or underflow in the arithmetic operation.
I have also tried with this way, but I got a same error.
If cbxBold.Checked Then
tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, FontStyle.Bold)
End If
The error occurs at the line where NEW takes place.
Can anybody help me please !
Thanks in advance,
Juliando