0

I am writing a program to calculate payrolls for employees. What I need to know is how to get payroll information from variables from one form to another.

The form I need the variable data from is called Timesheet and the form I need the data for is called PayRoll.

When I use the following code:

  lblName.Text = TimeSheet.EmpName

I get the error that EmpName is not a member of EmployeeInfo.Timesheet (the project file the Timesheet is located) after I generated a class for it.

Any ideas to link these forms?

3
  • 1
    You have to create public properties in your class. Commented Oct 8, 2012 at 15:00
  • You should post some code where you call the line above. Also, please explain your architecture. Are you showing the forms modally or do you have an MDI structure? Commented Oct 8, 2012 at 15:02
  • This is the code I have in TimeSheet Public EmpName As String Public Supervisor As String Public Period As String Public Client1 As String Public Client2 As String Public Contract1 As String Public Contract2 As String Public Project1 As String Public Project2 As String Public BillLevel As String Public BillLevel2 As String Public TotalHours As Double Public PTO As Double Private Sub frmPayroll_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load EmpName = txtEmpName.Text Supervisor = txtSupervisor.Text Commented Oct 8, 2012 at 15:17

1 Answer 1

1

Shouldn't be anything wrong with that as long as you are calling the TimeSheet form from the PayRoll form and as long as you have instanciated and retained an instance of that form.

I would expect to see something like:

Dim ts as New TimeSheet
ts.ShowDialog()
' Do whatever you need in the timesheet form to set it.
lblName.Text = ts.EmpName

One thing to note is if you call the Dispose() method you will loose your property.

More information on your problem might be more helpful if this does not answer your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.