Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to writ code for percentage in windows application form

how to writ code for percentage in windows application form

Scheduled Pinned Locked Moved C#
tutorialcareer
13 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Simon_Whale

    Seriously?

    Value = (Salary / 100) * percentage;

    I'll let you determine the types required

    Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

    A Offline
    A Offline
    ashwini dharamsale
    wrote on last edited by
    #3

    private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

    S A L F OriginalGriffO 5 Replies Last reply
    0
    • A ashwini dharamsale

      private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #4

      Value = (Salary / 100) * percentage; Value would the the variable that you want to store the result in Salary would be the variable / object that stores the salary value percentage would be the variable / object that stores the percentage that you want to do the multiplication by. The answer I gave you was a formula to find out the what a percentage of X would be.

      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

      1 Reply Last reply
      0
      • A ashwini dharamsale

        private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

        A Offline
        A Offline
        ashwini dharamsale
        wrote on last edited by
        #5

        iam still getting error plz send me complete code

        L K 2 Replies Last reply
        0
        • A ashwini dharamsale

          private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          ashwini dharamsale wrote:

          int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage;

          For real? Pro tip: replace placeholders when copy&pasting code. Epic pro tip: please learn enough C# to at least understand the compilation errors you're getting. It's obvious that you put exactly zero effort in this.

          1 Reply Last reply
          0
          • A ashwini dharamsale

            iam still getting error plz send me complete code

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            ashwini dharamsale wrote:

            iam still getting error

            Out of the 46,298 errors that you could be getting you seriously expect us to guess with is the one error that you are getting? Do you realize that it's Friday and most of us have used up all of our mind reading credits for the week.

            ashwini dharamsale wrote:

            send me complete code

            What? No mention of how much you are going to pay us to do your work for you? Or, how you intend to pay?

            F 1 Reply Last reply
            0
            • A ashwini dharamsale

              iam still getting error plz send me complete code

              K Offline
              K Offline
              Keith Barrow
              wrote on last edited by
              #8

              Why? None of us is getting paid or a qualification for it. I don't think it is up to us to let you breeze through life hiding your own inability to code through the work of others. What you want is a fairly easy thing to do, I certainly could have done this aged 11 (probably younger). You have two real options: 1. Learn at least the basics of programming and debugging. We will help if we aren't be expected to write your code for you or taken advantage of. 2. Leave development as a career. This is a sane option for many people, most of the population just doesn't have the correct type of thought processes for coding. If you are a beginner at coding, then you need to state what your problem is - you say you have an error but do not state what it is. At the very least I can see from skimming your code you aren't updating anything on the form. Again, asking for you code to be written for you won't get a helpful response.

              PB 369,783 wrote:

              I just find him very unlikeable, and I think the way he looks like a prettier version of his Mum is very disturbing.[^]

              1 Reply Last reply
              0
              • L Lost User

                ashwini dharamsale wrote:

                iam still getting error

                Out of the 46,298 errors that you could be getting you seriously expect us to guess with is the one error that you are getting? Do you realize that it's Friday and most of us have used up all of our mind reading credits for the week.

                ashwini dharamsale wrote:

                send me complete code

                What? No mention of how much you are going to pay us to do your work for you? Or, how you intend to pay?

                F Offline
                F Offline
                Forbiddenx
                wrote on last edited by
                #9

                Out of memory...... Good luck! Best error ever!

                =)

                1 Reply Last reply
                0
                • A ashwini dharamsale

                  private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

                  F Offline
                  F Offline
                  Forbiddenx
                  wrote on last edited by
                  #10

                  private void btnCalc_Click(object sender, EventArgs e)
                  {
                  int Value;
                  int percentage = 10;
                  int sal = 99999;
                  Value = (sal / 100) * percentage;
                  btnCalc.Text = Value.ToString();
                  }

                  I fixed it! had to assume a lot here.

                  =)

                  1 Reply Last reply
                  0
                  • A ashwini dharamsale

                    private void btnDelete_Click(object sender, EventArgs e) { int id = Convert.ToInt32(txtId.Text); string name = txtName.Text; decimal sal = Convert.ToDecimal(txtSal.Text); cmd.CommandText = "Delete from Emp where EmpId = " + id; cmd.Connection = con; con.Open(); cmd.ExecuteNonQuery(); con.Close(); } private void btnCalc_Click(object sender, EventArgs e) { int Result; int Total; int sal = int.Parse(txtper.Text); Value = (Salary / 100) * percentage; } like this i wrote still it is getting error

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #11

                    There are a lot of problems here, some of which will prevent it compiling. Assuming that you have declared Value as a class level field or property: 1) Salary does not exist - I suspect you also want this as a class level field or property. 2) percentage does not exists, I assume that the variable you declared on the line above should be called percentage, not sal That should cure your compiler errors, but I suspect it won't give you the right result unless you have been careful about the variable types, which it doesn't appear you have so far!

                    This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    S 1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      There are a lot of problems here, some of which will prevent it compiling. Assuming that you have declared Value as a class level field or property: 1) Salary does not exist - I suspect you also want this as a class level field or property. 2) percentage does not exists, I assume that the variable you declared on the line above should be called percentage, not sal That should cure your compiler errors, but I suspect it won't give you the right result unless you have been careful about the variable types, which it doesn't appear you have so far!

                      This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

                      S Offline
                      S Offline
                      Simon_Whale
                      wrote on last edited by
                      #12

                      His errors are due to a copy and paste problem http://www.codeproject.com/Messages/4648703/Re-how-to-writ-code-for-percentage-in-windows-appl.aspx[^]

                      Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

                      OriginalGriffO 1 Reply Last reply
                      0
                      • S Simon_Whale

                        His errors are due to a copy and paste problem http://www.codeproject.com/Messages/4648703/Re-how-to-writ-code-for-percentage-in-windows-appl.aspx[^]

                        Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

                        OriginalGriffO Offline
                        OriginalGriffO Offline
                        OriginalGriff
                        wrote on last edited by
                        #13

                        I am assuming the problem is "I want to copy your work and paste it in as my homework"?

                        This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups