miércoles, 21 de septiembre de 2016

VALIDAR VALORES INTRODUCIDOS


PRÁCTICA #5

VALIDAR VALORES INTRODUCIDOS


Objetivo: Validar valores introducidos


DISEÑO DEL PROBLEMA


Código del programa

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 Practica_5._1
{
    public partial class frmValidar : Form
    {
        public frmValidar()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btnEjecutar_Click(object sender, EventArgs e)
        {
            if (txtEspacios.Text == "")
            {
                MessageBox.Show("No debe dejar espacios en blanco");
            }
        }

        private void txtLetras_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsLetter(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsSeparator(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }


        private void txtNumeros_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (Char.IsDigit(e.KeyChar))
            {
                e.Handled = false;
            }
            else if (Char.IsControl(e.KeyChar))
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
    }

}

No hay comentarios:

Publicar un comentario