Ok, the code button is not working for me today, so I'kk be brief.

This is homework, but it's been turned in and graded (A). My question is how do I make it so pressing enter clicks my button? for example:

    private void computeButton_Click(object sender, EventArgs e)
    {
        double hoursWorked = 0.0, payRate = 0.0;
        double grossPay = 0.0, stateTax = 0.0, fedTax = 0.0, ficaTax = 0.0, netPay = 0.0;

        //Inputs
        hoursWorked = Convert.ToDouble(hrsBox.Text);
        payRate = Convert.ToDouble(rateBox.Text); 

        grossPay = CalcGrossPay(hoursWorked, payRate);
        CalcStateTax(grossPay, out stateTax);
        CalcFederalTax(grossPay, ref fedTax);
        CalcFICATax(grossPay, ref ficaTax);
        CalcNetPay(grossPay, stateTax, fedTax, ficaTax, ref netPay);

        grossBox.Text = String.Concat(grossPay.ToString("#.00"));
        sTaxBox.Text = String.Concat(stateTax.ToString("#.00"));
        fedTaxBox.Text = String.Concat(fedTax.ToString("#.00"));
        ficaBox.Text = String.Concat(ficaTax.ToString("#.00"));
        netBox.Text = String.Concat(netPay.ToString("#.00"));
    }

    //Gross pay method
    public static double CalcGrossPay(double hoursWorked, double payRate)
    {
           double grossPay = hoursWorked * payRate;
           return grossPay;
    }

    //State tax method
    public static void CalcStateTax(double grossPay, out double stateTax)
    {
          stateTax = grossPay * .04;
    }

    //Federal tax method
    public static void CalcFederalTax(double grossPay, ref double fedTax)
    {
           fedTax = grossPay * .23;
    }

    //FICA tax method
    public static void CalcFICATax(double grossPay, ref double ficaTax)
    {
           ficaTax = grossPay * .14;
    }

   //Net pay method
   public static void CalcNetPay(double grossPay, double stateTax, double fedTax, double ficaTax, ref      double netPay)
   {
          double taxes = (stateTax + fedTax + ficaTax);
          netPay = grossPay - taxes;
   }
}

Just curiousity.

Recommended Answers

All 2 Replies

Set the forms AcceptButton to your computeButton

Thank you

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.