This post discussed on how to display the total task when a checkbox control is checked.
This is the code:
----------------
Imports System.Windows.Forms.CheckBox
Imports MySql.Data.MySqlClient
Imports System.IO
Public Class Production_Sequence
Dim totaltask As Integer = 0
Dim Production_Sequence() As Integer = {13, 2, 2, 2, 2, 3, 4, 5, 2, 2, 2, 2, 3, 9, 4, _
2, 1, 4, 13, 10, 5, 4, 4, 1, 3, 3, 3, 1, 1, 5, 1, 3, 4, 4, 1, 2, 1}
Dim checkbox() As CheckBox = New CheckBox() {CheckBoxProductionSequence1, CheckBoxProductionSequence2, CheckBoxProductionSequence2_1, _
CheckBoxProductionSequence3, CheckBoxProductionSequence4, CheckBoxProductionSequence4_1, CheckBoxProductionSequence5, CheckBoxProductionSequence6, _
CheckBoxProductionSequence7, CheckBoxProductionSequence8, CheckBoxProductionSequence9, CheckBoxProductionSequence10, CheckBoxProductionSequence11, _
CheckBoxProductionSequence12, CheckBoxProductionSequence13, CheckBoxProductionSequence14, CheckBoxProductionSequence15, CheckBoxProductionSequence16, _
CheckBoxProductionSequence17, CheckBoxProductionSequence18, CheckBoxProductionSequence19, CheckBoxProductionSequence20, CheckBoxProductionSequence21, _
CheckBoxProductionSequence22, CheckBoxProductionSequence23, CheckBoxProductionSequence24, CheckBoxProductionSequence25, CheckBoxProductionSequence26, _
CheckBoxProductionSequence27, CheckBoxProductionSequence28, CheckBoxProductionSequence29, CheckBoxProductionSequence30, CheckBoxProductionSequence31, _
CheckBoxProductionSequence32, CheckBoxProductionSequence33, CheckBoxProductionSequence34, CheckBoxProductionSequence35}
Public Function TotalProductionTask(ByVal x) As Short
Try
If checkbox(x).Checked = True Then
totaltask = totaltask + Production_Sequence(x)
Else
totaltask = totaltask - Production_Sequence(x)
End If
TotalProductionTask = totaltask
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Private Sub CheckBoxProductionSequence1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence1.CheckedChanged
Try
checkbox(0) = CheckBoxProductionSequence1
TextBoxTotalTask.Text = TotalProductionTask(0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence2.CheckedChanged
Try
checkbox(1) = CheckBoxProductionSequence2
TextBoxTotalTask.Text = TotalProductionTask(1)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence2_1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence2_1.CheckedChanged
Try
checkbox(2) = CheckBoxProductionSequence2_1
TextBoxTotalTask.Text = TotalProductionTask(2)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence3.CheckedChanged
Try
checkbox(3) = CheckBoxProductionSequence3
TextBoxTotalTask.Text = TotalProductionTask(3)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence4.CheckedChanged
Try
checkbox(4) = CheckBoxProductionSequence4
TextBoxTotalTask.Text = TotalProductionTask(4)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence4_1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence4_1.CheckedChanged
Try
checkbox(5) = CheckBoxProductionSequence4_1
TextBoxTotalTask.Text = TotalProductionTask(5)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence5.CheckedChanged
Try
checkbox(6) = CheckBoxProductionSequence5
TextBoxTotalTask.Text = TotalProductionTask(6)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence6.CheckedChanged
Try
checkbox(7) = CheckBoxProductionSequence6
TextBoxTotalTask.Text = TotalProductionTask(7)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence7.CheckedChanged
Try
checkbox(8) = CheckBoxProductionSequence7
TextBoxTotalTask.Text = TotalProductionTask(8)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence8.CheckedChanged
Try
checkbox(9) = CheckBoxProductionSequence8
TextBoxTotalTask.Text = TotalProductionTask(9)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence9.CheckedChanged
Try
checkbox(10) = CheckBoxProductionSequence9
TextBoxTotalTask.Text = TotalProductionTask(10)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence10.CheckedChanged
Try
checkbox(11) = CheckBoxProductionSequence10
TextBoxTotalTask.Text = TotalProductionTask(11)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence11.CheckedChanged
Try
checkbox(12) = CheckBoxProductionSequence11
TextBoxTotalTask.Text = TotalProductionTask(12)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence12.CheckedChanged
Try
checkbox(13) = CheckBoxProductionSequence12
TextBoxTotalTask.Text = TotalProductionTask(13)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence13.CheckedChanged
Try
checkbox(14) = CheckBoxProductionSequence13
TextBoxTotalTask.Text = TotalProductionTask(14)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence14.CheckedChanged
Try
checkbox(15) = CheckBoxProductionSequence14
TextBoxTotalTask.Text = TotalProductionTask(15)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence15.CheckedChanged
Try
checkbox(16) = CheckBoxProductionSequence15
TextBoxTotalTask.Text = TotalProductionTask(16)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence16.CheckedChanged
Try
checkbox(17) = CheckBoxProductionSequence16
TextBoxTotalTask.Text = TotalProductionTask(17)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence17_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence17.CheckedChanged
Try
checkbox(18) = CheckBoxProductionSequence17
TextBoxTotalTask.Text = TotalProductionTask(18)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence18_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence18.CheckedChanged
Try
checkbox(19) = CheckBoxProductionSequence18
TextBoxTotalTask.Text = TotalProductionTask(19)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence19_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence19.CheckedChanged
Try
checkbox(20) = CheckBoxProductionSequence19
TextBoxTotalTask.Text = TotalProductionTask(20)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence20_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence20.CheckedChanged
Try
checkbox(21) = CheckBoxProductionSequence20
TextBoxTotalTask.Text = TotalProductionTask(21)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence21_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence21.CheckedChanged
Try
checkbox(22) = CheckBoxProductionSequence21
TextBoxTotalTask.Text = TotalProductionTask(22)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence22_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence22.CheckedChanged
Try
checkbox(23) = CheckBoxProductionSequence22
TextBoxTotalTask.Text = TotalProductionTask(23)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence23_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence23.CheckedChanged
Try
checkbox(24) = CheckBoxProductionSequence23
TextBoxTotalTask.Text = TotalProductionTask(24)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence24_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence24.CheckedChanged
Try
checkbox(25) = CheckBoxProductionSequence24
TextBoxTotalTask.Text = TotalProductionTask(25)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence25_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence25.CheckedChanged
Try
checkbox(26) = CheckBoxProductionSequence25
TextBoxTotalTask.Text = TotalProductionTask(26)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence26_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence26.CheckedChanged
Try
checkbox(27) = CheckBoxProductionSequence26
TextBoxTotalTask.Text = TotalProductionTask(27)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence27_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence27.CheckedChanged
Try
checkbox(28) = CheckBoxProductionSequence27
TextBoxTotalTask.Text = TotalProductionTask(28)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence28_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence28.CheckedChanged
Try
checkbox(29) = CheckBoxProductionSequence28
TextBoxTotalTask.Text = TotalProductionTask(29)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence29_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence29.CheckedChanged
Try
checkbox(30) = CheckBoxProductionSequence29
TextBoxTotalTask.Text = TotalProductionTask(30)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence30_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence30.CheckedChanged
Try
checkbox(31) = CheckBoxProductionSequence30
TextBoxTotalTask.Text = TotalProductionTask(31)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence31_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence31.CheckedChanged
Try
checkbox(32) = CheckBoxProductionSequence31
TextBoxTotalTask.Text = TotalProductionTask(32)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence32_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence32.CheckedChanged
Try
checkbox(33) = CheckBoxProductionSequence32
TextBoxTotalTask.Text = TotalProductionTask(33)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence33_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence33.CheckedChanged
Try
checkbox(34) = CheckBoxProductionSequence33
TextBoxTotalTask.Text = TotalProductionTask(34)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence34_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence34.CheckedChanged
Try
checkbox(35) = CheckBoxProductionSequence34
TextBoxTotalTask.Text = TotalProductionTask(35)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub CheckBoxProductionSequence35_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBoxProductionSequence35.CheckedChanged
Try
checkbox(36) = CheckBoxProductionSequence35
TextBoxTotalTask.Text = TotalProductionTask(36)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Friday, September 21, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment