Documentos de Académico
Documentos de Profesional
Documentos de Cultura
CUESTIONARIO
1. Qu es un objeto? Cmo lo identificas en el cdigo ejemplo?
R=Un objeto es una combinacin de cdigo y datos que puede tratarse
como una unidad. Un objeto puede ser una porcin de una aplicacin,
como un control o un formulario.
Los objetos actan como bloques de creacin prefabricados para
programas: permiten escribir una porcin de cdigo y utilizarla una y
otra vez.
En el cdigo ejemplo el objeto es la etiqueta y el botn de comando
que se asigno a travs del programa, lugar donde se escribi el cdigo
a) Algoritmo
1. Inicio
2. Leer Num1
3. Leer Num2
4. Suma=Num1+Num2
5. Mostrar suma
6. Fin
b) Diagrama de flujo
INICIO
Num1
Num2
Suma=Num1+N
Mostrar suma
FIN
Form1.Caption = "frmPrincipal"
Command1.Caption = "Cargar Formulario"
End Sub
'Codigo frm.Secundario
Private Sub Command1_Click()
Hide
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Hide
Set Form2 = Nothing
End Sub
Private Sub Form_Activate()
MsgBox ("Evento Activete")
End Sub
Private Sub Form_Deactivate()
MsgBox ("Evento Deactivete")
End Sub
Private Sub Form_Initialize()
MsgBox ("Evento Initialize")
End Sub
Private Sub Form_Load()
Form2.Caption = "frmSecundario"
Command1.Caption = "Hide"
Command2.Caption = "Unload"
Command3.Caption = "Terminate"
MsgBox ("Evento Load")
End Sub
Private Sub Form_Paint()
MsgBox ("Evento Paint")
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
MsgBox ("QuaryUnload")
End Sub
Private Sub Form_Terminate()
MsgBox ("Terminate")
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox ("Unload")
End Sub
PRACTICA 4
Definicin del problema
Pedirle al usuario lo siguientes datos : nombre ,edad ,estatura y
promedio escolar .
-Despus el programa debe de decirnos si el usuario es "Mayor de Edad" o "Menor de
edad".
-Si mide mas de 1.60 metros, "Alto" en caso contrario "Bajo"
-Si el promedio es mayor de 8.0 escribir "Buen aprovechamiento", si es menor
"Regular aprovechamiento"
Text6.Text = ""
Text7.Text = ""
-Asignar el tipo de dato adecuado para las cajas de texto con las que
interactuara el usuario
Dim Text1 As String
Dim Text2 As Integer
Dim Text3 As Single
Dim Text4 As Single
-Para que la maquina le de sus valoraciones se tendr que utilizar la
sentencia ifthenelse
If Text2 > 18 Then
Text5 = "Eres mayor de edad"
Else
Text5 = "Eres Menor de Edad"
End If
If Text3 > 1.6 Then
Text6 = "Eres Alto"
Else
Text6 = "Eres Bajo"
End If
If Text4 > 8 Then
Text7 = "Buen Aprovechamieto"
Else
Text7 = "Regular Aprovechamiento"
End If
Diseo de la solucin del problema
a) Algoritmo
1. Inicio
2. Leer Text1
3. Leer Text2
4. Leer Text3
5. Leer Text4
6. Si (Text2>18) entonces
Text5 = "Eres mayor de edad"
Sino
Text5 = "Eres Menor de Edad"
Finalizar
7. Si (Text3>1.60) entonces
Text6 = "Eres Alto"
Si no
Text6 = "Eres Bajo"
Finalizar
8. Si (Text4>8.0)entonces
Text7 = "Buen Aprovechamiento"
Text7 = "Regular Aprovechamiento"
Finalizar
9. FIN
b) Diagrama de flujo
End Sub
Private Sub Form_Terminate()
MsgBox ("Salir")
End Sub
Practica 6
Mini-calculadora
fac = 1
cont = 1
While (cont <= text1)
fac = fac * cont
cont = cont + 1
Wend
Text3 = Str(fac)
Diseo de la solucin del problema
a) Algoritmo
1.
2.
3.
4.
5.
6.
7.
Inicio
Leer num1
Leer num2
Suma
Resta
Divisin
Multiplicacin
8. Exponenciacin
9. Raz
10.
Fin
1. Suma
1. Suma=(num1+nu
m2)
2. Mostrar suma
3. Fin
1. Resta
2. Resta=( num1num2)
3. Mostrar resta
4. Fin
1. Exponenciacin
2. Exponenciacin=( num1^num
2)
3. Mostrar exponenciacin
4. Fin
1.
2.
3.
4.
Raz
Raiz= sqr(num1)
Mostrar raz
Fin
b) Diagrama de Flujo
1.
2.
3.
4.
1.
2.
3.
4.
Divisin
Divisin= (num1/num2)
Mostrar divisin
Fin
1. Multiplicacin
2. Multiplicacin=(num1*nu
m2)
3. Mostrar Multiplicacin
4. Fin
Factorial
fac = 1
cont = 1
While (cont <=
text1) fac = fac *
cont
cont =
cont + 1
5. Mostrar =
Str(fac)
Text1.BackColor = vbWhite
Label2.Caption = "/"
Label2.Alignment = 2
Label2.FontSize = 26
Num1 = Val(Text1)
Num2 = Val(Text2)
Text3 = Str(Num1 / Num2)
End Sub
Text1.Enabled = True
Text1.BackColor = vbWhite
'Nombre: Perez Trujillo Karla Michelle NCuenta:314012483
Label2.Caption = "^"
'Practica 6
Label2.Alignment = 2
Private Sub Command1_Click()
Label2.FontSize = 28
Text1.Enabled = True
Num1 = Val(Text1)
Text1.BackColor = vbWhite
Num2 = Val(Text2)
Text3 = Str(Num1 ^ Num2)
End Sub
Private Sub
Form_Load()
Num2 = Val(Text2)
Label1.Caption =
"MINICALCULADORA"
Text3 = Str(Num1 + Num2)
End Sub
Label1.Alignment = 2
Label1.FontSize = 16
PrivatePrivate
Sub Sub Command2_Click()
Label2.Caption = ""
Command6_Click()
Text1.Enabled = True Label3.Caption = "="
Text1.Enabled = False
Label3.Alignment = 2
Text1.BackColor = vbWhite
Text1.BackColor = vbBlack
Label2.Caption = "-" Label3.FontSize = 24
Label2.Caption = "raz"
Label2.Alignment = 2 Text1.Text = ""
Label2.Alignment = 2
Label2.FontSize = 30 Text1.Alignment = 2
Label2.FontSize = 22
Text1.FontSize = 20
Num1 = Val(Text1)
Num1 = Val(Text2)
Text2.Text = ""
Num2 = Val(Text2)
Text3 = Sqr(Num1)
Text2.Alignment = 2
Text3 = Str(Num1 - Num2)
End Sub
Text2.FontSize = 20
End Sub
Text3.Text = ""
Private Sub
Text3.FontSize = 20
Private Sub Command3_Click()
Command7_Click()
Text1.Enabled
Text2.Enabled
= False= True Text3.Alignment = 2
Command1.Caption =
text1.Enabled = True
"+"
Private Sub
Text2.BackColor
= Command5_Click()
vbBlack
Command1.FontSize =
Label2.Caption = "!"
24
Label2.FontSize = 30
fac = 1
cont = 1
While (cont <= text1)
fac = fac * cont
cont = cont + 1
Wend
Text3 = Str(fac)
Command2.Caption =
"-"
Command2.FontSize =
30
Command3.Caption =
"/"
Command3.FontSize =
26
Command4.Caption =
"*"
Command5.Caption = "^"
Command5.FontSize = 28
Command6.Caption = "raiz"
Command6.FontSize = 22
Command7.Caption = "!"
Command7.FontSize = 28
End Sub
PRACTICA 7
Colores
Definicin
problema
Disear un
programa
tenga las
siguientes
opciones:
del
que
azul,
rojo, verde, amarillo, arriba y abajo. En cada opcin tendr que aparecer
automticamente un marco de asteriscos.
Anlisis del problema
Boton2
Text1.BackColor = vbRed
Boton3
Text1.BackColor = vbGreen
Boton4
Text1.BackColor = vbYellow
Boton5
Text1.Top = 0
Boton6
Text1.Top = Form1.ScaleHeight Text1.Height
Text1.Text = ""
Asignar las acciones que realizara cada botn
Boton1
Text1.BackColor = vbBlue
Text1.Enabled = False
Text1.FontSize = 14
Text1.Text = "**"
For cont = 1 To 41
Text1.Text = Text1.Text + "*"
Next
Text1 = Text1 & vbCrLf
For ren = 1 To 5
Text1 = Text1 & "*"
For esp = 1 To 58
Text1 = Text1 & " "
Next
Text1 = Text1 + "*"
Text1 = Text1 & vbCrLf
Next
For cont = 1 To 49
Text1.Text = Text1.Text + "*"
Next
1.
2.
3.
4.
5.
6.
7.
8.
Inicio
Azul
Rojo
Verde
Amarillo
Arriba
Abajo
Fin
1. Asteriscos
2. For cont= 1 To 41
Text1.text=Text1.text+*
Next
Text1 = Text1 & vbCrLf
3. For ren = 1 To 5
Text1 = Text1 & "*"
b) Diagrama de flujo
4. For esp = 1 To 58
Text1 = Text1 & " "
Next
Text1 = Text1 + "*"
Text1 = Text1 & vbCrLf
Next
5. For cont = 1 To 49
Text1.Text = Text1.Text
+ "*"
Next
6. Fin
End Sub
Private Sub Option2_Click()
Text1.BackColor = vbRed
End Sub
Private Sub Option3_Click()
Text1.BackColor = vbGreen
End Sub
Private Sub Option4_Click()
Text1.BackColor = vbYellow
End Sub
Private Sub Option5_Click()
Text1.Top = 0
End Sub
Private Sub Option6_Click()
Text1.Top = Form1.ScaleHeight Text1.Height
End Sub
PRACTICA 8
Palndromo
Definicin del problema
Identificar si una palabra o frase es un palndromo
Anlisis del problema
frase2 = Mid(palin, F, 1)
If frase = frase2 Then
F=F-1
Else
Label2.Caption = "No es un palindromo"
Diseo de la solucin del problema
a) Algoritmo
1.
2.
3.
4.
5.
Inicio
Leer Palin
Comprobar
Mostrar Es palindromo
Fin
1. Comprobar
2. For cont = 1 To F
frase = Mid(palin, cont, 1)
frase2 = Mid(palin, F, 1)
If frase = frase2 Then
F=F-1
Else
Label2.Caption = "No es
un palindromo"
3. Fin
b) Diagrama de Flujo
Next
End Sub
Private Sub Form_Load()
Label1.Caption = "Ingresa tu texto"
Label1.FontSize = 14
Label2.Caption = " "
Text1.Text = " "
Command1.Caption = "#Letras"
Command1.FontSize = 14
End Sub
For Letra = 1 To Len(frase)
If Mid(Text1, Letra, 1) = abc(1) Then
numero = numero + 1
Text2.Text = "a" & numero
End If
Next
PROGRAMA DE CARACTERES
abc(8) = "h"
abc(9) = "i"
abc(10) = "j"
abc(11) = "k"
abc(12) = "l"
abc(13) = "m"
abc(14) = "n"
abc(15) = ""
abc(16) = "o"
abc(17) = "p"
abc(18) = "q"
abc(19) = "r"
abc(20) = "s"
abc(21) = "t"
abc(22) = "u"
abc(23) = "v"
abc(24) = "w"
abc(25) = "x"
abc(26) = "y"
abc(27) = "z"
For Letra = 1 To 27
num = 0
For Letra2 = 1 To Len(Text1)
If Mid(Text1, Letra2, 1) = abc(Letra) Then
numero = numero + 1
End If
Next
End Sub
PRACTICA DE MAYOR Y MENOR
Option Explicit
Private Sub Command1_Click()
Dim C(15) As Integer
Dim CONT As Integer
For CONT = 0 To 15
C(CONT) = InputBox("ingrese numeros")
List1.AddItem C(CONT)
List2.AddItem C(CONT)
Next
End Sub
a(s) = p
End If
Next s
Next i
List1.Clear
For i = 0 To n - 1
List1.List(i) = a(i)
Next i
End Sub
Next i
End Sub
Private Sub Command1_Click()
Dim num, num1, num2, num3, raiz As Single
num1 = Val(Text1)
If num1 < 0 Then
MsgBox "No es valido"
Else
num2 = num1 / 2
num = num1 / num2
num3 = num + num2
raiz = 1 / 2 * num3
End If
raiz = 1 / 2 * ((num1 / raiz) + raiz)
resultado = raiz * raiz
If resultado = num1 + 0.0001 Then
text2 = raiz
Else
If resultado = num1 > num1 + 0.0001 < num1 + 0.005 Then
raiz = 1 / 2 * ((num1 / raiz) + raiz)
text2 = raiz
End If
End If
End Sub
Label1.FontSize = 14
Label2.Caption = "Ingresa un nmero real para obtener su raz cuadrada
"
Text1.Text = " "
Text1.FontSize = 14
Text1.Alignment = 2
text2.Text = " "
text2.FontSize = 14
text2.Alignment = 2
Command1.Caption = "Resultado"
End Sub
End Sub