martes, 10 de noviembre de 2009

INTRODUCCION DE VISUAL BASIC PARA PRINCIPIANTES


CAPITULO 2: PROPIEDADES


Aquí tienes una lista de algunas propiedades útiles

Para guardar un proyecto en Visual BasicEs recomendable que crees una carpeta para cada proyecto de Visual Basic. Haz clic en (File) Archivo, Save Form1 As... (Guardar Formulario1 Como...). En Save File As (Guardar Archivo Como), Save in (Guardar en) selecciona la carpeta o unidad de disco en donde guardarás tu proyecto de Visual Basic. En Name (Nombre) escribe el nombre del formulario (un nombre que tenga relación con el formulario como: entrada, contraseña, datos, etc.) y haz clic en Save (Guardar) Enseguida repite el procedimiento para guardar el proyecto


CAPITULOS 3: EJERCICIO-RELOJ Y CALENDARIO




Crea un formulario con cuatro etiquetas, un reloj con intervalo de 1000 y escribe el siguiente código:
Private Sub Timer1_Timer()
Label2.Caption = Time
Label4.Caption = Date
End Sub


CAPITULO 4 : EJERCICIO 2- TIPO DE CAMBIO

Crea un formulario con tres etiquetas, tres cajas de texto, cuatro botones y escribe el siguiente código:
Escribe el siguiente código:
El botón Ver Pesos
Private Sub Command1_Click()
Text1 = Val(Text2) * Val(Text3)
End Sub
El botón Ver Dólares
Private Sub Command2_Click()
Text2 = Val(Text1) / Val(Text3)
End Sub
El botón Nuevo Cálculo
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End Sub
El botón Salir
Private Sub Command4_Click()
Unload Me
End
End Sub

CAPITULO 5:EJERCICIO 4-CALCULADORA


Crea un formulario con cuatro etiquetas, cuatro cajas de texto, tres botones y escribe el siguiente código:
El botón Concatenar Datos
Private Sub Command1_Click()
Text4 = Text1 & " " & Text2 & " " & Text3
End Sub
El botón Nuevos Datos
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text1.SetFocus
End Sub
El botón Salir del Programa
Private Sub Command3_Click()
Unload Me
End
End SuB


Crea un formulario con cuatro etiquetas, cuatro cajas de texto, tres botones y escribe el siguiente código:
El botón Concatenar Datos
Private Sub Command1_Click()
Text4 = Text1 & " " & Text2 & " " & Text3
End Sub
El botón Nuevos Datos
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text1.SetFocus
End Sub
El botón Salir del Programa
Private Sub Command3_Click()
Unload Me
End
End Sub

CAPITULO 7: EJERCICIO 5- CALCULADORA 2


Crea un formulario con tres etiquetas, tres cajas de texto, seis botones y escribe el siguiente código:
El botón Nuevo Cálculo
Private Sub Command5_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End Sub
El botón Sumar
Private Sub Command1_Click()
Text3 = Val(Text1) + Val(Text2)
End Sub
El botón Restar
Private Sub Command2_Click()
Text3 = Val(Text1) - Val(Text2)
End Sub
El botón Multiplicar
Private Sub Command3_Click()
Text3 = Val(Text1) * Val(Text2)
End Sub
El botón Multiplicar
Private Sub Command4_Click()
Text3 = Val(Text1) / Val(Text2)
End Sub
El botón Salir
Private Sub Command6_Click()
Unload Me
End
End Sub

CAPITULO 8 :EJERCICIO 6: ALARMA


Crea un formulario con tres etiquetas, dos cajas de texto, dos botones, un reloj con intervalo de 1000 y escribe el siguiente código:
El botón Establecer la Alarma y Minimizar
Private Sub Command1_Click()
Form1.WindowState = 1
Timer1.Enabled = True
End Sub
El botón Salir
Private Sub Command2_Click()
Unload Me
End
End Sub
El reloj
Private Sub Timer1_Timer()
Dim horas As String
hora = Format(Time, "hh:mm")
If hora = Text1.Text Then
Beep
MsgBox Text2.Text, vbOKOnly + vbInformation, "Aviso de la Alarma"
Timer1.Enabled = False
Form1.WindowState = 0
End If
End Sub


CAPITULO 9 : EJERCICIO 7 - CALCULADORA 3


Crea un formulario con tres etiquetas, tres cajas de texto, un marco, cuatro botones de opción, tres botones y escribe el siguiente código:
El botón Calcular
Private Sub Command1_Click()
If Option1 = True Then
Text3 = Val(Text1) / Val(Text2)
ElseIf Option2 = True Then
Text3 = Val(Text1) * Val(Text2)
ElseIf Option3 = True Then
Text3 = Val(Text1) - Val(Text2)
ElseIf Option4 = True Then
Text3 = Val(Text1) + Val(Text2)
End If
End Sub
El botón Otra Operación
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text1.SetFocus
End Sub
El botón Salir
Private Sub Command3_Click()
Unload Me
End
End Sub

CAPITULO 10: EJERCICIO 8-CONVERSIONES


Crea un formulario con dos etiquetas, dos cajas de texto, un marco, cuatro botones de opción, tres botones y escribe el siguiente código:
El botón Convertir
Private Sub Command1_Click()
If Option1 = True Then
Text2 = Val(Text1) * 1000
ElseIf Option2 = True Then
Text2 = Val(Text1) * 100
ElseIf Option3 = True Then
Text2 = Val(Text1) * 10
ElseIf Option4 = True Then
Text2 = Val(Text1) / 1000
End If
End Sub
El botón Nuevo Cálculo
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text1.SetFocus
End Sub
El botón Salir
Private Sub Command3_Click()
Unload Me
End
End Sub


CAPITULO 11: EJERCICIO 9- CONCATENACION 2


Crea un formulario con un control con pestañas (haz clic con el botón derecho del ratón sobre la Caja de herramientas, haz clic en Components. En Components, Controls, selecciona el control Microsoft Tabbed Dialog Control 6.0 (SP5) y haz clic en Aceptar. El control aparecerá en la Caja de herramientas.), en la primera sección crea seis etiquetas, seis cajas de texto y dos botones.



En la segunda sección crea tres etiquetas, tres cajas de texto y un botón.
En este programa programaremos las cajas de texto para que el cursor avance con Enter a la siguiente caja de texto. Haz doble clic en la primera caja de texto y en la caja de opciones de eventos selecciona KeyPress y escribe el siguiente código:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
La caja de texto 2 la programaremos para que se introduzca automáticamente la fecha. Haz doble clic en la caja de texto 2, selecciona el evento GotFocus y escribe el siguiente código:
Private Sub Text2_GotFocus()
Text2.Text = Format(Now, "dd-mm-yyyy")
Text3.SetFocus
End Sub
Programa las cajas de texto (hasta la número seis) para que el cursor avance a la siguiente caja de texto.
El botón Salir
Private Sub Command1_Click()
Unload Me
End
End Sub
El botón Limpiar
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text6 = ""
Text7 = ""
Text8 = ""
Text9 = ""
Text1.SetFocus
End Sub
El botón Mostrar Datos
Private Sub Command3_Click()
Text7 = Text1 & " " & Text3
Text8 = Text4
Text9 = Text5
End Sub

CAPITULO 12 EJERCICIO 10-LAS TABLAS



Crea un formulario con una etiqueta, dos cajas de texto y tres botones.
Escribe el siguiente código:
El botón Ver Tabla
Private Sub Command1_Click()
Dim res As Long, retorno
For n = 1 To 10
res = Text1 * n
retorno = Chr(13) & Chr(10)
Text2 = Text2 & Text1 & " x " & n & " = " & res & retorno
Next n
End Sub
El botón Nueva Tabla
Private Sub Command2_Click ()
Text1 = ""
Text2 = ""
Text1.SetFocus
End Sub
El botón Salir
Private Sub Command3_Click()
If MsgBox("Por Favor Confirma Si Ya Te Quieres Ir", vbYesNo, "¿Qué Ya Te Quieres Ir?") = vbYes Then
End
Else
Cancel = 1
End If
End SuB

CAPITULO 13 EJERCICIO 11-LA GRAFICA



Crea un formulario con un cuadro de imagen e inserta la imagen que prefieras.
Agrega las etiquetas que necesites y coloca una al pie de la imagen y las demás sobre diferentes cosas de la imagen. En todas borra su Caption y de las que están sobre la imagen cambia su propiedad BackStyle a 0-Transparent y escribe el siguiente código:
La etiqueta 2
Private Sub Label2_Click()
Label1.Caption = "Mi Pollito"
End Sub
La etiqueta 3
Private Sub Label3_Click()
Label1.Caption = "El Papá"
End Sub
La etiqueta 4
Private Sub Label4_Click()
Label1.Caption = "Mi Papá y Mi Mamá"
End Sub

CAPITULO 14: EJERCICIO12 : ALBUM FOTOGRAFICO



Crea un formulario con un cronómetro con intervalo de 50 y escribe el siguiente código:
Private Sub Timer1_Timer()
Static a As Integer
a = a + 1
If a = 5 Then
Image1.Picture = LoadPicture("c:\windows\matrix_800.bmp")
End If
If a = 25 Then
Image1.Picture = LoadPicture("c:\windows\matrix_reloaded28.bmp")
End If
If a = 35 Then
Image1.Picture = LoadPicture("c:\windows\matrix_xp_800.bmp")
End If
If a = 45 Then
Image1.Picture = LoadPicture ("c:\windows\matrixreloaded800x600.bmp")
End If
If a = 55 Then
a = 0
End If
End Sub

No hay comentarios:

Publicar un comentario