[Year 12 SofDev] vb.net error

Timmer-Arends timmer at melbpc.org.au
Thu Jun 10 17:39:45 EST 2010


Hello Damien
I don't know for sure, but having just wrestled with vb.net for the first time myself I understand some of your frustrations. Many vb settings are built up from vb 'bit constants' that are 'added' together to produce some overall effect.
In your case it might be, for example, that fontstyle.bold = "0001 0000' (or whatever) and fontstyle.italics = "0000 0100".
When you AND them, therefore, you get '0000 0000', whereas OR would produce '0001 0100', which I imagine would set both styles.

Just a guess at this stage. Hope it helps.

Regards
Robert T-A
Brighton SC
  ----- Original Message ----- 
  From: ATKINSON-BUCK, Damien 
  To: Year 12 Software Development Teachers' Mailing List 
  Sent: Thursday, June 10, 2010 3:47 PM
  Subject: [Year 12 SofDev] vb.net error


  Hi folks,

              I’m just starting VB.Net with my year 11’s and have only ever used vb 6 before. The following code doesn’t make sense to me

  I’m trying to just teach if else statements so using a couple of check boxes want the font in a textbox to change. In vb 6 you used to just say textbox1.fontbold=true and txtfontItalic = true not it seems totally different



      Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click

          Dim fnt As Font

          fnt = txtSomeWriting.Font

          If chkItalics.Checked = True And chkBold.Checked = True Then

              txtSomeWriting.Font = New Font(fnt.Name, 8, FontStyle.Bold Or FontStyle.Italic)

          ElseIf chkBold.Checked = True Then

              txtSomeWriting.Font = New Font(fnt.Name, 8, FontStyle.Bold)

          ElseIf chkItalics.Checked = True Then

              txtSomeWriting.Font = New Font(fnt.Name, 8, FontStyle.Italic)

          Else

              txtSomeWriting.Font = New Font(fnt.Name, 8, FontStyle.Regular)

          End If

   

      End Sub

   

  I don’t get why it is only working if I have an OR between the 2 fontstyles, not an AND when I am trying to make the textbox Bold Italic

   

  Does anyone have any ideas? Thanks in advance.

  Regards

  Damien

   

        Damien Atkinson-Buck
        Member of Academic Staff (Secondary)


------------------------------------------------------------------------
       

              
             PO BOX 91 The Ridgeway, Ivanhoe, Victoria 3079 Australia
              Telephone +61 3 9490 3848 Facsimile +61 3 9490 3490
              mailto:damien.atkinson-buck at ivanhoe.com.au
              http://myivanhoe.net
             
       
       
       

   





  Privacy, Virus and Copyright Warning

  The information contained in this electronic message (e-mail), and any files transmitted with it:

  * is intended for the named recipients only. If you have received this in error, please advise the sender and delete it and any copies immediately;
  * Any personal information in this email must be used in accordance with the Privacy Act 1988 and this always applies even if it has been sent to you in error.
  * represents the views of the sender and does not necessarily represent the views or formal advice of Ivanhoe Grammar School;
  * may be subject to Copyright, so no further use should be made of it without the author's permission.

  The School does not represent or warrant that the email or any files attached do not contain errors or are free from computer viruses or other defects nor does it accept responsibility for any loss or damage resulting directly or indirectly from the use of the email or any attached files. 


------------------------------------------------------------------------------


  _______________________________________________
  http://www.edulists.com.au - FAQ, Subscribe, Unsubscribe
  IT Software Development Mailing List kindly supported by
  http://www.vcaa.vic.edu.au - Victorian Curriculum and Assessment Authority and
  http://www.vitta.org.au/vce/studies/infotech/softwaredevel3-4.html 
  http://www.vitta.org.au  - VITTA Victorian Information Technology Teachers Association Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20100610/61ef52b3/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 21432 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20100610/61ef52b3/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 9302 bytes
Desc: not available
Url : http://www.edulists.com.au/pipermail/sofdev/attachments/20100610/61ef52b3/attachment-0001.jpe 


More information about the sofdev mailing list