Port parallel
Public Class Form1
Public Declare Sub Out32 Lib "INPOUT32.DLL"
Alias "Out32"
(ByVal PortAddres As
Integer, ByVal
Value As Integer)
Dim abc As Integer
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim
acak As New
Random
abc = 0
Timer1.Enabled = True
Panel1.BackColor = Color.Black
Panel2.BackColor = Color.Black
Panel3.BackColor = Color.Black
Panel4.BackColor = Color.Black
Panel5.BackColor = Color.Black
Panel6.BackColor = Color.Black
Panel7.BackColor = Color.Black
Panel8.BackColor = Color.Black
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If
Button1.Text = "On 1" Then
abc = abc + 1
Timer1.Enabled = True
Panel1.BackColor = Color.Red
Button1.Text = "Off 1"
ElseIf
Button1.Text = "Off 1" Then
abc = abc - 1
Timer1.Enabled = True
Panel1.BackColor = Color.Black
Button1.Text = "On 1"
End If
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If
Button2.Text = "On 2" Then
abc = abc + 2
Timer1.Enabled = True
Panel2.BackColor = Color.Red
Button2.Text = "Off 2"
ElseIf Button2.Text = "Off
2" Then
abc = abc - 2
Timer1.Enabled = True
Panel2.BackColor = Color.Black
Button2.Text = "On 2"
End If
End Sub
Private Sub Button3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If
Button3.Text = "On 3" Then
abc = abc + 4
Timer1.Enabled = True
Panel3.BackColor = Color.Red
Button3.Text = "Off 3"
ElseIf
Button3.Text = "Off 3" Then
abc = abc - 4
Timer1.Enabled = True
Panel3.BackColor = Color.Black
Button3.Text = "On 3"
End If
End Sub
Private Sub Button4_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If
Button4.Text = "On 4" Then
abc = abc + 8
Timer1.Enabled = True
Panel4.BackColor = Color.Red
Button4.Text = "Off 4"
ElseIf
Button4.Text = "Off 4" Then
abc = abc - 8
Timer1.Enabled = True
Panel4.BackColor = Color.Black
Button4.Text = "On 4"
End If
End Sub
Private Sub Button5_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
If
Button5.Text = "On 5" Then
abc = abc + 16
Timer1.Enabled = True
Panel5.BackColor = Color.Red
Button5.Text = "Off 5"
ElseIf
Button5.Text = "Off 5" Then
abc = abc - 16
Timer1.Enabled = True
Panel5.BackColor = Color.Black
Button5.Text = "On 5"
End If
End Sub
Private Sub Button6_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
If
Button6.Text = "On 6" Then
abc = abc + 32
Timer1.Enabled = True
Panel6.BackColor = Color.Red
Button6.Text = "Off 6"
ElseIf
Button6.Text = "Off 6" Then
abc = abc - 32
Timer1.Enabled = True
Panel6.BackColor = Color.Black
Button6.Text = "On 6"
End If
End Sub
Private Sub Button7_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click
If
Button7.Text = "On 7" Then
abc = abc + 64
Timer1.Enabled = True
Panel7.BackColor = Color.Red
Button7.Text = "Off 7"
ElseIf
Button7.Text = "Off 7" Then
abc = abc - 64
Timer1.Enabled = True
Panel7.BackColor = Color.Black
Button7.Text = "On 7"
End If
End Sub
Private Sub Button8_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button8.Click
If
Button8.Text = "On 8" Then
abc = abc - 128
Timer1.Enabled = True
Panel8.BackColor = Color.Red
Button8.Text = "Off 8"
ElseIf
Button8.Text = "Off 8" Then
abc = abc - 128
Timer1.Enabled = True
Panel8.BackColor = Color.Black
Button8.Text = "On 8"
End If
End Sub
Private Sub Button9_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button9.Click
If
Button9.Text = "On All" Then
abc = 255
Timer1.Enabled = True
Button1.Text = "Off 1"
Button2.Text = "Off 2"
Button3.Text = "Off 3"
Button4.Text = "Off 4"
Button5.Text = "Off 5"
Button6.Text = "Off 6"
Button7.Text = "Off 7"
Button8.Text = "Off 8"
Panel1.BackColor = Color.Red
Panel2.BackColor = Color.Red
Panel3.BackColor = Color.Red
Panel4.BackColor = Color.Red
Panel5.BackColor = Color.Red
Panel6.BackColor = Color.Red
Panel7.BackColor = Color.Red
Panel8.BackColor = Color.Red
Button9.Text = "Off All"
ElseIf
Button9.Text = "Off All" Then
abc = 0
Timer1.Enabled = True
Button1.Text = "On 1"
Button2.Text = "On 2"
Button3.Text = "On 3"
Button4.Text = "On 4"
Button5.Text = "On 5"
Button6.Text = "On 6"
Button7.Text = "On 7"
Button8.Text = "On 8"
Panel1.BackColor = Color.Black
Panel2.BackColor = Color.Black
Panel3.BackColor = Color.Black
Panel4.BackColor = Color.Black
Panel5.BackColor = Color.Black
Panel6.BackColor = Color.Black
Panel7.BackColor = Color.Black
Panel8.BackColor = Color.Black
Button9.Text = "On All"
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox1.CheckedChanged
If
CheckBox1.Checked = True Then
abc = abc + 1
Timer1.Enabled = True
Panel1.BackColor = Color.Red
ElseIf
CheckBox1.Checked = False Then
abc = abc - 1
Timer1.Enabled = True
Panel1.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox2.CheckedChanged
If
CheckBox2.Checked = True Then
abc = abc + 2
Timer1.Enabled = True
Panel2.BackColor = Color.Red
ElseIf
CheckBox2.Checked = False Then
abc = abc - 2
Timer1.Enabled = True
Panel2.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox3_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox3.CheckedChanged
If
CheckBox3.Checked = True Then
abc = abc + 4
Timer1.Enabled = True
Panel3.BackColor = Color.Red
ElseIf
CheckBox3.Checked = False Then
abc = abc - 4
Timer1.Enabled = True
Panel3.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox4_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox4.CheckedChanged
If
CheckBox4.Checked = True Then
abc = abc + 8
Timer1.Enabled = True
Panel4.BackColor = Color.Red
ElseIf
CheckBox4.Checked = False Then
abc = abc - 8
Timer1.Enabled = True
Panel4.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox5_CheckedChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles CheckBox5.CheckedChanged
If
CheckBox5.Checked = True Then
abc = abc + 16
Timer1.Enabled = True
Panel5.BackColor = Color.Red
ElseIf
CheckBox5.Checked = False Then
abc = abc - 16
Timer1.Enabled = True
Panel5.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox6_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles CheckBox6.CheckedChanged
If
CheckBox6.Checked = True Then
abc = abc + 32
Timer1.Enabled = True
Panel6.BackColor = Color.Red
ElseIf
CheckBox6.Checked = False Then
abc = abc - 32
Timer1.Enabled = True
Panel6.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox7_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox7.CheckedChanged
If
CheckBox7.Checked = True Then
abc = abc + 64
Timer1.Enabled = True
Panel7.BackColor = Color.Red
ElseIf
CheckBox7.Checked = False Then
abc = abc - 64
Timer1.Enabled = True
Panel7.BackColor = Color.Black
End If
End Sub
Private Sub CheckBox8_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
CheckBox8.CheckedChanged
If
CheckBox8.Checked = True Then
abc = abc + 128
Timer1.Enabled = True
Panel8.BackColor = Color.Red
ElseIf
CheckBox8.Checked = False Then
abc = abc - 128
Timer1.Enabled = True
Panel8.BackColor = Color.Black
End If
End Sub
Private Sub Button10_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
End Sub
End Class
Tidak ada komentar:
Posting Komentar