This code originated from a post by toughcoder, I have modified it a little.
The bit I can't work out is I am getting an error message 'Object variable or with block variable not set.
Any ideas.Code:Option Explicit Dim blnDrawing As Boolean Dim x1 As Single, y1 As Single Dim Shape2 As Shape Private Sub Form_Load() ' Shape2.FillStyle = vbFSTransparent ' Shape2.FillColor = 0 ' Shape2.BorderStyle = 1 ' Shape2.BorderWidth = 1 End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) x1 = X y1 = Y Shape2.Left = x1 Shape2.Top = y1 blnDrawing = True End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If blnDrawing = True Then Shape2.Width = X - x1 Shape2.Height = Y - y1 End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) blnDrawing = False Shape2.FillStyle = vbFSSolid Shape2.FillColor = vbRed Shape2.BorderColor = vbRed End Sub




Reply With Quote