Dim col1 As Long
Dim tb01, tb04, tb07, tb10 As Decimal
Tb01 = Val(TextBox01.Text)
Tb03 = Val(TextBox04.Text)
Tb07 = Val(TextBox07.Text)
Tb10 = Val(TextBox10.Text)
Dim checked01 As Decimal
Dim checked04 As Decimal
Dim checked07 As Decimal
Dim checked10 As Decimal
If CheckBox1.Checked Then
Checked01 = 1
col1 = col1 & tb01
ElseIf CheckBox1.Checked = False Then
Checked01 = 0
End If
If CheckBox2.Checked Then
Checked04 = 1
col1 = col1 & tb04
ElseIf CheckBox2.Checked = False Then
Checked04 = 0
End If
If CheckBox3.Checked Then
Checked07 = 1
col1 = col1 & tb07
ElseIf CheckBox3.Checked = False Then
Checked07 = 0
End If
If CheckBox4.Checked Then
Checked10 = 1
col1 = col1 & tb10
ElseIf CheckBox4.Checked = False Then
Checked10 = 0
End If
Dim checkedcol1_01 As Decimal = checked01
Dim checkedcol1_04 As Decimal = checked04
Dim checkedcol1_07 As Decimal = checked07
Dim checkedcol1_10 As Decimal = checked10
Dim checkedsum As Decimal = Val(checkedcol1_01 + checkedcol1_04 + checkedcol1_07 + checkedcol1_10)
MessageBox.Show (checkedsum & " boxes were checked! ...just for my reference")
Dim col1row1 As Decimal
Dim col1row2 As Decimal
Dim col1row3 As Decimal
Dim col1row4 As Decimal
If CheckBox1.Checked Then
col1row1 = (col1 And tb01) - col1 + tb01
ElseIf CheckBox1.Checked = False Then
col1row1 = 0
End If
If CheckBox2.Checked Then
col1row2 = (col1 And tb04) - col1 + tb04
ElseIf CheckBox2.Checked = False Then
col1row2 = 0
End If
If CheckBox3.Checked Then
col1row3 = (col1 And tb07) - col1 + tb07
ElseIf CheckBox3.Checked = False Then
col1row3 = 0
End If
If CheckBox4.Checked Then
col1row4 = (col1 And tb10) - col1 + tb10
ElseIf CheckBox4.Checked = False Then
col1row4 = 0
End If
If CheckBox1.CheckState = CheckState.Unchecked And CheckBox2.CheckState = CheckState.Unchecked And CheckBox3.CheckState = CheckState.Unchecked And CheckBox4.CheckState = CheckState.Unchecked Then
MsgBox("Please select at least one check box!", vbExclamation, "Error!")
Exit Sub
End If
Dim finalResults_col1 As Decimal = Val(col1row1 + col1row2 + col1row3 + col1row4) / checkedsum
MessageBox.Show(finalResults_col1 & " is a final value for column 1")