You are on page 1of 26

APLICACIONES INICIALES DE CLASE (22 JUNIO 2017)

Modificacin del ejemplo 01 (pag 4)

Generar el formulario mostrado luego hacer el cdigo para que nos muestre en una etiqueta los
apellidos ingresados.

EL CODIGO ES

Private Sub CmdMuestra_Click()


LblUd.Caption = TxtApell
LblUd.Visible = True
Rem para poner comentarios lo ignora al
ejecutar
End Sub

Private Sub CmdNuevo_Click()


TxtApell = "": TxtCiclo = ""
TxtSexo = "": TxtClave = ""
LblUd = "": Rem las "" para limipiar los botones de control
TxtApell.SetFocus: Rem ubica el cursor en apellidos
LblUd.Visible = False
Rem oculta el control especificado
End Sub
Private Sub CmdSalir_Click()
End
End Sub

2.- se desea saber cunto se debe pagar por la compra de un artculo X. Generar el cdigo para el
siguiente formulario.

Private Sub CmdEjecuta_Click()

TxtArtic.SetFocus
Rem convertir a Nro. las cajas de texto
n1 = Val(TxtArtic)
n2 = Val(TxtPrecio)
costo = n1 * n2
TxtCosto = costo
End Sub

Private Sub CmdNuevo_Click()


TxtArtic = "": TxtPrecio = ""
TxtCosto = ""
TxtArtic.SetFocus
End Sub
Private Sub CmdSalir_Click()
End End Sub
DAR LECTURA DE LA PRACTICA N 03, Y DESARROLLAR LA APLICACION N 04 Y 05 (Pag 8-12)

ESTRUCTURAS DE CONTROL CONDICIONAL (pag 13)


IF THEN ELSE
Existen 3 formas de presentacion

SI NO

3.- Hacer un programa que ingresado 3 Nros; seleccione el MAYOR de ellos, tome el diseo del
sigte formulario.

Private Sub CmdEjecuta_Click()


A = Val(TxtA)
B = Val(TxtB)
C = Val(TxtC)
If A > B And A > C Then
LblMsj.Caption = " El MAYOR es " & A
End If
If B > A And B > C Then
LblMsj.Caption = " El MAYOR es " & B
End If
If C > A And C > B Then
LblMsj.Caption = " El MAYOR es " & C
End If
End Sub

Private Sub CmdNuevo_Click()


TxtA = "": TxtB = "": TxtC = ""
LblMsj.Caption = ""
TxtA.SetFocus
End Sub
Private Sub CmdSalir_Click()
MsgBox (" Que buena...!!"): Rem Ver pag 13
End
End Sub
4.- Generar el cdigo para calcular el pago por horas extras del personal de una mina, bajo las
siguientes condiciones: si el empleado es VARON el pago por HE es de

Private Sub CmdCalcula_Click()


NHE = Val(TxtHe)
Dim pago As Double
Dim R As Integer
If TxtSexo = "M" Or TxtSexo = "m" Then
pago = 85 * NHE
TxtPago = "Sr " & TxtApell & " Su Pago es = " & pago
Else
pago = 95 * NHE
TxtPago = "Sr " & TxtApell & " Su Pago es = " & pago
End If
End Sub

Private Sub CmdSalir_Click()


R = MsgBox("Desea Salir?", 4 + 32, "CUIDADO")
If R = 7 Then
TxtApell = "": TxtHe = "": TxtSexo = "": TxtPago = ""
TxtApell.SetFocus
Else
End
End If
End Sub
CLASE DE CONSISTENCIAS DEL 06 JULIO 2017

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 Minuscula(v As Integer) As Boolean
If (v >= 97 And v <= 122) Then
Minuscula = True
Else
Minuscula = 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 Function Ingreso() As Boolean
If Trim(Text1) <> "" And Trim(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 Command1_Click()


Text1 = "": Text2 = "": Text3 = "": Text4 = ""
Text1.SetFocus
End Sub

Private Sub Command2_Click()


End
End Sub

Private Sub Command3_Click()


P1 = Val(Text2)
P2 = Val(Text3)
P3 = Val(Text4)
PP = (P1 + P2 + P3) / 3
Text6 = PP
Command1.Enabled = True
Command2.Enabled = True
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


Static espacio As Boolean
If KeyAscii = 13 Then
Text2.SetFocus
End If
If KeyAscii = 32 Then
espacio = True
Else
If Mayuscula(KeyAscii) Or Minuscula(KeyAscii) Or Numero(KeyAscii) Then
If Trim(Text1) = "" Or espacio Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Else
KeyAscii = Asc(LCase(Chr(KeyAscii)))
End If
espacio = False
Else
MsgBox "Ingrese solo Letras", 16, "OJO,,OJO"
End If
End If
End Sub

Private Sub Text2_Change()


If Val(Text2) < 0 Or Val(Text2) > 20 Then
MsgBox "El promedio debe estar entre" & Chr(13) & "0 y 20", 16, "ERROR"
Text2.SelStart = 0
Tex2.SelLength = Len(Text2)
Text2.SetFocus
Command1.Enabled = False
Command2.Enabled = False
Else: Ingreso
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Debe de Ingresar solo Nros", 64, "CUIDADO"
KeyAscii = 0
Command1.Enabled = False
Command2.Enabled = False
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Debe de Ingresar solo Nros", 64, "CUIDADO"
KeyAscii = 0
Command1.Enabled = False
Command2.Enabled = False
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)


If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Debe de Ingresar solo Nros", 64, "CUIDADO"
KeyAscii = 0
Command1.Enabled = False
Command2.Enabled = False
End If
End Sub

CLASE SELECT CASE DEL 13 DE JULIO 2017 Pag 17

Hacer un programa que dado un Nro nos indique a que estacin pertenece. Use todas las
consistencias del caso. El formulario es:

Private Function Ingreso() As Boolean


If Trim(Text1) <> "" Then
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Else
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = 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 Command1_Click()


nro = Val(Text1)
Select Case nro
Case 1
Label2 = " La estacion es VERANO"
Case 2
Label2 = "La estacion es INVIERNO"
Case 3
Label2 = "la estacion es OTOO"
Case 4
Label2 = "La estacion es PRIMAVERA"
End Select
End Sub

Private Sub Command2_Click()


Text1 = ""
Label2 = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()


End
End Sub

Private Sub Text1_Change()


If Val(Text1) < 0 Or Val(Text1) > 4 Then
MsgBox " DIGITE Solo de 1 a 4", 16, "ERROR"
Text1 = ""
Text1.SetFocus
Command1.Enabled = False
Command2.Enabled = False
Else
Ingreso
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Debe de Ingresar solo Nros", 64, " OJO OJO"
KeyAscii = 0 Rem Hace que no refleje el carcter digitado
End If
End Sub

EJEMPLO SUELDO CON TODAS LAS CONSISTENCIAS

Private Function Mayus(v As Integer) As Boolean


If (v >= 65 And v <= 90) Then
Mayus = True
Else
Mayus = False
End If
End Function
Private Function Min(v As Integer) As Boolean
If (v >= 97 And v <= 122) Then
Min = True
Else
Min = 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 Function Ingreso() As Boolean
If Trim(Text1) <> "" And Trim(Text2) <> "" And Trim(Text3) <> "" Then
Command1.Enabled = True
Command2.Enabled = True
Else
Command1.Enabled = False
Command2.Enabled = False
End If
End Function
Private Sub Command1_Click()
Dim Turno As String * 1
Nhe = Val(Text3)
Turno = Text2
Select Case Turno
Case "M"
Phe = 18 * Nhe
sueldo = 2830 + 2830 * 0.26 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
Case "T"
Phe = 21 * Nhe
sueldo = 2830 + 2830 * 0.32 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
Case "N"
Phe = 28 * Nhe
sueldo = 2830 + 2830 * 0.4 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
End Select
End Sub
Private Sub Command2_Click()
Text1 = "": Text2 = "": Text3 = "": Text4 = "": Label4 = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Static espacio As Boolean
If KeyAscii = 13 Then
Text2.SetFocus
End If
If KeyAscii = 32 Then
espacio = True
Else
If Mayus(KeyAscii) Or Min(KeyAscii) Or Numero(KeyAscii) Then
If Trim(Text1) = "" Or espacio Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Else
KeyAscii = Asc(LCase(Chr(KeyAscii)))
End If
espacio = False
Else
MsgBox "Ingrese solo LETRAS", 16, "NO..NO"
End If
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim Turno As String * 1
If KeyAscii = 13 Then
Text3.SetFocus
Else
Turno = UCase(Chr(KeyAscii))
If Turno = "M" Or Turno = "T" Or Turno = "N" Then
KeyAscii = Asc(Turno) ' convierte la letra ingresada a Mays
'Command2.Enabled = True
Command3.Enabled = True
Else
MsgBox "Ingrese solo M,N o T ", 16, "OJO TURNO"
KeyAscii = 0
'Command2.Enabled = False
Command3.Enabled = False
End If
End If
End Sub
Private Sub Text3_Change()
If Val(Text3) < 0 Or Val(Text3) > 6 Then
MsgBox "Las Horas Extras" & Chr(13) & "Solo Hasta 6 Hrs", 16, "ERROR"
Text3.SelStart = 0
Text3 = ""
Text3.SetFocus
Else
Ingreso
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Ingrese SOLO Nros", 64, "OJO NROS"
KeyAscii = 0
Command2.Enabled = True
Command3.Enabled = True
End If
End Sub
EJERMPLO USO DEL INTPUTBOX

Private Sub Command1_Click()


Text1.Locked = True
saldo = Val(InputBox("Ud Compra" + Chr(13) + " El costo es", "COMPRA", 0))
Label2 = Val(Label2) + saldo
Mayus = UCase(Text1)
Text2 = Mayus
End Sub

Private Sub Command2_Click()


End
End Sub

EJEMPLO DE SUELDO APLICANDO CONSISTENCIAS


A TODOS LOS CONTROLES
Private Function Mayus(v As Integer) As Boolean
If (v >= 65 And v <= 90) Then
Mayus = True
Else
Mayus = False
End If
End Function

Private Function Min(v As Integer) As Boolean


If (v >= 97 And v <= 122) Then
Min = True
Else
Min = 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 Function Ingreso() As Boolean
If Trim(Text1) <> "" And Trim(Text2) <> "" And Trim(Text3) <> "" Then
Command1.Enabled = True
Command2.Enabled = True
Else
Command1.Enabled = False
Command2.Enabled = False
End If
End Function

Private Sub Command1_Click()


Dim Turno As String * 1
Nhe = Val(Text3)
Turno = Text2
Select Case Turno
Case "M"
Phe = 18 * Nhe
sueldo = 2830 + 2830 * 0.26 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
Case "T"
Phe = 21 * Nhe
sueldo = 2830 + 2830 * 0.32 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
Case "N"
Phe = 28 * Nhe
sueldo = 2830 + 2830 * 0.4 + Phe
Text4 = "Sr." & StrConv(Text1, 1)
Label4 = "SU PAGO ES = " & sueldo
End Select
End Sub

Private Sub Command2_Click()


Text1 = "": Text2 = "": Text3 = "": Text4 = "": Label4 = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()


End
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


Static espacio As Boolean
If KeyAscii = 13 Then
Text2.SetFocus
End If
If KeyAscii = 32 Then
espacio = True
Else
If Mayus(KeyAscii) Or Min(KeyAscii) Or Numero(KeyAscii) Then
If Trim(Text1) = "" Or espacio Then
KeyAscii = Asc(UCase(Chr(KeyAscii)))
Else
KeyAscii = Asc(LCase(Chr(KeyAscii)))
End If
espacio = False
Else
MsgBox "Ingrese solo LETRAS", 16, "NO..NO"
End If
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)


Dim Turno As String * 1
If KeyAscii = 13 Then
Text3.SetFocus
Else
Turno = UCase(Chr(KeyAscii))
If Turno = "M" Or Turno = "T" Or Turno = "N" Then
KeyAscii = Asc(Turno) ' convierte la letra ingresada a Mays
'Command2.Enabled = True
Command3.Enabled = True
Else
MsgBox "Ingrese solo M,N o T ", 16, "OJO TURNO"
KeyAscii = 0
'Command2.Enabled = False
Command3.Enabled = False
End If
End If
End Sub

Private Sub Text3_Change()


If Val(Text3) < 0 Or Val(Text3) > 6 Then
MsgBox "Las Horas Extras" & Chr(13) & "Solo Hasta 6 Hrs", 16, "ERROR"
Text3.SelStart = 0
Text3 = ""
Text3.SetFocus
Else
Ingreso
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)


If Numero(KeyAscii) Or KeyAscii = 13 Or KeyAscii = 8 Then
Ingreso
Else
MsgBox "Ingrese SOLO Nros", 64, "OJO NROS"
KeyAscii = 0
Command2.Enabled = True
Command3.Enabled = True
End If
End Sub

Trabajo para el 20 de julio


Hacer un programa para controlar el pago de los operarios de una mina, con las siguientes
caractersticas:
Se desea saber cuento se le paga al empleado ya sea Masculino o Femenino que trabaja en las
reas de:
Area Sexo Descuento
Planificacion M 1856 F 1473 6%
Logistica 2671 2100 4%
Operaciones 3176 2980 7%
Control 2780 2210 8.5%
Disee su formulario

CLASE DE CADENAS Y FECHAS 20 DE JULIO 2017


1.- APLICACIN DE CADENAS pag 23
Dim Frase As String
Private Sub Command1_Click()
Frase = Trim(TxtCadena)
Text2 = UCase(Frase)
Text3 = LCase(Frase)
Text4 = StrConv(Frase, 3)
Text5 = Len(Frase)
Text6 = Left(Frase, 1)
Text7 = Right(Frase, 1)
Text8 = Mid(Frase, 4, 3)
Text9 = InStr(1, Frase, "a")
End Sub

Private Sub Command2_Click()


TxtCadena = "": Text2 = "": Text3 = "": Text4 = ""
Text5 = "": Text6 = "": Text7 = "": Text8 = ""
Text9 = "": TxtCadena.SetFocus
End Sub

2. APLICACIN DE FECHAS
En GENERAL

Dim Fecha As Date: Dim Dia, DiaSem, Mes, Ao As Integer


Dim Ndia, Nmes As String * 10

Private Sub CmdMostrar_Click()


Fecha = CVDate(TxtFnac): Hoy = Date
DiaSem = Weekday(Hoy)
Dia = Day(Fecha): Mes = Month(Fecha): Ao = Year(Fecha)
Select Case DiaSem
Case 1: Ndia = "Domingo"
Case 2: Ndia = "Lunes"
Case 3: Ndia = "Martes"
Case 4: Ndia = "Miercoles"
Case 5: Ndia = "Jueves"
Case 6: Ndia = "Viernes"
Case 7: Ndia = "Sabado"
End Select
Select Case Mes
Case 1: Nmes = "Enero": Case 2: Nmes = "Febrero"
Case 3: Nmes = "Marzo": Case 4: Nmes = "Abril"
Case 5: Nmes = "Mayo": Case 6: Nmes = "Junio"
Case 7: Nmes = "Julio": Case 8: Nmes = "Agosto"
Case 9: Nmes = "Septiembre": Case 10: Nmes = "Octubre"
Case 11: Nmes = "Noviembre": Case 12: Nmes = "Diciembre"
End Select
Rem mostrar los pedidos
TxtDia = Dia: TxtMes = Nmes: TxtAo = Ao
Edad = 2017 - Val(TxtAo)
TxtSeor = StrConv(TxtApell, 3) & " Ud tiene " & Edad & " Aos"
LblHoy = "Hoy es " & Ndia
LblHora = Time
End Sub

Private Sub CmdNuevo_Click()


TxtApell = "": TxtFnac = "": TxtDia = "": TxtMes = ""
TxtAo = "": TxtSeor = "": TxtApell.SetFocus
End Sub

Private Sub CmdSalir_Click()


End
End Sub

Private Sub TxtApell_Change()


If Trim(TxtApell) <> "" Then
CmdSalir.Enabled = True
Else
CmdSalir.Enabled = False
End If
End Sub

Private Sub TxtApell_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then
TxtFnac.SetFocus
Else
'mientras se tapea Convierte a MAYUSC, lo ingresado
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End If
End Sub

Private Sub TxtFnac_LostFocus()


Consistenciar la FECHA
If Not IsDate(TxtFnac) Then
MsgBox "Debe formato FECHA(dd/mm/aa)", 64, "ERROR"
TxtFnac = "": TxtFnac.SetFocus
End If
End Sub

ESTRUCURAS DE CONTROL: DO.WHILE, DO.UNTIL y FOR ..NEXT pag 29


TRABAJO INDIVIDUAL, PARA EXPONER EL 27 DE JULIO
Alumnos con Apellido A hasta la C, un ejemplo usando DO.WHILE
Alumnos con Apellido D hasta la Q, un ejemplo usando DO.UNTIL
Alumnos con Apellido R hasta la V, un ejemplo usando FOR.NEXT

EJM: Genere un programa que permita mostrar en una caja de texto los Nros que sean mltiplos
de 2 pero no de 6, entre los primeros 40 Nros.

La caja de texto debe tener las siguientes


propiedades:

Propiedad Valor
Height 2200
Locked True
MultiLine true
ScrollBars 2- Vertical
Text
Private Sub CmdBuscar_Click()
Dim Num As Integer
For Num = 1 To 40
If Num Mod 2 = 0 Then
If Num Mod 3 <> 0 Then
TxtNum = TxtNum & vbNewLine & Str(Num)
End If : Escribe cada Nro en una nueva linea
End If
Next Num
End Sub

EJM: Generar un programa para calcular el valor de P, si P=


3 a+ 2 , si a varia de 1,2,315
2 a4
use la estructura FORNEXT

CLASE DEL 27 DE JULIO CONTROLES:


APLICACIN: Usando los controles del formulario, se desea hallar el pago del empleado, de
acuerdo a la siguiente tabla y formulario.

Area Mas Fem Dscto %


c
Planificacin 2890 2750 5.5
Logstica 2600 2400 7.25
Operaciones 3450 3120 6.5
Control 3050 3290 8.25

Private Sub CmdCalcula_Click()


Dim Area As String
Dim Pago As Single
Area = Trim(CmbArea)
Select Case Area
Case "OPERACIONES"
If OptMas.Value = True Then
Pago = (3450 - 3450 * 0.06)
Else
Pago = (3120 - 3120 * 0.065)

End If
Case "LOGISTICA"
If OptMas.Value = True Then
Pago = (2600 - 2600 * 0.0725)
Else
Pago = (2400 - 2400 * 0.0725)
End If
Case "PLANIFIC"
If OptMas.Value = True Then
Pago = (2890 - 2890 * 0.055)
Else
Pago = (2750 - 2750 * 0.055)
End If
Case "CONTROL"
If OptMas.Value = True Then
Pago = (3050 - 3050 * 0.0825)
Else
Pago = (3290 - 3290 * 0.0825)
End If
End Select
TxtSr = "Sr(ta) " & UCase(TxtApell)
Rem unica salida para cada CASE
Label2 = "AREA de = " & Area & " Su PAGO = " & Pago
End Sub

Private Sub CmdNuevo_Click()


CmbArea.Text = "< SU AREA ES >"
OptMas.Value = False
OptFem.Value = False
TxtApell = "" :TxtSr = "" : Label2 = ""
TxtApell.SetFocus
End Sub

CLASE DEL 03 DE AGOSTO: USO DE DO.LOOP UNTIL ()


Control LIST1 , muestra en una caja una lista de datos o resultados del proceso de un programa.

El DOLOOP es una sentencia de iteracin repetida de un grupo de sentencias, consideradas


dentro de DO, hasta que LOOP UNTIL variable = condicion (cumpla la condicin)
DO
-
-
LOOP UNTIL AA=0
Ejemplo; Hacer un programa que de cierta cantidad de
Nros, analice y cuente cuantos Nros son Positivos,
Cuantas Negativos, cuntos son Pares, Cuantos Impares
y nos reporte el Total de Nros ingresados, de acuerdo al
siguiente formulario:

Private Sub Command1_Click()


i = 0: cn = 0
cp = 0: cim = 0: cpa = 0
' aqui se inicia el LOOP Hacer
Do
i=i+1
numero = InputBox("Ingrese el Numero : " & i & Chr(13) & "CERO FINALIZA")
If numero <> 0 Then
List1.AddItem (numero) ' Muestra los Nros digitados a la Lista
For n = 1 To i
TR = List1.ListCount ' Cuenta los Nros de la Lista
Next
End If
If numero < 0 Then
cne = cne + 1
Else
If numero > 0 Then
cpo = cpo + 1
End If
End If

If numero <> 0 Then


If numero Mod 2 = 0 Then
cpa = cpa + 1
Else
cim = cim + 1
End If
End If

Loop Until numero = 0 'Finaliza el DO


Text1 = cne: Text2 = cpo: Text3 = cpa: Text4 = cim
Text5 = TR
End Sub

Private Sub Command2_Click()


Text1 = "": Text2 = "": Text3 = "": Text4 = "": Text5 = ""
List1.Clear 'Limpia los datos ingresados de la Lista

End Sub

Private Sub Command3_Click()


End
End Sub

ALGUNOS CONTROLES MS
- COMBOBOX, para digitar el contenido del comboBox ir a la propiedad List (Lista) y
digitar, para pasar a la siguiente lnea del box tenga presionado Ctr + Enter y digite.
- TOOLTIPTEXT, esta propiedad nos muestra en tiempo de ejecucin el mensaje digitado
en dicha propiedad, solo con acercar el cursor al control elegido.
- FRAME, es como un formulario auxiliar, donde debe tener un ttulo y dentro de l se
puede insertar ms controles. Como por ejem Option, Chek etc.
- OPTIONBUTTON, este control solo acepta elegir una sola opcin, que debe estar en
TRUE en el cdigo.
- CHEKBOX, en cambio este control nos permite elegir varias opciones, que deben estar
con TRUE.
2.- USO DE 2 O MAS FORMULARIOS EN UN PROYECTO
Para activar uno u otro formulario al momento de ejecutar un programa, se usa los siguientes
comandos con su respectivo mtodo.
- LOAD, cargar el formulario en memoria, pero no se hace visible
- UNLOAD, descarga completamente el formulario de la memoria ram
- SHOW, hace 2 cosas al mismo tiempo es decir carga en memoria y lo hace visible el
formulario.
- HIDE, oculta el formulario, pero sigue permaneciendo en memoria ram.

EJEMPLO
Haciendo uso de 2 formularios, simule el ingreso a un aplicativo mediante una
contrasea de usuario, de acuerdo al formulario mostrado.
FORMULARIO 1
FORMULARIO 2

Private Sub CmdAcceder_Click()


usu = Trim(TxtUsuario): Pasw = Trim(TxtPassw)
If usu = "INGENIERIA" And Pasw = "NAMI" Then
Form2.Show
Else
MsgBox "Acceso NO Aceptado", 64, "CUIDADO"
TxtUsuario = "": TxtPassw = ""
TxtUsuario.SetFocus
End If

End Sub

Private Sub CmdSalir_Click()


End
End Sub

Private Sub TxtPassw_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Or KeyAscii = 8 Then
CmdAcceder.Enabled = False
CmdSalir.Enabled = True
Else
'mientras se tapea Convierte a MAYUSC, lo digitado
KeyAscii = Asc(UCase(Chr(KeyAscii)))
CmdSalir.Enabled = True
End If

End Sub

Private Sub TxtUsuario_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Or KeyAscii = 8 Then


CmdAcceder.Enabled = True
CmdSalir.Enabled = True
TxtPassw.SetFocus
Else
'Mientras tipea convierte a mayuscula
KeyAscii = Asc(UCase(Chr(KeyAscii)))
CmdSalir.Enabled = False
End If
End Sub

TRABAJO PARA EL JUEVES 10 DE AGOSTO 2017


CON TODO LO APRENDIDO, HACER UN PROGRAMA CON DOS FORMULARIOS, DE UNA AGENCIA
DE VIAJES, QUE NOS REPORTE EN EL 2do. FORMULARIO EL LUGAR DE VIAJE Y EL VALOR DEL
PASAJE, DE ACUERDO A LO SIGUIENTE: Y EN EL 1er. FORMULARIO LA CONTRASEA DE INGRESO
LUGAR DE HUARAZ A. COSTO: M T - N
ICA 95 110 125
TACNA 130 150 170
TRUJILLO 60 50 80
TUMBES 135 150 180
LORETO 140 160 190
AREQUIPA 210 240 260
LIMA 40 55 70
PIURA 120 140 160

BASE DE DATOS USO EN CONSOLA JUEVES 10 DE agosto de 2017

- QUE ES UN REGISTRO:
- QUE ES UN CAMPO
- TIPO DE CAMPOS: Los campos mas usados son
a) Texto o Character
b) Numerico: single, doubl, entero, moneda
c) Logico: si/no
d) Fecha: mm/dd/yy
Tambin es necesario conocer un DATO COMPRIMIDO, la cual es manejada como un
cdigo o clave, por ejm la clave de una cuenta, el cdigo del alumno es decir
89.AD.0124.5 el cual tiene su significado que hasta el 2000 todava tenia vigencia.

- QUE ES UNA TABLA, es el conjunto de registros tomados de acuerdo al ingreso de datos


proporcionados.
- COMO SE CREA UNA DB EN ACCESS ? Seguir las instrucciones paso a paso

CREAR UNA DB QUE TENGA LA SIGUIENTE CONFIGURACION


Que tenga los siguientes campos:
CLAVE APELL NOMB SUELDO FE_ING SEXO E_CIVI
(T4) (T10) (T7) (N7:2) (F8) (L1) L
(T1)
UP05 CERNA LOPEZ LUIS 679,79 09/11/8 O C
9
etc etc etc

CONSULTAS A UNA DB POR CONSOLA USANDO EL SQL


Para hacer una consulta de una DB en Access, en la pestaa CREAR diseo de consulta QSL
vista de SQL.

CONSULTAS A UNA DB POR CONSOLA CLASE 11 AGOSTO 2017

Configurar una DB con una tabla llamada ROLA, que tiene los datos de los empleados de una
mina y tenga la siguiente configuracin:
CODIGO F_NAC APELL NOMB SUELDO PROF FE_ING DIREC
(T7) (F8) (T7) (T10) (N7:2) (T10) (F8) (T15)

Donde el campo CODIGO es un campo comprimido que contiene la siguiente informacin


- AREA DE TRABAJO (2) PL, MT, GE, SE, OP,RH, RP, PC, etc
- SEXO (1) M o F
- CONDICION LABORAL (1) N, C, J, S
- LUGAR DE NACIMIENTO (2) HZ, IC, HY, YG, CZ, HC, LI, TR, etc
- ESTADO CIVIL (1) S, C, V. D
LA TABLA GENERADA DEBE TENER AL MENOS 15 REGISTROS

EJEMPLO DE CONSULTAS
1.- Visualizar 1 y 7 poniendo nombres y apellidos en un solo campo (campos calculados

SELECT CODIGO, DIREC, NOMB & " " & APELL FROM ROLA
Aparece un campo con Exp.00345, ahora ponemos un titulo a ese campo calculado
2.- la orden seria
SELECT CODIGO, DIREC, NOMB & " " & APELL AS NOMBRE_APELLIDOS FROM ROLA

3.- Visualizar 1,3 y 7 de todos los empleados que vivan en BELEN (sentencia condicional)

SELECT CODIGO, APELL, DIREC FROM ROLA WHERE DIREC="BELEN"

4.- Visualizar 5,4 y 2 de todos los empleados que ganen ms de 950 y apelliden GIL

V 4,8,1 DE TODOS LOS EMPLEADOS CUYO APELLIDO EMPIECE CON R O SEAN DE HUARAZ

SELECT CODIGO, APELL, SUELDO FROM ROLA WHERE SUELDO > 950 AND LEFT(APELL,3)="GIL"

5.- Visualizar 5,3 y 6 de todos los empleados nacidos en YUNGAY y apelliden LEON

SELECT CODIGO, APELL, SUELDO FROM ROLA WHERE MID(CODIGO,5,2)="YG" AND


LEFT(APELL,4)="LEON"
6.- Visualizar 1, 3 y 7 de todos los empleados que ingresaron el 25 de marzo o vivan en BELEN

SELECT CODIGO, APELL, SUELDO FROM ROLA WHERE FORMAT(F_ING,"dd/mm") ="18/09"


OR DIREC="BELEN

You might also like