Got this project write a C# windows app program that computes employee wages. Input the employee's payroll number and number of hours worked. The employee receives 7.45 per hour as hourly rate and is taxed 20% from gross pay and 7% also national insurance. and to display this information in a seperate group box which i cant do. but me main problem is the error i recieved running the app .

my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

       
       
        string name;
        int employeeNumber;
        double hours;
        const double hourlyWage = 7.5;
        double gross;
        double tax;
        double insurance;
        double deduction;

       

        private void btnCompute_Click(object sender, EventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageB.Text = "...";
            }
            else if (txtPNumber.Text.Length <= 8)
            {
                MessageB.Text = "...";
            }
            else if (txtHoursWork.Text == "")
            {
                MessageB.Text = "...";
            }
            else if (btnCompute.Text == "Compute")
            {
                name = txtName.Text;
                employeeNumber = Convert.ToInt32(txtPNumber);
                hours = Convert.ToDouble(txtHoursWork.Text);
                gross = hours * hourlyWage;
                txtGrossPay.Text = "£" + Convert.ToString(gross);
                tax = gross / 100 * 20;

                txtIncomeTax = "£" + Convert.ToString(tax);

                insurance = gross / 100 * 7;

                txtNI = "£" + Convert.ToString(insurance);
                deduction = tax + insurance;
                txtTotalDeduction = "£" + Convert.ToString(deduction);

               



            }
            else
            {
                txtName.Text = "";
                txtPNumber.Text = "";
                txtHoursWork.Text = "";
                txtGrossPay.Text = "";
                txtIncomeTax.Text = "";
                txtNI.Text = "";
                txtTotalDeduction.Text = "";

                btnCompute.Text = "Compute";

               

            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Close();
        }
     
    }
}

error message

Error 1 Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox'

also attached the app

any of your help would be highly aappriciated
thank you in advance

You do it well in your else clause why dont you do it before: like in txtIncomeTax = "£" + Convert.ToString(tax); Here you assign a string to a textbox. This is not correct.

yes, instead of

txtIncomeTax = "£" + Convert.ToString(tax);

I put:

txtIncomeTax.Text = "£" + Convert.ToString(tax);

and it seemed to work fine...

name = txtName.Text;
employeeNumber = Convert.ToInt32(txtPNumber);

Please pay your attention here
I beleieve txtPNumber is the name of the textBox assigned by you and not a variable if yes thats why its throwing that error

TRY THIS:
name = txtName.Text;
employeeNumber = Convert.ToInt32(txtPNumber.Text);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.