1
Answer

Graphics Problem vb2010 express

Warren

Warren

11y
1.3k
1
I am trying to learn how to draw/shape in vb2010. The first code example is from a book, "VB2010 Step by Step".  The second and third are from MSDN.

Public Class Form1
    Dim GraphicsFun As Graphics
    Dim PenColor As New Pen(Color.Red)
    GraphicsFun = Me.CreateGraphics
    GraphicsFun.DrawLine(PenColor,20,30,100,80)

    Dim pen As New Pen(Color.FromArgb(255, 0, 0, 0))
      e.Graphics.DrawLine(pen, 20, 10, 300, 100)

    Private Sub DrawRectangle()
        Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
        Dim formGraphics As System.Drawing.Graphics
        formGraphics = Me.CreateGraphics()
        formGraphics.DrawRectangle(myPen, New Rectangle(0, 0, 200, 300))
        myPen.Dispose()
        formGraphics.Dispose()
    End Sub

End Class


In the first two errors are "Declaration expected",  GraphicsFun and e respectively.

On the third bit of code runs but I thought I would get a rectangle.  I get a Blank form

Questions:
1. What am i missing, doing wrong?

2. what does "e" stand for?

3.  Why do I get a blank form?



Answers (1)