Guest User

Pastebin

a guest
Feb 28th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Runtime.InteropServices;
  4.  
  5. namespace Request_Excel
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
  10.         static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
  11.         static readonly IntPtr HWND_TOP = new IntPtr(0);
  12.         static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
  13.         const UInt32 SWP_NOSIZE = 0x0001;
  14.         const UInt32 SWP_NOMOVE = 0x0002;
  15.         const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
  16.  
  17.         [DllImport("user32.dll")]
  18.         [return: MarshalAs(UnmanagedType.Bool)]
  19.         public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
  20.  
  21.  
  22.         public Form1()
  23.         {
  24.             InitializeComponent();
  25.         }
  26.  
  27.         private void Form1_Load(object sender, EventArgs e)
  28.         {
  29.             SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
  30.         }
  31.  
  32.         private void button1_Click(object sender, EventArgs e)
  33.         {
  34.             bool result = Int32.TryParse(tb_number1.Text, out int a_);
  35.             if (result && a_ <= 25 && a_ >= 0)
  36.             {
  37.                 bool result2 = Int32.TryParse(tb_number2.Text, out int b_);
  38.                 if (result2 && b_ <= 25 && b_ >= 0)
  39.                 {
  40.                     int c = (a_ + b_) % 25;
  41.                     if (c == 0)
  42.                         tb_answer.Text = "25";
  43.                     else
  44.                         tb_answer.Text = Convert.ToString(c);
  45.                 }
  46.                 else
  47.                     MessageBox.Show("Please enter a valid number between 0-25");
  48.             }
  49.             else
  50.                 MessageBox.Show("Please enter a valid number between 0-25");
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment