Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27329

VS 2010 Simple IF-THEN statements. What am I missing?

$
0
0
I am attempting to calculate some basic math functions and have them output to textboxes at the bottom of my form.

There are TWO problems that occur (no vb debug errors, just nothing happening):
1. Base pay, overtime pay, weekend/holiday/vacation total, & total pay are not updating
2. I want to assign a checkbox a value of 1 for True or 0 for False to be added depending on the checked state, but no luck

Anyway, here is an image of my form:

Attachment 97159

Here is my code for the Submit button (sorry for the length):
Code:

Private Sub btnSubmit_Click(sender As System.Object, e As System.EventArgs) Handles btnSubmit.Click
        If txtEmployee.Text = "" Or txtSupervisor.Text = "" Or txtWeek.Text = "" Or txtClient.Text = "" Or txtContract.Text = "" Or txtProject.Text = "" Then
            MessageBox.Show("One or more fields are missing. Check form for blank fields.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Else
            Dim employee As String = txtEmployee.Text
            Dim supervisor As String = txtSupervisor.Text
            Dim week As Integer = CInt(txtWeek.Text)
            Dim client As String = txtClient.Text
            Dim contract As String = txtContract.Text
            Dim project As String = txtProject.Text
            Dim M As Integer = CInt(txtDayM.Text)
            Dim Tu As Integer = CInt(txtDayTu.Text)
            Dim W As Integer = CInt(txtDayW.Text)
            Dim Th As Integer = CInt(txtDayTh.Text)
            Dim F As Integer = CInt(txtDayF.Text)
            Dim Sa As Integer = CInt(txtDaySa.Text)
            Dim Su As Integer = CInt(txtDaySu.Text)
            Dim total_hrs As Integer = M + Tu + W + Th + F + Sa + Su
            Dim cM, cTu, cW, cTh, cF, cSa, cSu As Integer
            Dim whv_time As Integer = CInt(txtWHV.Text)
            Dim full_time As Integer = "40"
            Dim reg_pay As Double = CDbl(txtBasePay.Text)
            Dim ot_pay As Double = CDbl(txtOtPay.Text)
            Dim total_pay As Double = CDbl(txtTotalPay.Text)
            If total_hrs > full_time Then
                txtRegHrs.Text = "40"
                txtOtHrs.Text = total_hrs - full_time
            Else
                If total_hrs < full_time Then
                    txtRegHrs.Text = total_hrs
                    txtOtHrs.Text = "0"
                Else
                    txtRegHrs.Text = "0"
                    txtOtHrs.Text = "0"
                End If
                reg_pay = total_hrs * 15
                ot_pay = txtOtHrs.Text * (1.5 * 15)
                total_pay = reg_pay + ot_pay
                If chkM.Checked = True Then
                    cM = "1"
                Else
                    cM = "0"
                End If
                If chkTu.Checked = True Then
                    cTu = "1"
                Else
                    cTu = "0"
                End If
                If chkW.Checked = True Then
                    cW = "1"
                Else
                    cW = "0"
                End If
                If chkTh.Checked = True Then
                    cTh = "1"
                Else
                    cTh = "0"
                End If
                If chkF.Checked = True Then
                    cF = "1"
                Else
                    cF = "0"
                End If
                If chkSa.Checked = True Then
                    cSa = "1"
                Else
                    cSa = "0"
                End If
                If chkSu.Checked = True Then
                    cSu = "1"
                Else
                    cSu = "0"
                End If
                whv_time = cM + cTu + cW + cTh + cF + cSa + cSu
            End If
        End If
    End Sub

:confused: Can anyone look this over and provide assistance? Bear in mind, I am a VERY novice VB user.
Attached Images
 

Viewing all articles
Browse latest Browse all 27329

Trending Articles