You are on page 1of 5

Function Mayuscula(v)

If (v >= 65 And v <= 90) Then


Mayuscula = True
Else
Mayuscula = False
End If
End Function

Function Minuscula(v)
If (v >= 97 And v <= 122) Then
Minuscula = True
Else
Minuscula = False
End If
End Function

Function Especial(v)
If v = 13 Or v = 32 Or v = 8 Or v = 225 Or v = 233 Or v = 237 Or v = 243
Or v = 250 Or v = 241 Or v = 209 Then
Especial = True
Else
Especial = False
End If
End Function

Function ingresados()
If Trim(Text1) <> "" And IsDate(Text2) And Trim(Text3) <> "" And Trim(Text4)
<> "" Then
Command1.Enabled = True
Command2.Enabled = True
Else
Command1.Enabled = False
Command2.Enabled = False
End If
End Function

Private Sub Form_Activate()


Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Command
End Sub

Private Sub Text1_()

End Sub

Private Sub Text1_KeyPress(keyAscii As Integer)


Static anteriorespacio As Boolean
If keyAscii = 13 Then
Text2.SetFocus
End If
If keyAscii = 32 Then
anteriorespacio = True
Else
If Mayuscula(keyAscii) Or Minuscula(keyAscii) Or Especial(keyAscii) Then
If Trim(Text1) = "" Or anteriorespacio Then
Rem Convierte a Mayuscula.
keyAscii = Asc(UCase(Chr(keyAscii)))
End If
anteriorespacio = False
Else
MsgBox "Debe ingresar solo letras", 16, "Cuidado"
keyAscii = 0 'Ignora el caracter digitado
Command1.Enabled = False
Command2.Enabled = False
End If
End If
End Sub

Private Sub Text2_KeyPress(keyAscii As Integer)


If keyAscii = 13 Then
Text3.SetFocus
End If
End Sub

Private Sub Text2_LostFocus()


If IsDate(Text2) Then
ingresados
Else
MsgBox "Debe ingresar una fecha correcta", 16, "Cuidado"
Text2.SelStart = 0
Text2.SelLength = Len(Text2)
Text2 = Text2.SelText
Text2.SetFocus
End If
End Sub

Private Sub Text3_KeyPress(keyAscii As Integer)


Dim Letra As String * 1
If keyAscii = 13 Then
Text4.SetFocus
Else
Letra = UCase(Chr(keyAscii))
If Letra = "M" Or Letra = "T" Or Letra = "N" Or keyAscii = 8 Then
Rem Convierte la letra ingresada a Mayusculas
keyAscii = Asc(UCase(Chr(keyAscii)))
Else
MsgBox "Debe ingresar solo las letras M,T o N", 16, "Error"
Rem Ignora el caracter ingresado.
keyAscii = 0
Command1.Enabled = False
Command2.Enabled = False
End If
End If
End Sub

Private Sub Text4_Change()


If Val(Text4) < 0 Or Val(Text4) > 20 Then
MsgBox "El promedio debe estar entre 0 y 20", 16, "Error"
Text4.SelStart = 0
Text4.SelLength = Len(Text4)
Text4 = Text4.SelText
Text4.SetFocus
Command1.Enabled = False
Command2.Enabled = False
Else
ingresados
End If
End Sub

Private Sub Text4_KeyPress(keyAscii As Integer)


If numero(keyAscii) Or keyAscii = 8 Or keyAscii = 13 Then
ingresados
Else
MsgBox "Debe ingresar solo numeros", 64, "Cuidado"
keyAscii = 0
Command1.Enabled = False
Command2.Enabled = False
End If
End Sub

You might also like