0% found this document useful (0 votes)
67 views

Main Form

The document contains code for a C# application that converts temperatures between Celsius and Kelvin scales. It defines a MainForm class with fields to store the Celsius and Kelvin text boxes and conversion button. The button click handler gets the Celsius value, converts it to Kelvin by adding 273, and displays the result. The MainForm class also contains code to initialize the form layout and components. The Program class contains the main method that creates and runs the MainForm.

Uploaded by

smkpdbantul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Main Form

The document contains code for a C# application that converts temperatures between Celsius and Kelvin scales. It defines a MainForm class with fields to store the Celsius and Kelvin text boxes and conversion button. The button click handler gets the Celsius value, converts it to Kelvin by adding 273, and displays the result. The MainForm class also contains code to initialize the form layout and components. The Program class contains the main method that creates and runs the MainForm.

Uploaded by

smkpdbantul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

mainForm.

cs
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace KonversiSuhu {
public partial class MainForm : Form {
public MainForm()
{
InitializeComponent();
}
void Button1Click(object sender, EventArgs e)
{
double cel, kel;
cel = Convert.ToDouble(celcius.Text);
kel = cel+273;
kelvin.Text = kel.ToString();
}
}
}

MainForm.cs
namespace KonversiSuhu {
partial class MainForm
{
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.TextBox celcius;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox kelvin;
private System.Windows.Forms.Label label2;

protected override void Dispose(bool disposing) {


if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.celcius = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.kelvin = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// celcius
//
this.celcius.Location = new System.Drawing.Point(86, 44);
this.celcius.Name = "celcius";
this.celcius.Size = new System.Drawing.Size(100, 22);
this.celcius.TabIndex = 0;
//
// button1
//
this.button1.Location = new System.Drawing.Point(101, 95);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 1;
this.button1.Text = "Konversi";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(192, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 23);
this.label1.TabIndex = 2;
this.label1.Text = "celcius";
//
// kelvin
//
this.kelvin.Location = new System.Drawing.Point(86, 154);
this.kelvin.Name = "kelvin";
this.kelvin.Size = new System.Drawing.Size(100, 22);
this.kelvin.TabIndex = 3;
//
// label2
//
this.label2.Location = new System.Drawing.Point(193, 154);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 23);
this.label2.TabIndex = 4;
this.label2.Text = "Kelvin";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 255);
this.Controls.Add(this.label2);
this.Controls.Add(this.kelvin);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Controls.Add(this.celcius);
this.Name = "MainForm";
this.Text = "KonversiSuhu";
this.ResumeLayout(false);
this.PerformLayout();

}
}
}

Program.cs
using System;
using System.Windows.Forms;

namespace KonversiSuhu
{
internal sealed class Program
{

[STAThread]
private static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}

}
}

You might also like