Advertisement
DrAungWinHtut

SumQuiz.cs

Aug 12th, 2023
1,300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 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 HelloBoston
  12. {
  13.     public partial class frmHello : Form
  14.     {
  15.         public frmHello()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnHello_Click(object sender, EventArgs e)
  21.         {
  22.             MessageBox.Show("Hello Boston!", "Greeting", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
  23.         }
  24.  
  25.         private void btnHide_Click(object sender, EventArgs e)
  26.         {
  27.             picRiver.Visible = false;
  28.         }
  29.  
  30.         private void btnHide_MouseHover(object sender, EventArgs e)
  31.         {
  32.             this.Text = "This Button is used to hide river";
  33.         }
  34.  
  35.         private void btnShow_Click(object sender, EventArgs e)
  36.         {
  37.             string sPass = txtPass .Text;
  38.             if(sPass =="1234")
  39.             {
  40.                 picRiver.Visible = true;
  41.             }
  42.             else
  43.             {
  44.                 MessageBox.Show("Wrong Password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  45.             }
  46.  
  47.            
  48.         }
  49.  
  50.         private void btnShow_MouseHover(object sender, EventArgs e)
  51.         {
  52.             this.Text = "This Button is used to show river";
  53.         }
  54.  
  55.         private void frmHello_MouseHover(object sender, EventArgs e)
  56.         {
  57.             this.Text = "This is Form!";
  58.         }
  59.  
  60.         private void btnHello_MouseHover(object sender, EventArgs e)
  61.         {
  62.             this.Text = "This Button is used to greet you!";
  63.         }
  64.  
  65.         private void picRiver_MouseHover(object sender, EventArgs e)
  66.         {
  67.             this.Text = "This is river";
  68.         }
  69.  
  70.         private void btnCheck_Click(object sender, EventArgs e)
  71.         {
  72.             string sA;
  73.             sA = txtA .Text;
  74.             string sB;
  75.             sB = txtB .Text;
  76.             string sSum;
  77.             sSum = txtSum .Text;
  78.  
  79.             int iA;
  80.             iA = int.Parse(sA); //string -> int
  81.             int iB;
  82.             iB = int.Parse(sB);
  83.             int  iC = int.Parse(sSum);
  84.  
  85.             int sum;
  86.             sum = iA + iB;
  87.  
  88.             if(sum==iC)
  89.             {
  90.                 MessageBox.Show("Correct!");
  91.  
  92.             }
  93.             else
  94.             {
  95.                 MessageBox.Show("Wrong!");
  96.             }
  97.  
  98.            
  99.         }
  100.     }
  101. }
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement