domingo, 11 de mayo de 2014

Lostfocus y Gotfocus.



Curso: 11A
Fecha: Mayo 12 de 2014

Curso: 11B y 11C
Fecha: Mayo 16 de 2014

Asignatura: Tecnología e Informática.
Formación en Valor: Amor a la Virgen María.
Núcleo Integrador: Eventos Lostfocus y Gotfocus.
Objetivo: Programar la ubicación del Mouse.

Evento Lostfocus
Este evento ocurre cuando el cursor sale de un objeto(Cuadro de Texto, Botón de comando, etc.)


Evento Gotfocus
Este evento ocurre cuando el cursor Entra o Cae en un objeto(Cuadro de Texto, Botón de comando, etc.)

Diseñe la siguiente pantalla:

Copie este código en la ventana de código del programa y ejecute el programa con F5
Private Sub Command1_Click()
  If Val(Text2) <= 1200000 Then
    Text3 = 70000
  Else
    Text3 = 0
  End If
  Text4 = Val(Text2) + Val(Text3)
  Command2.SetFocus
End Sub

Private Sub Command1_GotFocus()
  
  If Text3 <> "" Then
    MsgBox "No debe escribir el transporte este se calcula"
    Text3 = ""
  End If
  If Text4 <> "" Then
    MsgBox "No debe escribir El Total a Pagar este se calcula"
    Text4 = ""
  End If
  If Text2 = "" Then
    MsgBox "Debe escribir el Salario"
    Text2.SetFocus
  End If
  
End Sub

Private Sub Command2_Click()
  Text1 = ""
  Text2 = ""
  Text3 = ""
  Text4 = ""
  Text1.SetFocus
End Sub

Private Sub Text2_GotFocus()
  If Text1 = "" Then
    MsgBox "Debe escribir el nombre"
    Text1.SetFocus
  End If
End Sub

Private Sub Text3_GotFocus()
  If Text2 = "" Then
    MsgBox "Debe escribir el Salario"
    Text2.SetFocus
  End If
End Sub

Taller:


Teniendo en cuenta el programa anterior, Aplique lo aprendido al proyecto de matemáticas, utilice el evento Gotfocus.

Ejemplo Taller Matemáticas
Desarrollo: Desarrolle un programa que permita que estudiantes de primaria identifiquen el numero con la cantidad y su escritura.

Diseñe el siguiente formulario en Visual Basic 6.0.


NOTA: GRABAR EL PROYECTO Y LAS IMAGENES EN LA MISMA CARPETA, PARA QUE PUEDA FUNCIONAR EL PROYECTO.

Para lo anterior debe adicionar los siguientes objetos:
Objeto a utilizar:
Objeto Image, debe cambiarle la propiedad Stretch al valor TRUE.

Objeto LABEL, colocarlos del tamaño de los números y cambiarle la propiedad 
Backstyle  =  0-Transparet

Nota: el LABEL  debe estar acorde con el numero, ejemplo:
Dibuja el LABEL1, debe ser sobre el numero Uno.
Dibuja el LABEL2, debe ser sobre el numero Dos.
Etc.

A el objeto Image1, asignale en su propiedad Picture la siguiente image(Debes descargarla)

No le cambies el nombre.

Descarga las siguientes imágenes:
OJO AQUÍ HAY UNA IMAGEN EN BLANCO
IMAGEN OSO1

IMAGEN OSO2

IMAGEN OSO3

IMAGEN OSO4

IMAGEN OSO5

IMAGEN OSO6

IMAGEN OSO7

IMAGEN OSO8

IMAGEN OSO9

IMAGEN OSO1 GRANDE

Copie el siguiente código y pegarlo en la ventana de código de Visual Basic.


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Image2.Picture = LoadPicture(App.Path + "\" + "osito0.jpg")
  Label10 = "CERO"
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  Image2.Picture = LoadPicture(App.Path + "\" + "osito1.jpg")
  Label10 = "UNO"
End Sub

Private Sub Label2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito2.jpg")
Label10 = "DOS"
End Sub

Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito3.jpg")
Label10 = "TRES"
End Sub

Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito4.jpg")
Label10 = "CUATRO"
End Sub

Private Sub Label5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito5.jpg")
Label10 = "CINCO"
End Sub

Private Sub Label6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito6.jpg")
Label10 = "SEIS"
End Sub

Private Sub Label7_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito7.jpg")
Label10 = "SIETE"
End Sub

Private Sub Label8_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito8.jpg")
Label10 = "OCHO"
End Sub

Private Sub Label9_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image2.Picture = LoadPicture(App.Path + "\" + "osito9.jpg")
Label10 = "NUEVE"
End Sub



No hay comentarios:

Publicar un comentario