Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleMake a simple scribble application
Keywordsscribble, draw
CategoriesGraphics
 
Start drawing in the MouseDown event handler. Continue drawing in MouseMove. End drawing in MouseUp.

This program stores the coordinates of the points drawn in the PointX and PointY arrays.

 
Private PointX() As Single
Private PointY() As Single
Private NumPoints As Integer

Private Drawing As Boolean

Private Sub Form_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Let MouseMove know we are drawing.
    Drawing = True
    
    ' Start from scratch
    NumPoints = 0
    Cls

    ' Start drawing here.
    CurrentX = X
    CurrentY = Y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Make sure we are drawing.
    If Not Drawing Then Exit Sub

    ' Save the new point.
    NumPoints = NumPoints + 1
    ReDim Preserve PointX(1 To NumPoints)
    ReDim Preserve PointY(1 To NumPoints)
    PointX(NumPoints) = X
    PointX(NumPoints) = X

    ' Draw to the point.
    Line -(X, Y)
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Stop drawing.
    Drawing = False
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated