title: Visual Basic: Freeform Pen?/Data Variance ignored when code "Handles" a state of that data?
body: <pre><code>Private Sub Form1_Click(ByVal sender As System.Object, ByVal e As     System.EventArgs) Handles MyBase.Click
      clicks += 1
      Select Case clicks Mod 2
          Case 1
              unclicked = 0
      End Select
      If Not already = 1 Then
          Do Until unclicked = 1
              already = 1
              If Not notgonnacrash = 1 Then
                  area = Me.CreateGraphics
              End If
              Dim bun As Pen
              bun = New Pen(Drawing.Color.SandyBrown)
              notgonnacrash = 1
              Dim mouseposit = New Point(MousePosition.X, MousePosition.Y)
              If Not mouseposit = New Point(MousePosition.X, MousePosition.Y) Then
                  area.DrawLine(bun, MousePosition.X, MousePosition.Y, mouseposit.X, mouseposit.Y)
                  mouseposit = New Point(MousePosition.X, MousePosition.Y)
              End If
              Select Case clicks Mod 2
                  Case 1
                  Case 0
                      unclicked = 1
                      already = 0
              End Select
              '   unclicked = 0
  
              btnstart.Text = "clickd"
          Loop
      End If
  End Sub
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>Private Sub Form1_MouseClickBun(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  
      If Not n = 1 Then
  
          area = Me.CreateGraphics
      End If
      Dim bun As Pen
      bun = New Pen(Drawing.Color.SandyBrown)
      n = 1
      Dim f As Integer = 0
      Do
          Dim mouseposit = New Point(MousePosition.X, MousePosition.Y)
          If e.Button = MouseButtons.Left Then
              If Not mouseposit = New Point(MousePosition.X, MousePosition.Y) Then
                  area.DrawLine(bun, MousePosition.X, MousePosition.Y, mouseposit.X, mouseposit.Y)
                  mouseposit = New Point(MousePosition.X, MousePosition.Y)
              End If
          End If
      Loop
  End Sub
  </code></pre>
  
  <p>I have a school project due soon which I am ambitious enough to attempt this for. Herein lies the main problem...: </p>
  
  <p>I've tried many variations of this program (including an adaptation with insteaed of Handles mybase.click I used Handles Me.Mousedown and me.mouseup and beginning drawing based off of whether or not you had the left mouse down), but in all of the programs it seems that it solidifies all received data at the beginning and doesn't adjust. A request of mine of the computer, for example: if the left button is no longer pressed down, you should stop executing this code. but apparently the left being pressed down never changes in that sub of Handles left down-- it keeps on drawing. its like the sub cannot fathom the case which initiated it no longer being valid. Why? Am I just a terrible programmer? Why won't this above one stop drawing either? I'm desperate, please!
  (If it wasn't clear this is supposed to be a freeform pen that you can draw with on the form, turning it on or off whenever you want, whether simply by holding down on the left button or toggling it on or off with the left button, whichever I can get to work.)</p>