[dba-VB] VB2005 Programmatically set text box font values

Stuart McLachlan stuart at lexacorp.com.pg
Sun Feb 3 17:42:31 CST 2008


On 3 Feb 2008 at 21:00, Pete Phillipps wrote:

> 	In VB6, the following code sets/unsets the text box to bold
> and/italic depending on the value of the checkboxes:
> 	txtMyText.Font.Bold = chkBold.Value
> 	txtMyText.Font.Italic = chkItalic.Value
> 
> 	How do you do the same in VB2005?
> 



   Private Sub chkBoxes_CheckedChanged(ByVal sender As 
System.Object, ByVal e As System.EventArgs) Handles 
chkBold.CheckedChanged, chkItalic.CheckedChanged

        Dim intFontAttribs As Integer
        intFontAttribs = IIf(chkBold.Checked, FontStyle.Bold, 0) + 
IIf(chkItalic.Checked, FontStyle.Italic, 0)
        txtmyText.Font = New Font(txtmyText.Font, intFontAttribs)

    End Sub



More information about the dba-VB mailing list