Public Class Form2
Private g As Graphics
Private mySerialPort As New SerialPort
Dim instance As SerialPort
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
g = Me.CreateGraphics()
Me.Height = 500
Me.Width = 860
Me.BackColor = Color.Aqua
Call CommPortSetup()
Dim i As Integer
Try
mySerialPort.Open()
Catch ex As Exception
i = MessageBox.Show(ex.Message)
End Try
If i = 1 Then
Form1.Show()
Me.Dispose()
End If
End Sub
Private Sub CommPortSetup()
With mySerialPort
'a = ComboBox1.Text
'b = ComboBox1.Text
.PortName = "COM" & 5 REM Module1.uname1
.BaudRate = 9600 REM Module1.uname2
.DataBits = 8
.Parity = Parity.None
.StopBits = StopBits.One
.Handshake = Handshake.None
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.PictureBox1.Image = My.Resources.L1
Timer3.Start()
Timer4.Start()
Try
mySerialPort.Write("1")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.PictureBox1.Image = My.Resources.L2
Timer3.Stop() REM belt stop
Timer4.Stop()
Try
mySerialPort.Write("2")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Timer1.Start()
Timer2.Start()
Try
mySerialPort.Write("3")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Timer1.Stop() REM belt stop
Timer2.Stop()
Try
mySerialPort.Write("4")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.PictureBox2.Image = My.Resources.a1
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Me.PictureBox2.Image = My.Resources.a2
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Me.PictureBox1.Image = My.Resources.L1
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
Me.PictureBox1.Image = My.Resources.L3
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.PictureBox3.Image = My.Resources.TV1
Timer5.Start()
Timer6.Start()
Try
mySerialPort.Write("5")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.PictureBox3.Image = My.Resources.TV1
Timer5.Stop() REM belt stop
Timer6.Stop()
Try
mySerialPort.Write("6")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
Me.PictureBox3.Image = My.Resources.TV2
End Sub
Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
Me.PictureBox3.Image = My.Resources.TV3
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Form1.Show()
Me.Hide()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Me.PictureBox1.Image = My.Resources.L1
Timer3.Start()
Timer4.Start()
Timer1.Start()
Timer2.Start()
Me.PictureBox3.Image = My.Resources.TV1
Timer5.Start()
Timer6.Start()
Try
mySerialPort.Write("8")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Me.PictureBox1.Image = My.Resources.L2
Timer3.Stop() REM belt stop
Timer4.Stop()
Timer1.Stop() REM belt stop
Timer2.Stop()
Me.PictureBox3.Image = My.Resources.TV1
Timer5.Stop() REM belt stop
Timer6.Stop()
Try
mySerialPort.Write("9")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class