• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 144
  • Last Modified:

How can i determine if anything is written on a picture box

I have a picture box on a form that is being used to capture a signature.  How can I determine whether someone has "signed" or written anything on the pictire box?  Can I compare the picture box against a "blank" picture box?  Any suggestions would be appreciated.  Thanks.
0
TheChos
Asked:
TheChos
  • 4
1 Solution
 
List244Commented:
How are they drawing on it? If they draw to it then it has been written on, hasn't it?
0
 
List244Commented:
In other words, as soon as you draw to the picture, you can set a variable to state it has been drawn on.
0
 
TheChosAuthor Commented:
Exactly, however, I don't want a mouse tap to count as a signature.
0
 
List244Commented:
What would count as a signature? This is something you must know in order to create.
The best way to go about capturing what is done is to monitor it as it is done. Perhaps
a weight system? Say you have :

Dim Ox As Long
Dim Oy As Long
Dim Weight As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PSet (X, Y), vbRed
Ox = X
Oy = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (Ox, Oy)-(X, Y)
Weight = Weight + Abs(Ox - X) + Abs(Oy - Y)
Ox = X
Oy = Y
End If
Form1.Caption = Weight
End Sub

Now you have a weight, then you just need to define what weight will be considered valid for
a signature.
0
 
List244Commented:
Or if you perhaps think people may try to cheat it do something like this:

Dim Ox As Long
Dim Oy As Long
Dim Weight As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.PSet (X, Y), vbRed
Ox = X
Oy = Y
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picture1.Line (Ox, Oy)-(X, Y)
If X > Picture1.ScaleWidth Or X < 0 Then GoTo 1
If Y > Picture1.ScaleHeight Or Y < 0 Then GoTo 1
Weight = Weight + Abs(Ox - X) + Abs(Oy - Y)
1
Ox = X
Oy = Y
End If
Form1.Caption = Weight
End Sub

That will make sure the weight only adds when they are inside the picture box's range.

Note that is just an example I am giving you. The caption is changed so that you can see
how it works if you put that in a project by itself. You would likely remove that for your
project.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now