Você está na página 1de 33

c  

 
   

|ñ  |
|

 |
    |

×| 1. Ejercicio1: Aprende a Sumar


×| . Ejercicio : Ordenar los Números
×| ë. Ejercicio ë: Calcular la edad
×| . Ejercicio : Cálculo de Ventas
×| 0. Ejercicio 0: Fecha Escrita
×| u. Ejercicio u: Análisis Numérico
×| £. Ejercicio £: Lista de Números
×| Ñ. Ejercicio Ñ: Registro de Cursos
×| ÿ. Ejerciocio ÿ: Palíndromos
×| 10. Ejercicio 10: Inter Compras Net
×| 11. Ejercicio 11: Calificaciones
×| 1. Ejercicio 1: Impresión

Capítulo 1:

    


Enlaces patrocinadosAgente Turismo Receptivo
Doble Titulación En 7m. Por Cordon Bleu. Sorteo 1/2 Beca. Contáctanos!
www.EducaOnline.pe/Le-Cordon-Bleu
Crea un formulario con cinco etiquetas, una caja de texto, tres botones, dos imágenes y tres
líneas. Modifica las propiedades de las etiquetas de las cantidades y la de la palabra de
resultado como sigue: BackColor blanco y Border Style 1-Fixed Single. Usa Font y
ForeColor para el tamaño y color del contenido y Alignment 2-Center

En Word crea las caritas y colócalas dentro de los cuadros de imágenes con su propiedad
Stretch en True, las líneas hazlas más gruesas en BorderWidth 3 y BorderColor azul.

Vamos a crear un procedimiento para generar al azar los números:

Haz doble clic en el formulario. Haz clic en Tools (Herramientas)/AddProcedure (Agregar


Procedimiento). En AddProcedure escribe el nombre del procedimiento, en este caso Azar
y haz clic en Aceptar. Ahora escribe el código:

Public Sub azar()

n1 = Int(Rnd * 10) + 1

n2 = Int(Rnd * 10) + 1

Label1.Caption = n1

Label2.Caption = n2

End Sub

Haz doble clic en el formulario y escribe el siguiente código:

Private Sub Form_Load()

Randomize

Call azar

Image1.Visible = False
Image2.Visible = False

End Sub

El botón Otra Suma

Private Sub Command1_Click()

Call azar

×| *Costosos Servidores? Olvidese con Google Apps Tecnología Cloud e Innovación


www.google.com.pe/aEnlaces patrocinados

Text1.Text = ""

Label3.Caption = ""

Image1.Visible = False

Image2.Visible = False

End Sub

El botón Revisar

Private Sub Command2_Click()

If Val(Text1) = Val(Label1) + Val(Label2) Then

Label3.Caption = "Bien"

Image1.Visible = True

Else

Label3.Caption = "Mal"

Image1.Visible = False

Image2.Visible = True

End If

End Sub

El botónSalir
Private Sub Command3_Click()

Unload Me

End

End Sub

×| TECSUP - Cursos Online Mejora tu desempeño profesional Actualiza tus


conocimientos
www.tecsup.edu.peEnlaces patrocinados

Capítulo 2:

     

Crea un formulario con nueve etiquetas, dos de ellas serán las instrucciones y a las que
contendrán los números (seis) cámbiales su Propiedad Alignment a 2-Center, BackColor
blanco, BorderStyle a 1-Fixed Single y tres botones, ahora

Introduce las siguientes declaraciones

Haz doble clic en el formulario En la caja de combo de la esquina superior izquierda


selecciona (General) Y escribe: Dim n1, n2, n3 As Integer (presiona Enter al terminar)

Ahora crea un procedimiento:

Haz doble clic en el formulario. Haz clic en Herramientas (Tools)/Agregar Procedimiento


(AddProcedure). En Agregar Procedimiento escribe el nombre del Procedimiento (en este
caso azar) y haz clic en Aceptar. Ahoraescribe el siguientecódigo:
Public Sub azar()
n1 = Int(Rnd * 10) + 1
n2 = Int(Rnd * 10) + 1
n3 = Int(Rnd * 10) + 1
If n1 <> n2 And n2 <> n3 And n1 <> n3 Then
Label1.Caption = n1
Label2.Caption = n2
Label3.Caption = n3
Else
Exit Sub
End If
End Sub

La etiqueta 4

Private Sub Label4_DragDrop(Source As Control, X As Single, Y As Single)

Label4.Caption = Source

Source.Visible = False

End Sub

La etiqueta 5

Private Sub Label5_DragDrop(Source As Control, X As Single, Y As Single)

Label5.Caption = Source

Source.Visible = False

End Sub

La etiqueta 6

Private Sub Label6_DragDrop(Source As Control, X As Single, Y As Single)

Label6.Caption = Source

Source.Visible = False

End Sub

El botónIniciar

Private Sub Command1_Click()

Label4.Caption = ""

Label5.Caption = ""
Label6.Caption = ""

×| TECSUP - Cursos Online Mejora tu desempeño profesional Actualiza tus


conocimientos
www.tecsup.edu.peEnlaces patrocinados

Label7.Caption = ""

Label1.Visible = True

Label2.Visible = True

Label3.Visible = True

Call azar

End Sub

El botón Resultado

Private Sub Command2_Click()

If Val(Label4.Caption) < Val(Label5.Caption) And Val(Label5.Caption) <


Val(Label6.Caption) Then

Label7.Caption = "Bien"

Else

Label7.Caption = "Mal"

End If

End Sub

El botón Salir

Private Sub Command3_Click()

Unload Me

End

End Sub

El formulario
Private Sub Form_Load()

Randomize

Call azar

End Sub

 |||

       


3   |   || | |
|
   |    |  ! "||3  |3 |#$  |%&|'|
(((  |

Crea un formulario con dos etiquetas, dos cajas de texto y tres botones, escribe el siguiente
código:

El botón Calcular la Edad

Private Sub Command1_Click()

Dim fecnac As Date, edad As Integer

fecnac = CDate(Text1)

edad = CInt((Date - fecnac) / 365)

Text2 = Str(edad) & " años"

End Sub
El botón Nuevo Cálculo

Private Sub Command2_Click()

Text1 = ""

Text2 = ""

Text1.SetFocus

End Sub

El botónSalir

Private Sub Command3_Click()

Unload Me

End

End Sub

Capítulo 4:

    


Enlaces patrocinadosAgente Turismo Receptivo
Doble Titulación En 7m. Por Cordon Bleu. Sorteo 1/2 Beca. Contáctanos!
www.EducaOnline.pe/Le-Cordon-Bleu

Crea un formulario con ocho etiquetas, ocho cajas de texto, un control Microsoft
HierarchicalFlexGrid (haz clic con el botón derecho del ratón sobre la caja de herramientas
y haz clic en Componentes, selecciona la casilla Microsoft HierarchicalFlexGrid Control
6.0 y haz clic en Aceptar) tres botones y escribe el siguiente código:
Dobleclicsobre el formulario

Private Sub Form_Load()

grdmenu.Cols = 2

grdmenu.Rows = 8

grdmenu.FixedCols = 0

grdmenu.FixedRows = 1

grdmenu.TextArray(0) = "Menú"

grdmenu.TextArray(1) = "Precio"

grdmenu.TextArray(2) = "Burrito"

grdmenu.TextArray(3) = "9.50"

grdmenu.TextArray(4) = "Burger"

grdmenu.TextArray(5) = "12.75"

grdmenu.TextArray(6) = "Torta"

grdmenu.TextArray(7) = "8.25"

grdmenu.TextArray(8) = "Refresco"

grdmenu.TextArray(9) = "4.00"

grdmenu.TextArray(10) = "Cerveza"

grdmenu.TextArray(11) = "15.60"

grdmenu.TextArray(12) = "Ensalada"

grdmenu.TextArray(13) = "14.45"

grdmenu.TextArray(14) = "Hot Dog"

grdmenu.TextArray(15) = "6.90"

End Sub
El botónAceptar

Private Sub Command1_Click()

×| TECSUP e-learning Capacitación de alto nivel con horarios a tu medida


www.tecsup.edu.peEnlaces patrocinados

Dim burrito As Integer, burger As Integer

Dim torta As Integer, refresco As Integer

Dim cerveza As Integer, ensalada As Integer

Dim hotdog As Integer, ventatotal As Double

burrito = Val(Text1)

burger = Val(Text2)

torta = Val(Text3)

refresco = Val(Text4)

cerveza = Val(Text5)

ensalada = Val(Text6)

hotdog = Val(Text7)

ventatotal = burrito * 9.5 + burger * 12.75 + torta * 8.25 + refresco * 4.60 + cerveza * 15.6
+ ensalada * 14.45 + hotdog * 6.9

Text8 = Str(ventatotal)

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ónSalir

Private Sub Command3_Click()

Unload Me

End

End Sub

Capítulo 5:

   ! "   


Enlaces patrocinadosVASTECEquipamentosInds.
PontesRolantes, TalhasElétricas, Guindastes,As.Técnica 11-3572-8000
www.vastec.com.br

Crea un formulario con cinco etiquetas, tres cajas de texto, un marco, tres botones y escribe
el siguiente código:

El botónConvertir

Private Sub Command1_Click()

Dim cadmes As String, mes As Integer


mes = Val(Text2)

Select Case mes

Case 1: cadmes = "Enero"

Case 2: cadmes = "Febrero"

Case 3: cadmes = "Marzo"

Case 4: cadmes = "Abril"

Case 5: cadmes = "Mayo"

Case 6: cadmes = "Junio"

Case 7: cadmes = "Julio"

Case 8: cadmes = "Agosto"

Case 9: cadmes = "Septiembre"

Case 10: cadmes = "Octubre"

Case 11: cadmes = "Noviembre"

Case 12: cadmes = "Diciembre"

Case Else

MsgBox "Revísalos Por Favor", vbCritical, "Hay un Error en los Datos...!!!"

×| Original Label Dispenser Dispensa-Matic made in USA ,NOW with Photoelectric


Sensor!
www.labeldispenser.comEnlaces patrocinados

Call Command2_Click

Exit Sub

EndSelect

Label4 = Text1 & " de " &cadmes& " de " & Text3

End Sub
El botónLimpiar

Private Sub Command2_Click()

Text1 = ""

Text2 = ""

Text3 = ""

Text1.SetFocus

End Sub

El botónSalir

Private Sub Command3_Click()

IfMsgBox("*Ya Quieres Salir del Programa?", vbQuestion + vbYesNo, "Tengo una


Pregunta para Ti") = vbYesThen

End

Else: Call Command2_Click

End If

End Sub

Capítulo 6:

  #  $ 


Crea un formulario con cuatro marcos, siete etiquetas, ocho cajas de texto, tres botones y
escribe el siguiente código:

El botónAnálisis

Private Sub Command1_Click()

If IsNumeric(Text1) Then

Dim s As Integer, si As Integer, sp As Integer

Dim may As Integer, min As Integer

Dim cad As String

Dim i As Integer, j As Integer

n = CLng(Text1)

m = CLng(Text1)

cad = ""

i=0

j=1

s = sp = si = 0

For j = 1 To n
If (n Mod j = 0) Then

cad = cad & j &vbCrLf

End If

Next j

While (n > 0)

If ((n Mod 10) Mod 2) = 0 Then

sp = sp + (n Mod 10)

Else

si = si + (n Mod 10)

End If

s = s + (n Mod 10)

n = n \ 10

i=i+1

Wend

may = Mid(Text1, 1, 1)

men = may

While (m > o)

If may < (m Mod 10) Then

may = m Mod 10

EndIf

×| Aprender Inglés Niños Divertido Curso de Inglés Sus Niños lo Amarán.


¡Conózcalo!
www.ganandoconingles.comEnlaces patrocinados

Ifmen> (m Mod 10) Then


men = m Mod 10

EndIf

m = m \ 10

Wend

Text2 = Str(i)

Text3 = Str(si)

Text4 = Str(sp)

Text5 = Str(s)

Text6 = Str(may)

Text7 = Str(men)

Text8 = cad

Else

MsgBox "Debes Introducir un Número, El que Quieras pero Introduce Un Número",


vbCritical, "Aviso Importante"

Text1.SetFocus

End If

End Sub

El botón Otro Número

Private Sub Command2_Click()

Text1 = "": Text2 = ""

Text3 = "": Text4 = ""

Text5 = "": Text6 = ""

Text7 = "": Text8 = ""

Text1.SetFocus
End Sub

El botónSalir

Private Sub Command3_Click()

IfMsgBox("*Deseas Cerrar el Programa?", vbQuestion + vbYesNo, "Aviso Antes de Cerrar


el Programa") = vbYesThen

End

Else

Cancel = True

Text1.SetFocus

End If

End Sub

Capítulo 7:

  %&  

Crea un formulario con tres marcos, una caja de texto, dos botones de opción, una caja de
lista, cuatro botones y escribe el siguiente código:

Haz doble clic en el formulario y escribe:

Private Sub Form_Unload(Cancel As Integer)

IfMsgBox("*Cerramos el Programa?", vbQuestion + vbYesNo, "*Ya nos Vamos?") =


vbYesThen
End

Else: Cancel = True: Text1.SetFocus

End If

End Sub

El botónAgregar

Private Sub Command1_Click()

If IsNumeric(Text1.Text) Then

List1.AddItem Text1.Text

Text1.Text = ""

Text1.SetFocus

Else

MsgBox "Introduce un Número", vbCritical, "Por Favor"

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

Text1.SetFocus

End If

End Sub

El botónOrdenar

Private Sub Command2_Click()

Dim i As Integer, j As Integer, t As Integer, n As Integer

Dim a() As Integer

n = List1.ListCount

ReDima(n)
For i = 0 To n - 1

a(i) = List1.List(i)

Next i

If Option1.Value Then

For i = 0 To n - 2

For j = i + 1 To n - 1

If a(i) > a(j) Then

t = a(i)

×| VASTEC Equipamentos Inds. Pontes Rolantes,


TalhasElétricas, Guindastes,As.Técnica 11-3572-8000
www.vastec.com.brEnlaces patrocinados

a(i) = a(j)

a(j) = t

End If

Next j

Next i

End If

Text1.SetFocus

If Option2.Value Then

For i = 0 To n - 2

For j = i + 1 To n - 1

If a(i) < a(j) Then

t = a(i)

a(i) = a(j)
a(j) = t

End If

Next j

Next i

End If

List1.Clear

For i = 0 To n - 1

List1.List(i) = a(i)

Next i

Text1.SetFocus

End Sub

El botón Lista Nueva

Private Sub Command4_Click()

Text1 = ""

List1.Clear

Text1.SetFocus

End Sub

El botónSalir

Private Sub Command3_Click()

IfMsgBox("*Seguro que Quieres Cerrar el Programa?", vbQuestion + vbYesNo, "*Ya es


Hora de Irnos?") = vbYesThen

End

Else: Cancel = True: Text1.SetFocus

End If
End Sub

Capítulo 8:

  '()   


Enlaces patrocinadosRead Excel on system i
Export Excel .xls or .xlsx to system i database file
www.ariadnesoftware.co.uk

Crea un formulario con cuatro marcos, seis etiquetas, cinco cajas de texto, un cuadro
combinado, dos cajas de lista, cuatro botones y escribe el siguiente código:

Private Sub Form_Load()

List1.AddItem "Intro.aSistemas"

List1.AddItem "Windows"

List1.AddItem "MS Word"

List1.AddItem "MS Excel"

List1.AddItem "MS PowerPoint"

List1.AddItem "MS Access"

List1.AddItem "SoporteTécnico"

List1.AddItem "Redes"
List1.AddItem "MS Visual Basic"

List1.AddItem "Internet"

List2.AddItem "Chihuahua"

List2.AddItem "Campeche"

List2.AddItem "Veracruz"

List2.AddItem "Colima"

List2.AddItem "Yucatán"

List2.AddItem "Sonora"

List2.AddItem "Sinaloa"

List2.AddItem "Puebla"

List2.AddItem "Tabasco"

List2.AddItem "Zacatecas"

Combo1.AddItem "Masculino"

Combo1.AddItem "Femenino"

End Sub

Private Sub Form_Unload(Cancel As Integer)

IfMsgBox("*Estás Seguro de Querer Cerrar el Programa?", vbQuestion + vbYesNo, "*Oye


qué pasa contigo?") = vbYesThen

End

Else

Cancel = True

End If

End Sub

Private Sub List1_Click()


Text1 = List1

End Sub

Private Sub List2_Click()

Text5 = List2

End Sub

El botónGuardar

Private Sub Command1_Click()

List1.Enabled = False

×| lPalabraClave: Carteras} Master En Gestión de Carteras Estudia Con Expertos!


www.ieb.esEnlaces patrocinados

List2.Enabled = False

Text1.Locked = True

Text2.Locked = True

Combo1.Locked = True

Text4.Locked = True

Text5.Locked = True

MsgBox "Este Alumno ha sido Matriculado", vbInformation, "Mensaje Importante"

End Sub

El botónLimpiar

Private Sub Command2_Click()

List1.Enabled = True

List2.Enabled = True

Text1.Locked = False

Text2.Locked = False
Text3.Locked = False

Combo1.Locked = False

Text4.Locked = False

Text5.Locked = False

Text1 = ""

Text2 = ""

Text3 = ""

Combo1 = ""

Text4 = ""

Text5 = ""

Text1.SetFocus

End Sub

El botónCancelar

Private Sub Command3_Click()

If MsgBox("DeseasCancelarAlgúnDato?", vbQuestion + vbYesNo,


"AvisoMuyImportante") = vbYes Then

List1.Enabled = True

List2.Enabled = True

Text1.Locked = False

Text2.Locked = False

Text3.Locked = False

Combo1.Locked = False

Text4.Locked = False

Text5.Locked = False
End If

End Sub

El botónSalir

Private Sub Command4_Click()

Unload Me

End

End Sub

 |)||

  *+ , 


3   |   | |3"  |
* |
+, |  ||
" ||- . |3 |/|0 1 ||
(((  .  |

Crea un formulario con tres etiquetas, dos cajas de texto, tres botones y escribe el siguiente
código:

Function cadinvertida(cadena As String) As String

Dim invertida() As String * 1

Dim i As Integer

Dim j As Integer
n = Len(cadena)

ReDiminvertida(n)

For i = 1 To n

invertida(i - 1) = Mid(cadena, i, 1)

Next i

For j = (n - 1) To 0 Step -1

cadinvertida = cadinvertida& invertida(j)

Next j

End Function

El botónInvertir

Private Sub Command1_Click()

Text2 = cadinvertida(Text1)

End Sub

El botón Limpiar

Private Sub Command2_Click()

Text1 = ""

Text2 = ""

Text1.SetFocus

End Sub

El botónSalir

Private Sub Command3_Click()

Unload Me

End
End Sub

 |||

  -    


3   |  2"  1 -  |
-  /   | |3* |4526(!
!  |* '|
(((  1    |

Crea un formulario con siete etiquetas, cinco cuadros image, un botón y escribe el siguiente
código:

Dim total As Double

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)

Source.Move X, Y

End Sub

El botón Cuenta Nueva

Private Sub Command1_Click()

Label7 = ""

total = o

End Sub
Private Sub Image5_DragDrop(Source As Control, X As Single, Y As Single)

If Source = Image1 Then

total = total + 250#

ElseIf Source = Image2 Then

total = total + 375#

ElseIf Source = Image3 Then

total = total + 400#

ElseIf Source = Image4 Then

total = total + 500#

End If

Label7 = "$" & total & ".00"

End Sub

Capítulo 11:

   .  


Enlaces patrocinadosVASTECEquipamentosInds.
PontesRolantes, TalhasElétricas, Guindastes,As.Técnica 11-3572-8000
www.vastec.com.br
Crea un formulario con ocho etiquetas, nueve cajas de texto, tres botones ye escribe el
siguiente código:

El botónSalir

Private Sub Command3_Click()

Unload Me

End

End Sub

El botónLimpiar

Private Sub Command2_Click()

Text1 = ""

Text2 = ""

Text3 = ""

Text4 = ""

Text5 = ""

Text6 = ""

Text7 = ""

Text8 = ""

Text9 = ""

Text1.SetFocus

End Sub

El botón Prom. Gral. Redondeado

×| Agente Turismo Receptivo Doble Titulación En 7m. Por Cordon Bleu. Sorteo 1/2
Beca. Contáctanos!
Cursos-Turismo.EducaOnline.peEnlaces patrocinados

Private Sub Command1_Click()


Dim n1 As Double, n2 As Double, n3 As Double, n4 As Double, n5 As Double, n6 As
Double

Dim promedio As Integer

n1 = Val(Text2): n2 = Val(Text3)

n3 = Val(Text4): n4 = Val(Text5)

n5 = Val(Text6): n6 = Val(Text7)

promedio = ((n1 + n2 + n3 + n4 + n5 + n6) / 6)

Text8 = Str(promedio)

If promedio>= 9.5 Then

Text9 = "Excelente"

End If

If promedio>= 9 Andpromedio< 9.5 Then

Text9 = "Muy Bien"

End If

If promedio>= 8.5 Andpromedio< 9 Then

Text9 = "Bien"

End If

If promedio>= 8 Andpromedio< 8.5 Then

Text9 = "Regular"

End If

If promedio< 8 Then

Text9 = "Mal"

End If

End Sub
Capítulo 12:

    /

Crea un formulario con seis etiquetas, seis cajas de texto, dos botones y escribe el siguiente
código:

El botónLimpiar

Private Sub Command2_Click()

Text1 = ""

Text2 = ""

Text3 = ""

Text4 = ""

Text5 = ""

Text6 = ""

Text1.SetFocus

End Sub

El botónImprimir

Private Sub Command1_Click()

Printer.Orientation = 1

Printer.FontSize = 12
Printer.Print

Printer.Print

×| PNL - Matriculas Abiertas Los títulos otorgados por la SCPNL tienen validez
internacional.
www.scpnl.clEnlaces patrocinados

Printer.Print

Printer.PrintTab(15); Label1.Caption; Tab(30); Text1.Text

Printer.Print

Printer.Print

Printer.PrintTab(15); Label2.Caption; Tab(30); Text2.Text

Printer.Print

Printer.Print

Printer.PrintTab(15); Label3.Caption; Tab(30); Text3.Text

Printer.Print

Printer.Print

Printer.PrintTab(15); Label4.Caption; Tab(30); Text4.Text

Printer.Print

Printer.Print

Printer.PrintTab(15); Label5.Caption; Tab(30); Text5.Text

Printer.Print

Printer.Print

Printer.PrintTab(15); Label6.Caption; Tab(30); Text6.Text

Printer.EndDoc

End Sub
|

Você também pode gostar