0% found this document useful (0 votes)
5 views8 pages

Form Navigation and Input Validation

This document contains code for a form application that handles passenger ticket booking. It includes functions to validate input fields, set form visibility, calculate ticket prices and discounts based on destination and number of passengers, and display ticket details on a third form on purchase. Field values like name, destination, number of passengers, discount amount and total price are passed between forms.

Uploaded by

nilton
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views8 pages

Form Navigation and Input Validation

This document contains code for a form application that handles passenger ticket booking. It includes functions to validate input fields, set form visibility, calculate ticket prices and discounts based on destination and number of passengers, and display ticket details on a third form on purchase. Field values like name, destination, number of passengers, discount amount and total price are passed between forms.

Uploaded by

nilton
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Private Sub Command1_Click()

[Link]
[Link]
End Sub

FORMA2

Private Function MINUSCULA(V As Integer) As Boolean


If V >= 97 And V <= 122 Then
MINUSCULA = True
Else
MINUSCULA = False
End If
End Function
Private Function MAYUSCULA(V As Integer) As Boolean
If V >= 65 And V <= 90 Then
MAYUSCULA = True
Else
MAYUSCULA = False
End If
End Function
Private Function LETRA(V As Integer) As Boolean
If V >= 65 And V <= 90 Or V >= 97 And V <= 122 Then
LETRA = True
Else
LETRA = False
End If
End Function

Private Function NUMERO(V As Integer) As Boolean


If V >= 48 And V <= 57 Then
NUMERO = True
Else
NUMERO = False
End If
End Function
Private Sub APELLIDO_Change()

If APELLIDO = "" Then


[Link] = False
Else
[Link] = True
End If
If APELLIDO = "" Or PASAJE = "" Then
[Link] = False
[Link] = False
[Link] = False
Else
[Link] = True
[Link] = True
End If
End Sub
Private Sub PASAJE_Change()
If APELLIDO = "" Or PASAJE = "" Then
[Link] = False
[Link] = False
[Link] = False
Else
[Link] = True
[Link] = True
End If
End Sub
Private Sub Combo1_Click()

Select Case Combo1


Case "CHIMBOTE"
COSTO = 45
DESTINO = "CHIMBOTE"
Case "TRUJILLO"
COSTO = 66
DESTINO = "TRUJILLO"
Case "CHICLAYO"
COSTO = 71
DESTINO = "CHICLAYO"
Case "CAJAMARCA"
COSTO = 85
DESTINO = "CAJAMARCA"
Case "TUMBES"
COSTO = 118
DESTINO = "TUMBES"
Case "PIURA"
DESTINO = "PIURA"
COSTO = 93
End Select
End Sub
Private Sub Command1_Click()

If Combo1 = "LUGAR" Then


R = MsgBox("SELECCIONE UN LUGAR PARA VIAJAR", 16, "ATENCIÓN")
Else
[Link] = True
AYN = APELLIDO
End If
NUMEROP = Val(PASAJE)
If Val(PASAJE) < 2 Then
DESCUENTO = 0
TOTAL = COSTO
Else
DESCUENTO = COSTO * Val(PASAJE) * 0.12
TOTAL = COSTO * Val(PASAJE) – DESCUENTO
End If
End Sub
Private Sub Command2_Click()
[Link]
End Sub
Private Sub Command3_Click()
APELLIDO = ""
PASAJE = ""
End Sub
Private Sub Command4_Click()

R = MsgBox("DESEA SALIR?", vbYesNo + 32, "MENÚ SALIR")


If R = vbYes Then
End
End If
End Sub
Private Sub APELLIDO_KeyPress(KeyAscii As Integer)
Static ANTERIORESPACIO As Boolean
If KeyAscii = 32 Then
ANTERIORESPACIO = True
Else
If MAYUSCULA(KeyAscii) Or MINUSCULA(KeyAscii) Then
If Trim(APELLIDO) = "" Or ANTERIORESPACIO Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Else
KeyAscii = Asc(LCase(Chr(KeyAscii)))
End If
ANTERIORESPACIO = False
Else
If NUMERO(KeyAscii) Then
R1 = MsgBox("DEBE INGRESAR SOLO LETRAS", 16, "CUIDADO")
KeyAscii = 0
End If
End If
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If LETRA(KeyAscii) Then
R = MsgBox("SOLO SE ADMITEN NÚMEROS", 16, "CUIDADO")
End If
End Sub

Private Sub PASAJE_KeyPress(KeyAscii As Integer)

If LETRA(KeyAscii) Then
R = MsgBox("SOLO SE ADMITEN NÚMEROS", 16, "CUIDADO")
KeyAscii = 0
End If
End Sub

FORMA3

Private Sub Form_Load()

LBL1 = UCase(AYN)
LBL2 = DESTINO
LBL3 = NUMEROP
LBL4 = DESCUENTO
LBL5 = TOTAL
LBL6 = COSTO * NUMEROP
LBLFECHA = "FECHA Y HORA DE SALIDA: " & Now
End Sub

You might also like