The start button starts the
code and the package starts
to move after this button is
clicked. These labels show the user
how many total packages
there are of that specific
type.
The reset button allows the user
to click it to start the process
over so that the package moves
These labels show the
to the beginning of the conveyor
percentage of unsealed and
belt. These red boxes are the
the number of unsealed
packages. sensors, these were used
within the code to detect
the different package types.
, 1 Public Class Form1
2 Dim Type As Integer
3 Dim Sealed As Boolean
4 Dim NumbSmall As Byte 'This adds the NumbSmall as a varible and stores it as a
byte
5 Dim NumbMedium As Byte 'This adds the NumbMedium as a variable and stores as byte
6 Dim NumbLarge As Byte 'This adds NumbLarge as a variable and stores it as a byte
7 Dim NumbTotal As Byte '
8 Dim NumbUnsealed As Byte
9 Dim NumbUnSeal As Byte
10
11 Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles
BtnStart.Click
12 Type = 0
13 Randomize()
14 Type = Type + Int(Rnd() * 4) + 1 'this defines the amount of images it shows
15 Sealed = Sealed + Int(Rnd() * 2) + 1 'this is a true or false for the
unsealed packages
16
17 TmrMove.Enabled = True
18
19 Select Case Type
20 Case 1 'This is a Small Package Case
21 PicPackage.Image = My.Resources.Small_Box1
22
23 Case 2 'Medium Package Case
24 PicPackage.Image = My.Resources.Medium_Box
25
26 Case 3 'Case for the Large Package
27 PicPackage.Image = My.Resources.Large_Box
28
29 Case Else
30 PicPackage.Image = My.Resources.Unsealed
31
32 End Select
33
34
35 End Sub
36
37 Private Sub CheckCollision()
38
39 If PicPackage.Bounds.IntersectsWith(PicSensorS.Bounds) = True And Type = 1
Then
40 TmrMove.Enabled = False
41 MessageBox.Show("Small Package Detected")
42 NumbSmall = NumbSmall + 1 'this adds up the Small Packages so that the
total shows next to the label
43 LblNumbSmall.Text = NumbSmall
44 NumbTotal = NumbTotal + 1
45 LblTotal.Text = NumbTotal.ToString
46
47 ElseIf PicPackage.Bounds.IntersectsWith(PicSensorM.Bounds) = True And Type =
2 Then
48 TmrMove.Enabled = False
49 MessageBox.Show("Medium Package Detected")
50 NumbMedium = NumbMedium + 1 'this adds up the Medium Packages so that
the total shows next to the label
51 LblNumbMedium.Text = NumbMedium
52 NumbTotal = NumbTotal + 1
53 LblTotal.Text = NumbTotal.ToString
54
55 ElseIf PicPackage.Bounds.IntersectsWith(PicSensorL.Bounds) = True And Type =
3 Then
56 TmrMove.Enabled = False
57 MessageBox.Show("Large Package Detected")
58 NumbLarge = NumbLarge + 1 'this adds up the Large Packages so that the
total shows next to the label
59 LblNumbLarge.Text = NumbLarge
60 NumbTotal = NumbTotal + 1
61 LblTotal.Text = NumbTotal.ToString
62