Graphics porblem

This simple sample works fine unless I try to draw a line.
The "real" program is based on using info from scrollbars to draw picutres.

Thanks for any suggestions.
Chuck Bodeen
*******************************************************************

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form
' common variables
Friend v1, v2, v3, v4, counter As Integer
Dim ep As PaintEventArgs
Dim epen As Pen
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

************************************************************************
any of the next 3 statements cause an error:
'"An unhandled exception of type
' System.NullReferenceException'
' occurred in system.windows.forms.dll
*************************************************************************
'epen.Color = System.Drawing.Color.Red
'epen.Width = 4
'e.Graphics.DrawLine(epen, 20, 100, 100, 100)
counter = counter + 1
TextBox3.Text = v1 + v2
TextBox4.Text = counter
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
v1 = VScrollBar1.Value
TextBox1.Text = v1
OnPaint(ep)
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
v2 = 2 * v1
TextBox2.Text = v2
OnPaint(ep)
'DrawLineFloat(ep)
End Sub


Chuck Bodeen
"Everybody comes to Las Vegas --- and usually stays with me!"
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories