New handwriting into the converter (very stupid to write)

Source: Internet
Author: User
Tags datetime string format tostring
Convert using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;

Namespace S_h_c
{
<summary>
Summary description of the 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 ()
{
//
Required for Windows Forms Designer support
//
InitializeComponent ();

//
TODO: Add any constructor code after the InitializeComponent call
//
}

<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}

Code generated #region the Windows forms Designer
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</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 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 = "character";
//
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 = "Digital conversion 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 = "";
//
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 = "hexadecimal";
//
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 system";
//
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_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 = "Data converter";
This. Load + = new System.EventHandler (this. Form1_Load);
This.groupBox1.ResumeLayout (FALSE);
This.groupBox2.ResumeLayout (FALSE);
This. ResumeLayout (FALSE);

}
#endregion

<summary>
The main entry point for the application.
</summary>
///
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)
{
Turn ASCII code
Str=textbox1.text;
int A;
if (str. LENGTH&GT;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 ();
}

}
Hexadecimal by decimal
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 ("wrong, the input should be a decimal integer.") ");
Else
b=b+ ((int) ten[i]-48) *c;
C=1;
}
textbox5.text=b.tostring ("x8");
}
Binary binary by decimal
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);

}
Binary Turn Decimal
void tw_t ()
{

String two;
Two=textbox4.text;
int P=convert.toint32 (two,2);
Textbox3.text=p.tostring ();
}
Binary turn hexadecimal
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 ();


}



}





}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.