Hola amigos.
Saludos.
Tengo un problema de programación con Visual Basic, hice una mimi aplicación que convierte un número determinado de SEGUNDOS en HORAS, MINUTOS Y SEGUNDOS.
<div class='bbimg'></div>
Acá el código...
Private Sub cmdCalcular_Click()
Dim Horas As Integer
Dim Minutos As Integer
Dim Segundos As Integer
Horas = Val(Text1.Text) \ 3600
Minutos = Val(Text1.Text Mod 3600) \ 60
Segundos = Val((Text1.Text Mod 3600) Mod 60)
Text2.Text = Horas
Text3.Text = Minutos
Text4.Text = Segundos
End Sub
Private Sub cmdSalir_Click()
Unload Me
End Sub
Private Sub cmdNuevo_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not Chr(KeyAscii) = vbBack Then
If Not IsNumeric(Chr(KeyAscii)) Then
Beep
KeyAscii = vbEmpty
End If
End If
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Val(Text1.Text) > 86400 Then
MsgBox "No se debe rebasar la cifra de 86400, ya que el sistema sólo tiene que capturar un máximo de 24 horas exactas."
Text1.Text = ""
KeyAscii = vbEmpty ElseIf Val(Text1.Text) < 0 Then
MsgBox "Número no permitido"
Text1.Text = ""
KeyAscii = vbEmpty
End If
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
(NO ENTIENDO LA PRIMERA LINE DE ESTE CODIGO, SI ALGUIEN LA PUDIERA COMENTAR SE LOS HE DE AGRADECER)
If Not Me.ActiveControl.Name = "command3" Then
If Text1.Text = "" Then
MsgBox "Debes capturar un número, el campo no debe quedar vacío"
'Text1.SetFocus
Cancel = True
End If
End If
End Sub
El problema surge cuando al textbox le doy calcular sin haber capturado nada, me mandaba un error, ya lo corregí sólo que ahora al darle SALIR no me deja.
¿Cómo debo poner el código para dejar mi aplicación tal y como está pero que me deje cerrar la aplicación desde el botón salir?
Gracias.



</div>
