基本信息
源码名称:C#十六进制的计算器
源码大小:0.11M
文件格式:.rar
开发语言:C#
更新时间:2018-10-15
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _16
{
public partial class Form1 : Form
{
string p1,p2,s;
int l1,l2,result;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button2.Text;
p1 = textBox1.Text;
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button3.Text;
p1 = textBox1.Text;
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button4.Text;
p1 = textBox1.Text;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button5.Text;
p1 = textBox1.Text;
}
private void button6_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button6.Text;
p1 = textBox1.Text;
}
private void button7_Click(object sender, EventArgs e)
{
string old = textBox1.Text;
if (old.Length > 1)
{
textBox1.Text = old.Substring(0, old.Length - 1);
}
else
textBox1.Text = "0";
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button1.Text ;
p1 = textBox1.Text;
}
private void button8_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button8.Text;
p1 = textBox1.Text;
}
private void button9_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button9.Text;
p1 = textBox1.Text;
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button10.Text;
p1 = textBox1.Text;
}
private void button11_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button11.Text;
p1 = textBox1.Text;
}
private void button12_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button12.Text;
p1 = textBox1.Text;
}
private void button18_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button18.Text;
p1 = textBox1.Text;
}
private void button17_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button17.Text;
p1 = textBox1.Text;
}
private void button16_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button16.Text;
p1 = textBox1.Text;
}
private void button15_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button15.Text;
p1 = textBox1.Text;
}
private void button13_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
}
private void button14_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text button14.Text;
p1 = textBox1.Text;
}
private void button19_Click(object sender, EventArgs e)
{
l1 = Convert.ToInt32(p1, 16);
l2 = Convert.ToInt32(p2, 16);
switch(s)
{
case "And": result= l2 & l1; break;
case "Not": result= ~l2 ;break;
case "Or": result=l2 | l1 ;break;
case "Xor": result = l2 ^ l1; break;
case "Mod":
if (l1 == 0)
{ MessageBox.Show("mod运算除数不能为零,请重新输入!!"); }
else
{result=l2%l1;}
break;
}
string s1 = Convert.ToString(result,2);//二进制
int s2 = Convert.ToInt32(s1,2);//十进制
string s3 = Convert.ToString(s2, 16); //十六进制
textBox1.Text = s3;
textBox2.Text = Convert.ToString(s2);
textBox3.Text = s1;
}
private void button20_Click(object sender, EventArgs e)
{
textBox1.Text = "";
s = "Mod";
p2 = p1;
}
private void button21_Click(object sender, EventArgs e)
{
textBox1.Text = "";
s = "Xor";
p2 = p1;
}
private void button22_Click(object sender, EventArgs e)
{
textBox1.Text = "";
s = "Or";
p2 = p1;
}
private void button23_Click(object sender, EventArgs e)
{
textBox1.Text = "";
s = "Not";
p2 = p1;
}
private void button24_Click(object sender, EventArgs e)
{
textBox1.Text = "";
s = "And";
p2 = p1;
}
}
}