Advertisement
DrAungWinHtut

Area of Circle revision

Apr 1st, 2022
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Revision1
  12. {
  13.     public partial class frmArea : Form
  14.     {
  15.         public frmArea()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnCalculate_Click(object sender, EventArgs e)
  21.         {
  22.             funCalArea();
  23.          
  24.         }
  25.  
  26.         private void txtR_KeyDown(object sender, KeyEventArgs e)
  27.         {
  28.             if(e.KeyCode == Keys.Enter)
  29.             {
  30.                 funCalArea();
  31.                 txtR .SelectAll();
  32.                 txtR.Focus();
  33.             }
  34.  
  35.         }
  36.  
  37.         public void funCalArea()
  38.         {
  39.  
  40.             float fArea = 0.0f;
  41.             float fRadius = 0.0f;
  42.  
  43.             // varname = value;
  44.             // varname
  45.             fRadius = float.Parse(txtR.Text);
  46.  
  47.             // bool bStatus = float.TryParse (txtR .Text, out fRadius);
  48.             // if(bStatus)
  49.  
  50.             if (float.TryParse(txtR.Text, out fRadius))
  51.             {
  52.                 // data valid
  53.                 fArea = 3.14f * fRadius * fRadius;
  54.                 txtA.Text = fArea.ToString();
  55.             }
  56.             else
  57.             {
  58.                 //data invalid
  59.                 //show error and ask to try again
  60.             }
  61.  
  62.  
  63.  
  64.             // 1. User ထည့်ပေးလိုက်တဲ့ တန်ဖိုးကို စစ်မယ်
  65.             // float ဖြစ်လား မဖြစ်လား စစ်ဖို့လိုမယ်
  66.             // float.tryparse()
  67.             // Validation
  68.  
  69.             // Store လုပ်ဖို့ = assignment operator
  70.  
  71.             // Hand Calculation
  72.             // Equation
  73.             // fA = 3.14f * fR * fR;
  74.  
  75.  
  76.             // Outpur Results into UI
  77.             // Store Results
  78.         }
  79.     }
  80. }
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement