Valida TextBox si es Entero o Decimal
Bueno estas funciones ayudan a validar si el texto ingresado en un textbox es un valor numérico ó es un valor decimal, estas son de las validaciones más usadas para desarrollar así que acá se los dejo.
Public Shared Function EsInteger(ByVal theValue As String) As Boolean
'funcion para enteros
Try
Convert.ToInt32(theValue)
Return True
Catch
Return False
End Try
End Function
Public Shared Function EsDecimal(ByVal theValue As String) As Boolean
'funcion para enteros
Try
Convert.ToDecimal(theValue)
Return True
Catch
Return False
End Try
End Function
public static bool EsInteger(string theValue)//funcion para enteros
{
try
{
Convert.ToInt32(theValue);
return true;
}
catch
{
return false;
}
}
public static bool EsDecimal(string theValue)//funcion para enteros
{
try
{
Convert.ToDecimal(theValue);
return true;
}
catch
{
return false;
}
}
otra manera de validar de parte de @cmsalvado gracias por el dato:
Public Shared Function EsInteger(ByVal theValue As String) As Boolean Dim value As Integer Return Integer.TryParse(theValue, value) End Function
public static bool EsInteger(string theValue)
{
int value;
return int.TryParse(theValue, out value);
}
bueno espero les sea de gran ayuda.
nos vemos
Me sirvió de mucho, ya que domino java pero no tanto vb .net xD