Code issue

cnorris135

New member
Joined
Oct 19, 2021
Messages
1
Programming Experience
1-3
Hi.... i am working on a class project and i cant seem to figure out what i am having problems with my code. can someone look it over for me and please let me know what im doing wrong??? My error issues are marked by (***** Issue here) in the code.
C#:
using System;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class frmegistration : Form
    {
        public frmegistration()
        {
            InitializeComponent();
        }

        private void Buttoncalculate_Click(object sender, EventArgs e)
        {
            //declare local vriables
            double nbrofdays = 0;
            double registrationfee = 0;
            double lodgingfees = 0;
            double costforlodging = 0;
            double totalcost = 0;

            // validate input
            if (lblworkshops.selectedIndex == -1)                                                                ******* Issue Here
             {
                //display error message in message box
                MessageBox.Show("MUST select a workshop");
                return; //stop executing
            }
            if (lbllocations.SelectedIndex ==0)                                                                    ******* Issue Here
             {
                //display error message in message box
                MessageBox.Show("MUST select a location");
                return; //stop executing
            }
            if (lblworkshops.selectedIndex == 0)
            {
                nbrofdays = 3;
                registrationfee = 1000;
            }
            else if (lblworkshops.selectedIndex == 1)
            {
                nbrofdays = 3;
                registrationfee = 800;
            }
            else if (lblworkshops.selectedIndex == 2)
            {
                nbrofdays = 3;
                registrationfee = 1500;
            }
            else if (lblworkshops.selectedIndex == 3)
            {
                nbrofdays = 5;
                registrationfee = 1300;
            }
            else if (lblworkshops.selectedIndex == 4)
            {
                nbrofdays = 1;
                registrationfee = 500;
            }
            //check location
            if (lbllocations.SelectedIndex == 0)
            {
                costforlodging = 150;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            else if (lbllocations.SelectedIndex == 1)
            {
                costforlodging = 225;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            else if (lbllocations.SelectedIndex == 2)
            {
                costforlodging = 175;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            else if (lbllocations.SelectedIndex == 3)
            {
                costforlodging = 300;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            else if (lbllocations.SelectedIndex == 4)
            {
                costforlodging = 175;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            else if (lbllocations.SelectedIndex == 5)
            {
                costforlodging = 150;
                lodgingfee = costforlodging * nbrofdays;
                totalcost = costforlodging + registrationfee;
            }
            //Display output values
            textboxdays.text = nbrofdays.ToString();
            textboxregistration.Text = registrationfee.ToString("c");
            textboxlodgefee.Text = costforlodging.ToString("c");
            textboxlodgecost.Text = lodgingfees.ToString("c");
            textboxtotalcost.Text = totalcost.ToString("c");
          
          
        }

        private void Buttonclear_Click(object sender, EventArgs e)
        {
            textboxdays.clear();                                                                                         ******* Issue Here
            textboxregistration.clear();                                                                              ******* Issue Here
            textboxlodgefee.clear();                                                                                  ******* Issue Here
            textboxlodgecost.clear();                                                                                 ******* Issue Here
            textboxtotalcost.clear();                                                                                  ******* Issue Here
            lblworkshops.clear();                                                                                       ******* Issue Here
            lbllocations.clear();                                                                                          ******* Issue Here

        }

        private void Buttonexit_Click(object sender, EventArgs e)
        {
            this.Close();
 
Last edited by a moderator:

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
1,437
Location
Norway
Programming Experience
10+
*Clear* C# is case-sensitive.
 
Top Bottom