Vous êtes sur la page 1sur 8

INSTITUTO TECNOLOGICO SUPERIOR DE PÁNUCO

CARRERA
Ingeniería Informática

MATERIA
Administración y Organización de Datos

UNIDAD II
Organizaciones Básicas

ALUMNO
Erick Manuel Lara Diaz

DOCENTE
MCA. Eric Álvarez Baltierra

Pánuco, Ver a 09 de marzo del 2020


Practicar: Conocer el ambiente de programación.

OBJETIVO: Conocer el lenguaje de programación C# en Visual Studio. Esto con la


finalidad de proveer otra herramienta de programación a la par de Java.
Investigar los principales eventos de los cuatros de texto, botones y etiquetas

DESARROLLO:
Desarrollar el código
1 Realizar un programa que realice funciones de calculadora de operaciones
basicas + - * /.

Form1.cs
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 ConocerEntorno_Practica_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

//Aqui es el código para hacer la suma.


private void BtnSuma_Click(object sender, EventArgs e)
{
float numero1, numero2, resultado;

numero1 = float.Parse(txtnumero1.Text);
numero2 = float.Parse(txtnumero2.Text);

resultado = numero1 + numero2;

lbresultado.Text = "La suma es igual a " + resultado;


}

//Aqui es el código para hacer la resta.


private void BtnResta_Click(object sender, EventArgs e)
{
float numero1, numero2, resultado;
numero1 = float.Parse(txtnumero1.Text);
numero2 = float.Parse(txtnumero2.Text);

resultado = numero1 - numero2;

lbresultado.Text = "La resta es igual a " + resultado;


}

//Aqui es el código para hacer la multiplicación.


private void BtnMultiplicacion_Click(object sender, EventArgs e)
{
float numero1, numero2, resultado;

numero1 = float.Parse(txtnumero1.Text);
numero2 = float.Parse(txtnumero2.Text);

resultado = numero1 * numero2;

lbresultado.Text = "La multiplicación es igual a " + resultado;


}

//Aqui es el código para hacer la división.


private void BtnDivision_Click(object sender, EventArgs e)
{
float numero1, numero2, resultado;

numero1 = float.Parse(txtnumero1.Text);
numero2 = float.Parse(txtnumero2.Text);

resultado = numero1 / numero2;

lbresultado.Text = "La división es igual a " + resultado;


}

//Aqui es el código para borrar los datos.


private void BtnBorrar_Click(object sender, EventArgs e)
{
txtnumero1.Text = "";

txtnumero2.Text = "";

lbresultado.Text = "Resultado";
}

//Aqui es el código para cerrar la aplicación.


private void BtnSalir_Click(object sender, EventArgs e)
{
Application.Exit();
}

}
}
Form1.Designer.cs
namespace ConocerEntorno_Practica_1
{
partial class Form1
{
/// <summary>
/// Variable del diseñador requerida.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Limpiar los recursos que se estén utilizando.
/// </summary>
/// <param name="disposing">true si los recursos administrados se deben
eliminar; false en caso contrario, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Código generado por el Diseñador de Windows Forms

/// <summary>
/// Método necesario para admitir el Diseñador. No se puede modificar
/// el contenido del método con el editor de código.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.txtnumero2 = new System.Windows.Forms.TextBox();
this.txtnumero1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.Titulo_Practica = new System.Windows.Forms.Label();
this.BtnSuma = new System.Windows.Forms.Button();
this.BtnResta = new System.Windows.Forms.Button();
this.BtnMultiplicacion = new System.Windows.Forms.Button();
this.BtnDivision = new System.Windows.Forms.Button();
this.lbresultado = new System.Windows.Forms.Label();
this.BtnBorrar = new System.Windows.Forms.Button();
this.BtnSalir = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.Color.Navy;
this.panel1.Controls.Add(this.BtnSalir);
this.panel1.Controls.Add(this.BtnBorrar);
this.panel1.Controls.Add(this.lbresultado);
this.panel1.Controls.Add(this.BtnDivision);
this.panel1.Controls.Add(this.BtnMultiplicacion);
this.panel1.Controls.Add(this.BtnResta);
this.panel1.Controls.Add(this.BtnSuma);
this.panel1.Controls.Add(this.txtnumero2);
this.panel1.Controls.Add(this.txtnumero1);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.Titulo_Practica);
this.panel1.Location = new System.Drawing.Point(-1, 1);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(262, 332);
this.panel1.TabIndex = 0;
//
// txtnumero2
//
this.txtnumero2.Location = new System.Drawing.Point(88, 93);
this.txtnumero2.Multiline = true;
this.txtnumero2.Name = "txtnumero2";
this.txtnumero2.Size = new System.Drawing.Size(158, 23);
this.txtnumero2.TabIndex = 4;
//
// txtnumero1
//
this.txtnumero1.Location = new System.Drawing.Point(88, 59);
this.txtnumero1.Multiline = true;
this.txtnumero1.Name = "txtnumero1";
this.txtnumero1.Size = new System.Drawing.Size(158, 23);
this.txtnumero1.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif",
9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.label2.ForeColor = System.Drawing.SystemColors.HighlightText;
this.label2.Location = new System.Drawing.Point(13, 94);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(69, 16);
this.label2.TabIndex = 2;
this.label2.Text = "Número 2:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif",
9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.HighlightText;
this.label1.Location = new System.Drawing.Point(13, 60);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(69, 16);
this.label1.TabIndex = 1;
this.label1.Text = "Número 1:";
//
// Titulo_Practica
//
this.Titulo_Practica.AutoSize = true;
this.Titulo_Practica.Font = new System.Drawing.Font("Microsoft Sans
Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((byte)(0)));
this.Titulo_Practica.ForeColor =
System.Drawing.SystemColors.HighlightText;
this.Titulo_Practica.Location = new System.Drawing.Point(43, 17);
this.Titulo_Practica.Name = "Titulo_Practica";
this.Titulo_Practica.Size = new System.Drawing.Size(174, 18);
this.Titulo_Practica.TabIndex = 0;
this.Titulo_Practica.Text = "CALCULADORA BÁSICA";
this.Titulo_Practica.TextAlign =
System.Drawing.ContentAlignment.MiddleCenter;
//
// BtnSuma
//
this.BtnSuma.Location = new System.Drawing.Point(33, 139);
this.BtnSuma.Name = "BtnSuma";
this.BtnSuma.Size = new System.Drawing.Size(97, 34);
this.BtnSuma.TabIndex = 5;
this.BtnSuma.Text = "Suma";
this.BtnSuma.UseVisualStyleBackColor = true;
this.BtnSuma.Click += new System.EventHandler(this.BtnSuma_Click);
//
// BtnResta
//
this.BtnResta.Location = new System.Drawing.Point(141, 139);
this.BtnResta.Name = "BtnResta";
this.BtnResta.Size = new System.Drawing.Size(105, 34);
this.BtnResta.TabIndex = 6;
this.BtnResta.Text = "Resta";
this.BtnResta.UseVisualStyleBackColor = true;
this.BtnResta.Click += new System.EventHandler(this.BtnResta_Click);
//
// BtnMultiplicacion
//
this.BtnMultiplicacion.Location = new System.Drawing.Point(33, 193);
this.BtnMultiplicacion.Name = "BtnMultiplicacion";
this.BtnMultiplicacion.Size = new System.Drawing.Size(97, 34);
this.BtnMultiplicacion.TabIndex = 7;
this.BtnMultiplicacion.Text = "Multiplicación";
this.BtnMultiplicacion.UseVisualStyleBackColor = true;
this.BtnMultiplicacion.Click += new
System.EventHandler(this.BtnMultiplicacion_Click);
//
// BtnDivision
//
this.BtnDivision.Location = new System.Drawing.Point(141, 193);
this.BtnDivision.Name = "BtnDivision";
this.BtnDivision.Size = new System.Drawing.Size(105, 34);
this.BtnDivision.TabIndex = 8;
this.BtnDivision.Text = "División";
this.BtnDivision.UseVisualStyleBackColor = true;
this.BtnDivision.Click += new
System.EventHandler(this.BtnDivision_Click);
//
// lbresultado
//
this.lbresultado.AutoSize = true;
this.lbresultado.Font = new System.Drawing.Font("Microsoft Sans Serif",
9.25F);
this.lbresultado.ForeColor =
System.Drawing.SystemColors.ButtonHighlight;
this.lbresultado.Location = new System.Drawing.Point(30, 288);
this.lbresultado.Name = "lbresultado";
this.lbresultado.Size = new System.Drawing.Size(70, 16);
this.lbresultado.TabIndex = 9;
this.lbresultado.Text = "Resultado";
//
// BtnBorrar
//
this.BtnBorrar.Location = new System.Drawing.Point(33, 244);
this.BtnBorrar.Name = "BtnBorrar";
this.BtnBorrar.Size = new System.Drawing.Size(97, 30);
this.BtnBorrar.TabIndex = 10;
this.BtnBorrar.Text = "Borrar Valores";
this.BtnBorrar.UseVisualStyleBackColor = true;
this.BtnBorrar.Click += new System.EventHandler(this.BtnBorrar_Click);
//
// BtnSalir
//
this.BtnSalir.Location = new System.Drawing.Point(141, 244);
this.BtnSalir.Name = "BtnSalir";
this.BtnSalir.Size = new System.Drawing.Size(105, 30);
this.BtnSalir.TabIndex = 11;
this.BtnSalir.Text = "Salir";
this.BtnSalir.UseVisualStyleBackColor = true;
this.BtnSalir.Click += new System.EventHandler(this.BtnSalir_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(260, 329);
this.Controls.Add(this.panel1);
this.Name = "Form1";
this.Text = "Form1";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);

#endregion

private System.Windows.Forms.Panel panel1;


private System.Windows.Forms.TextBox txtnumero2;
private System.Windows.Forms.TextBox txtnumero1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label Titulo_Practica;
private System.Windows.Forms.Label lbresultado;
private System.Windows.Forms.Button BtnDivision;
private System.Windows.Forms.Button BtnMultiplicacion;
private System.Windows.Forms.Button BtnResta;
private System.Windows.Forms.Button BtnSuma;
private System.Windows.Forms.Button BtnBorrar;
private System.Windows.Forms.Button BtnSalir;
}
}

Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace ConocerEntorno_Practica_1
{
static class Program
{
/// <summary>
/// Punto de entrada principal para la aplicación.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

Vous aimerez peut-être aussi