Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulate a font style

Status
Not open for further replies.

jkusmanto

MIS
Feb 27, 2006
5
BE
Hi to all,

As a beginner in VB please let me ask some questions.
I hope that somebody can help me.

I use Visual Studio 2003 in Windows 2000 and .NET framework 1.0

I have a code 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
------------------

-->tbxTeks is a TextBox.
The goal of this code is the change the font in a textbox tbxTeks.
If the checkbox cbxBold checked or unchecked, the text in the textbox tbxTeks should change.

When I run this code, I got an error message as follow :
---------------
An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll

Additional information: Overflow or underflow in the arithmetic operation.
---------------

I have tried many ways, but the error always occurs at the line where the NEW take place.

Can you help me please ?

Thanks in advance for helping me.

Regards,
Juliando.


 
hi,

how about this:

Code:
Private Sub cbxBold_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxBold.CheckedChanged

  if cbxBold.Checked Then
     tbxTeks.Font = New System.Drawing.Font(tbxTeks.Font, FontStyle.Bold)
  End If

End Sub
 
Thanks for your reply/answer Mastakilla,

The same error occurs.
The error message is the same, and the error takes place at the line where the NEW sit.

Rgds,
Juliando
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top