New handwritten converter (very stupid)

xiaoxiao2021-03-06  64

Using system.drawing; using system.componentmodel; using system.windows.form; using system.data ;. using system.data ;. USING SYSTEM.DATA;

A summary description of Namespace S_H_C {///

/// form1. /// ////

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 component;

Public Form1 () {// // Windows Form Designer Support for // InitializeComponent ();

// // Todo: Add any constructor code after INITIALIZEComponent call //}

///

/// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = Null) {components.dispose ();}} Base.Dispose

#REGION Windows Form Designer The code ///

/// designer supports the required method - do not use the code editor to modify the // / this method.

/// 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 () Idton1 = 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 (); THISPBOX2.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 conversion"; // // 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 code"; // // 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 = "characters"; // // Button1 // this.button1.location = New system.drawing.point (200, 40); this.button1.name = "button1"; this.button1.tabindex = 2; this.button1.text = "OK"; 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 = "Digitally converter"; // // 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 = "OK"; 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 = ""; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////bit (120, 24); this.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 = "Ten Sixth

// // 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 = "binary"; /// 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 = "decimal"; // 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_thing); // // 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"; THISTEXT = "Data Converter"; this.Load = New System.EventHandler (this.form1_load); this.groupBox1.ResumeLayout (false); this.groupBox2.ResumeLayout; this.ResumeLayout (false); } #Endregion

///

/// The primary entry point of the application. /// /// string str; [stathread] static void main () {Application.run (New Form1 ());}

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

// Call system time 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) {// transfer ASCII code 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 ();

} // Based on Ten-Binary Hexadecimal Void T_S () {String Ten; INT B = 0; Ten = TEXTBOX3.TEXT; For (int i = 0; i 0; J -) {c = c * 10;

} IF (Ten [i]> 57 || Ten [i] <48) MessageBox.show ("Wrong, the input should be a decimal integer."); ELSE B = B ((int) Ten [i] -48) * C; c = 1;} textbox5.text = b.toString ("x8");} // Based on decimal turnover void t_tw () {INT b = 0; string Ten; int C = 1;

Ten = textBox3.text; for (int i = 0; i 0; j -) {c = c * 10;

} B = b ((int) Ten [i] -48) * c; c = 1;} textbox4.text = Convert.TOSTRING (B, 2);

} // binary turn 10 credit void TW_T () {string two; turn = textBox4.text; int p = convert.Toint32 (Two, 2); TextBox3.text = p.toString ();} // binary turn hex 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 ();

}

}

}

转载请注明原文地址:https://www.9cbs.com/read-110599.html

New Post(0)