1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 16 - Adding Graphics and Animation Effects

By , About.com Guide

5 of 5

The Code and Result of Monitoring the Paint Event

Paint

~~~~~~~~~~~~~~~~~~~~~~~~~
Dim paintcount As Integer = 0
Private Sub Form1_Paint( _
  ByVal sender As Object, _
  ByVal e As System.Windows.Forms.PaintEventArgs) _
  Handles MyBase.Paint
  paintcount += 1
  Debug.Write("Paint Event executed " _
    & CStr(paintcount) & vbCrLf)
End Sub
~~~~~~~~~~~~~~~~~~~~~~~~~

You will then see just when and how often the Paint event is called automatically as you resize, move, or minimize the window. In the My Moving Icon example in the book, because the timer is enabled from the first button click and never disabled, the form is repainted every 75 milliseconds no matter what else the program is doing. (This is why the example doesn't use a Paint event.)

Considerations like these can seriously impact the performance of your program ... or explain why it's not working the way you expect!

Explore Visual Basic
By Category
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Adding Graphics and Animation Effects

©2009 About.com, a part of The New York Times Company.

All rights reserved.