3 Replies - 1860 Views - Last Post: 08 October 2012 - 09:48 PM Rate Topic: -----

#1 compucrazy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 30-September 12

Get variable data from one form to another in vb.net

Posted 08 October 2012 - 03:27 PM

Hi,

I wrote a program to calculate payroll data once an employee enters their information and hours. I am having a problem reading the data from variables in one form to another. What I was trying to do was reading from a form called TimeSheet in my other form called Payroll_Submission. Here is the code I have so far and I really need to get that data from the other form to do my calculations. Please let me know if you need my TimeSheet code, it is long so I didn't attach it this time.

 Private Sub Payroll_Submission_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim counter As Integer
        counter = 0

        lblEmployee.Text = TimeSheet.EmpName
        lblSuperName.Text = TimeSheet.Supervisor
        lblReport.Text = TimeSheet.Period

        If Not TimeSheet.flag Then
            lblHoursWorked.Text = TimeSheet.txtMon1 + TimeSheet.txtTues1 + TimeSheet.txtWed1 + TimeSheet.txtThurs1 + TimeSheet.txtFri1 + TimeSheet.txtSat1 + TimeSheet.txtSun1
            If lblOvertimeHours.Text > 40 Then
                lblRegHours.Text = 40
                lblRegHours.Text = lblHoursWorked.Text - 40
            Else
                lblRegHours.Text = lblHoursWorked.Text
                lblOvertimeHours.Text = 0
            End If
            lblOvertimeHours.Text = "$15"
            lblRateOver.Text = "$22.50"

            HourlyPay.Text = Convert.ToInt32(lblRegHours.Text) * 15
            lblOvertimeHours.Text = Convert.ToInt32(lblOvertimeHours.Text) * 22.5
            lblGrossPay.Text = Convert.ToInt32(HourlyPay.Text) + Convert.ToInt32(lblOvertimeHours.Text)

            If TimeSheet.chk1.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk2.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk3.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk4.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk5.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk6.Checked Then
                counter = counter + 1
            End If

            If TimeSheet.chk7.Checked Then
                counter = counter + 1
            End If

            lblPTOHours.Text = counter

        End If

        HourlyPay.Text = Convert.ToInt32(lblRegHours.Text) * 15
        lblOvertimeHours.Text = Convert.ToInt32(lblOvertimeHours.Text) * 22.5
        lblGrossPay.Text = Convert.ToInt32(lblRegHours.Text) + Convert.ToInt32(lblOvertimeHours.Text)
    End Sub

End Class




Is This A Good Question/Topic? 0
  • +

Replies To: Get variable data from one form to another in vb.net

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Get variable data from one form to another in vb.net

Posted 08 October 2012 - 04:09 PM

DO you get any error?
Was This Post Helpful? 0
  • +
  • -

#3 compucrazy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 30-September 12

Re: Get variable data from one form to another in vb.net

Posted 08 October 2012 - 04:50 PM

View Postsela007, on 08 October 2012 - 04:09 PM, said:

DO you get any error?


No error, just doesn't display the data from the calculations.
Was This Post Helpful? 0
  • +
  • -

#4 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Get variable data from one form to another in vb.net

Posted 08 October 2012 - 09:48 PM

Try placing a breakpoint in your code on Line 6 (the first assignment line), and single-step through the rest of the Load routine after it stops. Check to make sure your If statements do what you expect. Make sure that every operation makes sense with reference to what you thought it should do. Check every variable in an assignment statement, before and after executing the statement. Visual Studio has a wonderful set of tools to help you troubleshoot your code. Don't be afraid to use them. Even programmers that have been at it for decades still use these tools.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1