128 lines
4.3 KiB
VB.net
128 lines
4.3 KiB
VB.net
'Noviembre 2005
|
|
'Noè Sànchez
|
|
'CONDORBS
|
|
|
|
Public Class ValidaTexto
|
|
'Verfifica si la caja de texto (recibida como parametro) esta vacia
|
|
|
|
Public Function ValidaCadenas(ByVal CajaTexto As TextBox) As Boolean
|
|
Try
|
|
Dim nombreCaja As String = CajaTexto.Tag
|
|
If CajaTexto.Text.Length = 0 Then
|
|
MessageBox.Show("El campo " + nombreCaja + "se encuentra vacio.", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
CajaTexto.Focus()
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en la clase ValidaText: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Function
|
|
|
|
Public Function ValidaCombos(ByVal Combo As ComboBox) As Boolean
|
|
Try
|
|
Dim NombreCombo As String = Combo.Name
|
|
If Combo.Text.Length = 0 Then
|
|
MessageBox.Show(NombreCombo + " Vacio", "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Information)
|
|
Combo.Focus()
|
|
Return False
|
|
Else
|
|
Return True
|
|
End If
|
|
Catch ex As Exception
|
|
MessageBox.Show("Error en la clase ValidaText: " & ex.Message, "MINDS", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
|
End Try
|
|
End Function
|
|
|
|
Function NumeroDec(ByVal e As System.Windows.Forms.KeyPressEventArgs, ByVal Text As TextBox) As Integer
|
|
Dim dig As Integer = Len(Text.Text & e.KeyChar)
|
|
Dim a, esDecimal, NumDecimales As Integer
|
|
Dim esDec As Boolean
|
|
' se verifica si es un digito o un punto para el decimal
|
|
If e.KeyChar.IsDigit(e.KeyChar) Or e.KeyChar = "." Then
|
|
e.Handled = False
|
|
ElseIf e.KeyChar.IsControl(e.KeyChar) Then
|
|
e.Handled = False
|
|
Return a
|
|
Else
|
|
e.Handled = True
|
|
End If
|
|
' se verifica que el primer digito ingresado no sea un punto al seleccionar
|
|
If Text.SelectedText <> "" Then
|
|
If e.KeyChar = "." Then
|
|
e.Handled = True
|
|
Return a
|
|
End If
|
|
End If
|
|
|
|
If dig = 1 And e.KeyChar = "." Then
|
|
e.Handled = True
|
|
Return a
|
|
End If
|
|
' aqui se hace la verificacion cuando es seleccionado el valor del texto
|
|
'y no sea considerado como la adicion de un digito mas al valor ya contenido en el textbox
|
|
If Text.SelectedText = "" Then
|
|
' aqui se hace el for para controlar que el numero sea de dos digitos - contadose a partir del punto decimal.
|
|
For a = 0 To dig - 1
|
|
Dim car As String = CStr(Text.Text & e.KeyChar)
|
|
If car.Substring(a, 1) = "." Then
|
|
esDecimal = esDecimal + 1
|
|
esDec = True
|
|
End If
|
|
If esDec = True Then
|
|
NumDecimales = NumDecimales + 1
|
|
End If
|
|
' aqui se controla los digitos a partir del punto numdecimales = 4 si es de dos decimales
|
|
If NumDecimales >= 8 Or esDecimal >= 8 Then
|
|
e.Handled = True
|
|
End If
|
|
Next
|
|
End If
|
|
End Function
|
|
|
|
Public Shared Function Istext(ByVal p_email As String) As Boolean
|
|
Dim l_reg As New System.Text.RegularExpressions.Regex("^[^'<>*?%!\s]$")
|
|
|
|
' Dim l_reg As New System.Text.RegularExpressions.Regex("[@#\\/&?¿*']")
|
|
|
|
|
|
If l_reg.IsMatch(p_email) = False Then
|
|
If p_email = " " Then
|
|
Return True
|
|
Else
|
|
Return (l_reg.IsMatch(p_email))
|
|
End If
|
|
Else
|
|
Return (l_reg.IsMatch(p_email))
|
|
End If
|
|
|
|
End Function
|
|
|
|
Function LimpiarUrl(ByVal texto)
|
|
|
|
'objRegExp.IgnoreCase = True
|
|
'objRegExp.Global = True
|
|
|
|
'objRegExp.Pattern = "\s+"
|
|
'texto = objRegExp.Replace(texto, " ")
|
|
|
|
'objRegExp.Pattern = "[(?*"",\\<>&#~%{}+.@:\/!;']+"
|
|
'texto = objRegExp.Replace(texto, "")
|
|
|
|
Dim i, s1, s2
|
|
s1 = "ÁÀÉÈÍÏÓÒÚÜáàèéíïóòúüñÑç,-"
|
|
s2 = "AAEEIIOOUUaaeeiioouunc,-"
|
|
If Len(texto) <> 0 Then
|
|
For i = 1 To Len(s1)
|
|
texto = Replace(texto, Mid(s1, i, 1), Mid(s2, i, 1))
|
|
Next
|
|
End If
|
|
|
|
LimpiarUrl = LCase(texto)
|
|
|
|
End Function
|
|
|
|
|
|
End Class
|