cdiego

VALIDAR_CAMPOS_ENTEROS_Y_DECIMAL_C#

Feb 10th, 2014
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6.  
  7. namespace Validar
  8. {
  9.     public class Funciones
  10.     {
  11.         public static bool ValidarCampoEntero(TextBox CajaDeTexto)
  12.         {
  13.             try
  14.             {
  15.                 int d = Convert.ToInt32(CajaDeTexto.Text);
  16.                 return true;
  17.             }
  18.             catch (Exception ex)
  19.             {
  20.                 CajaDeTexto.Text ="0";
  21.                 CajaDeTexto.Select (0, CajaDeTexto.Text.Length );
  22.                 return false;
  23.             }
  24.         }
  25.         public static bool ValidarCampoDecimal(TextBox CajaDeTexto)
  26.         {
  27.             try
  28.             {
  29.                 decimal d = Convert.ToDecimal (CajaDeTexto.Text);
  30.                 return true;
  31.             }
  32.             catch (Exception ex)
  33.             {
  34.                 CajaDeTexto.Text = "0";
  35.                 CajaDeTexto.Select(0, CajaDeTexto.Text.Length);
  36.                 return false;
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment