国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

新手寫的進制轉換器(寫的很笨)

2024-07-21 02:23:01
字體:
來源:轉載
供稿:網友
using system;
using system.drawing;
using system.collections;
using system.componentmodel;
using system.windows.forms;
using system.data;

namespace s_h_c
{
/// <summary>
/// form1 的摘要說明。
/// </summary>
///

public class form1 : system.windows.forms.form
{
private system.windows.forms.groupbox groupbox1;
private system.windows.forms.label label1;
private system.windows.forms.label label2;
private system.windows.forms.textbox textbox1;
private system.windows.forms.textbox textbox2;
private system.windows.forms.groupbox groupbox2;
private system.windows.forms.label label3;
private system.windows.forms.label label4;
private system.windows.forms.label label5;
private system.windows.forms.textbox textbox3;
private system.windows.forms.textbox textbox4;
private system.windows.forms.textbox textbox5;
private system.windows.forms.button button1;
private system.windows.forms.button button2;
private system.windows.forms.label label6;
private system.windows.forms.timer timer1;
private system.componentmodel.icontainer components;

public form1()
{
//
// windows 窗體設計器支持所必需的
//
initializecomponent();

//
// todo: 在 initializecomponent 調用后添加任何構造函數代碼
//
}

/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.dispose();
}
}
base.dispose( disposing );
}

#region windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void initializecomponent()
{
this.components = new system.componentmodel.container();
this.groupbox1 = new system.windows.forms.groupbox();
this.textbox2 = new system.windows.forms.textbox();
this.textbox1 = new system.windows.forms.textbox();
this.label2 = new system.windows.forms.label();
this.label1 = new system.windows.forms.label();
this.button1 = new system.windows.forms.button();
this.groupbox2 = new system.windows.forms.groupbox();
this.button2 = new system.windows.forms.button();
this.textbox5 = new system.windows.forms.textbox();
this.textbox4 = new system.windows.forms.textbox();
this.textbox3 = new system.windows.forms.textbox();
this.label5 = new system.windows.forms.label();
this.label4 = new system.windows.forms.label();
this.label3 = new system.windows.forms.label();
this.label6 = new system.windows.forms.label();
this.timer1 = new system.windows.forms.timer(this.components);
this.groupbox1.suspendlayout();
this.groupbox2.suspendlayout();
this.suspendlayout();
//
// groupbox1
//
this.groupbox1.controls.add(this.textbox2);
this.groupbox1.controls.add(this.textbox1);
this.groupbox1.controls.add(this.label2);
this.groupbox1.controls.add(this.label1);
this.groupbox1.controls.add(this.button1);
this.groupbox1.location = new system.drawing.point(24, 16);
this.groupbox1.name = "groupbox1";
this.groupbox1.size = new system.drawing.size(288, 112);
this.groupbox1.tabindex = 0;
this.groupbox1.tabstop = false;
this.groupbox1.text = "ascii轉換";
//
// textbox2
//
this.textbox2.location = new system.drawing.point(112, 64);
this.textbox2.name = "textbox2";
this.textbox2.size = new system.drawing.size(80, 21);
this.textbox2.tabindex = 3;
this.textbox2.text = "";
//
// textbox1
//
this.textbox1.location = new system.drawing.point(112, 24);
this.textbox1.name = "textbox1";
this.textbox1.size = new system.drawing.size(80, 21);
this.textbox1.tabindex = 2;
this.textbox1.text = "";
this.textbox1.textchanged += new system.eventhandler(this.textbox1_textchanged);
//
// label2
//
this.label2.location = new system.drawing.point(8, 72);
this.label2.name = "label2";
this.label2.size = new system.drawing.size(72, 24);
this.label2.tabindex = 1;
this.label2.text = "ascii碼";
//
// label1
//
this.label1.location = new system.drawing.point(8, 24);
this.label1.name = "label1";
this.label1.size = new system.drawing.size(80, 24);
this.label1.tabindex = 0;
this.label1.text = "字符";
//
// button1
//
this.button1.location = new system.drawing.point(200, 40);
this.button1.name = "button1";
this.button1.tabindex = 2;
this.button1.text = "確定";
this.button1.click += new system.eventhandler(this.button1_click);
//
// groupbox2
//
this.groupbox2.controls.add(this.button2);
this.groupbox2.controls.add(this.textbox5);
this.groupbox2.controls.add(this.textbox4);
this.groupbox2.controls.add(this.textbox3);
this.groupbox2.controls.add(this.label5);
this.groupbox2.controls.add(this.label4);
this.groupbox2.controls.add(this.label3);
this.groupbox2.location = new system.drawing.point(24, 152);
this.groupbox2.name = "groupbox2";
this.groupbox2.size = new system.drawing.size(288, 144);
this.groupbox2.tabindex = 1;
this.groupbox2.tabstop = false;
this.groupbox2.text = "數字進制轉換器";
//
// button2
//
this.button2.location = new system.drawing.point(208, 56);
this.button2.name = "button2";
this.button2.size = new system.drawing.size(64, 24);
this.button2.tabindex = 6;
this.button2.text = "確定";
this.button2.click += new system.eventhandler(this.button2_click);
//
// textbox5
//
this.textbox5.location = new system.drawing.point(120, 104);
this.textbox5.name = "textbox5";
this.textbox5.size = new system.drawing.size(80, 21);
this.textbox5.tabindex = 5;
this.textbox5.text = "";
//
// textbox4
//
this.textbox4.location = new system.drawing.point(120, 64);
this.textbox4.name = "textbox4";
this.textbox4.size = new system.drawing.size(80, 21);
this.textbox4.tabindex = 4;
this.textbox4.text = "";
//
// textbox3
//
this.textbox3.location = new system.drawing.point(120, 24);
this.textbox3.name = "textbox3";
this.textbox3.size = new system.drawing.size(80, 21);
this.textbox3.tabindex = 3;
this.textbox3.text = "";
//
// label5
//
this.label5.location = new system.drawing.point(16, 112);
this.label5.name = "label5";
this.label5.size = new system.drawing.size(88, 24);
this.label5.tabindex = 2;
this.label5.text = "十六進制";
//
// label4
//
this.label4.location = new system.drawing.point(16, 72);
this.label4.name = "label4";
this.label4.size = new system.drawing.size(88, 24);
this.label4.tabindex = 1;
this.label4.text = "二進制";
//
// label3
//
this.label3.location = new system.drawing.point(16, 24);
this.label3.name = "label3";
this.label3.size = new system.drawing.size(88, 24);
this.label3.tabindex = 0;
this.label3.text = "十進制";
//
// label6
//
this.label6.location = new system.drawing.point(88, 304);
this.label6.name = "label6";
this.label6.size = new system.drawing.size(208, 16);
this.label6.tabindex = 2;
//
// timer1
//
this.timer1.tick += new system.eventhandler(this.timer1_tick);
//
// form1
//
this.autoscalebasesize = new system.drawing.size(6, 14);
this.clientsize = new system.drawing.size(342, 323);
this.controls.add(this.label6);
this.controls.add(this.groupbox2);
this.controls.add(this.groupbox1);
this.name = "form1";
this.text = "數據轉換器";
this.load += new system.eventhandler(this.form1_load);
this.groupbox1.resumelayout(false);
this.groupbox2.resumelayout(false);
this.resumelayout(false);

}
#endregion

/// <summary>
/// 應用程序的主入口點。
/// </summary>
///
string str;
[stathread]
static void main()
{

application.run(new form1());

}

private void form1_load(object sender, system.eventargs e)
{
timer1.start();

}



//調用系統時間
void datetimetostring()
{
datetime now=datetime.now;
string format;
label6.text="";
format="yyyy-mm-dd hh:mm:ss";
label6.text=now.tostring(format);
}
private void button1_click(object sender, system.eventargs e)
{
//轉ascii碼
str=textbox1.text;
int a;
if(str.length>1)
messagebox.show("error,please input the char!");
a=(int)str[0];
textbox2.text=a.tostring();
}

private void textbox1_textchanged(object sender, system.eventargs e)
{

}

private void button2_click(object sender, system.eventargs e)
{

if(textbox3.text!="")
{
t_s();
t_tw();
}
else if(textbox4.text!="")
{
tw_t();
tw_s();
}

}
//由十進制轉十六進制
void t_s()
{
string ten;
int b=0;
ten=textbox3.text;

for(int i=0;i<ten.length;i++)
{

int c=1;
for(int j=ten.length-i-1;j>0;j--)
{
c=c*10;

}
if(ten[i]>57 || ten[i]<48)
messagebox.show("錯,輸入的應該是十進制整數。");
else
b=b+((int)ten[i]-48)*c;
c=1;
}
textbox5.text=b.tostring("x8");
}
//由十進制轉二進制
void t_tw()
{

int b=0;
string ten;
int c=1;

ten=textbox3.text;

for(int i=0;i<ten.length;i++)
{


for(int j=ten.length-i-1;j>0;j--)
{
c=c*10;

}

b=b+((int)ten[i]-48)*c;
c=1;
}
textbox4.text=convert.tostring(b,2);

}
//二進制轉十進制
void tw_t()
{

string two;
two=textbox4.text;
int p=convert.toint32(two,2);
textbox3.text=p.tostring();
}
//二進制轉十六進制
void tw_s()
{

string two;
two=textbox4.text;

int s=convert.toint32(two,2);
textbox5.text=s.tostring("x8");
}

private void timer1_tick(object sender, system.eventargs e)
{

datetimetostring();


}



}





}





發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 濉溪县| 金沙县| 察隅县| 加查县| 白朗县| 三穗县| 彭泽县| 通州市| 和平区| 资中县| 平湖市| 镇安县| 铜山县| 海口市| 修水县| 武宁县| 西华县| 会泽县| 天峨县| 沙雅县| 松阳县| 怀来县| 邢台县| 泾阳县| 千阳县| 公主岭市| 天门市| 肥东县| 阿克苏市| 乌恰县| 定远县| 仲巴县| 平和县| 永安市| 双城市| 高平市| 朝阳区| 甘德县| 三穗县| 陈巴尔虎旗| 高邮市|