Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace Request_Excel
- {
- public partial class Form1 : Form
- {
- static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
- static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
- static readonly IntPtr HWND_TOP = new IntPtr(0);
- static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
- const UInt32 SWP_NOSIZE = 0x0001;
- const UInt32 SWP_NOMOVE = 0x0002;
- const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- bool result = Int32.TryParse(tb_number1.Text, out int a_);
- if (result && a_ <= 25 && a_ >= 0)
- {
- bool result2 = Int32.TryParse(tb_number2.Text, out int b_);
- if (result2 && b_ <= 25 && b_ >= 0)
- {
- int c = (a_ + b_) % 25;
- if (c == 0)
- tb_answer.Text = "25";
- else
- tb_answer.Text = Convert.ToString(c);
- }
- else
- MessageBox.Show("Please enter a valid number between 0-25");
- }
- else
- MessageBox.Show("Please enter a valid number between 0-25");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment