Public Class frmBarChart

  Private Sub btnPrint_Click(ByVal sender As System.Object,
                             ByVal e As System.EventArgs) Handles btnPrint.Click
    PrintDocument1.Print()
  End Sub

  Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
                                       ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    Dim quantity() As Single = {33, 207, 180}
    Dim gr As Graphics = e.Graphics
    gr.DrawLine(Pens.Black, 340, 310, 510, 310)    'x-axis
    gr.DrawLine(Pens.Black, 340, 310, 340, 200)    'y-axis
    gr.DrawLine(Pens.Black, 335, 260, 345, 260)    'tick mark
    gr.DrawString("$100", Me.Font, Brushes.Black, 305, 255)
    gr.DrawString("Financing for Public Schools (K - 12)", Me.Font, Brushes.Black, 300, 175)
    For i As Integer = 0 To quantity.Count - 1
      gr.FillRectangle(Brushes.Blue, 360 + i * 40,
                       (310 - quantity(i) / 2), 20, quantity(i) / 2)
    Next
    gr.DrawString("Federal    State    Local", Me.Font,
                   Brushes.Black, 350, 315)
    gr.DrawString("(Expenditures in billions)", Me.Font,
                   Brushes.Black, 350, 330)
  End Sub

  Private Sub btnPreview_Click(ByVal sender As System.Object,
                               ByVal e As System.EventArgs) Handles btnPreview.Click
    PrintPreviewDialog1.Document = PrintDocument1
    PrintPreviewDialog1.ShowDialog()
  End Sub

End Class
