Problemas VB
-
Upload
michelle-trujillo -
Category
Documents
-
view
264 -
download
2
description
Transcript of Problemas VB
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
CUESTIONARIO
1. ¿Qué es un objeto? ¿Cómo lo identificas en el código ejemplo?R=Un objeto es una combinación de código y datos que puede tratarse como una unidad. Un objeto puede ser una porción de una aplicación, como un control o un formulario. Los objetos actúan como bloques de creación prefabricados para programas: permiten escribir una porción de código y utilizarla una y otra vez.
En el código ejemplo el objeto es la etiqueta y el botón de comando que se asigno a través del programa, lugar donde se escribió el código
2. ¿Qué es un evento? ¿Cómo lo identificas en el código ejemplo?R= Un evento es una señal que comunica a una aplicación que ha sucedido algo importante Los eventos también permiten que las tareas separadas se comuniquen.
En el código ejemplo un evento se ejecuta a partir de la asignación de un código específico para ese evento que en este caso fue el evento “click”
3. ¿Qué es una propiedad o atributo? En el código ¿Cual es?R=Son etiquetas descriptivas aque proporcionan información adicional, con los atributos, puede especificar los metadatos casi del mismo modo en que utiliza palabras clave como Public y Private para proporcionar información sobre niveles de acceso.
En el código ejemplo se utiliza “PRIVATE”
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
PRACTICA 2
Definición del problema
Sumar dos números enteros en visual basic.
Análisis del problema
- Se necesita una 4 etiquetas , 3 cajas de texto y un botón de comando - Asignar nombre a los objetos
Label1.Caption=”Suma de dos numeros”Label2.Caption=”Num1”Label3.Caption=”Num2”Label4.Caption=”RESULTADO”Command1.Caption=”SUMAR”
- Para declarar una variable entera se escribe dentro de cada procedimiento:Dim Num1 As IntegerDim Num2 As Integer
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
- Para obtener valores se declaran:Num1 = Val(Text1)Num2 = Val(Text2)Text3 = str(Num1 + Num2)
Diseño de la solución del problemaa) Algoritmo
1. Inicio2. Leer Num13. Leer Num24. Suma=Num1+Num25. Mostrar suma6. Fin
b) Diagrama de flujo
INICIO
Num1
Num2
Suma=Num1+Num2
Mostrar suma
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Desarrollo a la Solución del Problema 'Nombre:Perez Trujillo Karla Michelle Grupo:82A N°Cuenta:314012483'Suma de dos numeros enterosPrivate Sub Command1_Click()Num1 = Val(Text1)Num2 = Val(Text2)Text3.Enabled = TrueText3 = Str(Num1 + Num2)Text3.Enabled = FalseEnd Sub
Private Sub Form_Load()Label1.Caption = "Suma de dos numeros"Label1.Alignment = 2Label1.FontSize = 18Label2.Caption = "Num1"Label2.Alignment = 2Label2.FontSize = 14Label3.Caption = "Num2"Label3.Alignment = 2Label3.FontSize = 14Label4.Caption = "Resultado"Label4.Alignment = 2Label4.FontSize = 14Command1.Caption = "Suma"Command1.FontSize = 14Text3.Enabled = FalseText1.FontSize = 16Text1.Alignment = 2Text2.FontSize = 16Text2.Alignment = 2Text3.Alignment = 2Text3.FontSize = 16
End Sub
FIN
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Private Sub Text1_Change()Dim Num1 As IntegerEnd Sub
Private Sub Text2_Change()Dim Num2 As Integer
End Sub
'Nombre:Perez Trujillo Karla Michelle Grupo:82A N°Cuenta:314012483'Codigo del form. principalPrivate Sub Command1_Click()Form2.ShowEnd Sub
Private Sub Form_Load()Form1.Caption = "frmPrincipal"Command1.Caption = "Cargar Formulario"
End Sub
'Codigo frm.SecundarioPrivate Sub Command1_Click()HideEnd Sub
Private Sub Command2_Click()Unload MeEnd Sub
Private Sub Command3_Click()HideSet Form2 = NothingEnd Sub
Private Sub Form_Activate()MsgBox ("Evento Activete")End Sub
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
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
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
1. ¿Cuáles son los eventos que se cargan al iniciar un formulario?
2. ¿Para qué sirve el evento "Initialize"?
3. ¿Cuándo se produce el evento "Unload"?
4. ¿Qué actividades NO se pueden hacer sobre el evento "load"?
5. Explica que hace el método "hide" y el método "show".
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
6. ¿Qué hace el evento Activate y cuando se realiza?
7. ¿En qué parte del compilador de Visual Basic se colocan los Menús?
8. ¿qué hace el evento "Terminate"?
9. ¿en tu practica, ¿para que se usa la instrucción MsgBox?
10. ¿Para que sirve el evento Paint?
PRACTICA 4 Definición del problema
Pedirle al usuario lo siguientes datos : nombre ,edad ,estatura y promedio escolar .-Después 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"
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Análisis del Problema -Se necesitaran 1 etiqueta, 7 cajas de texto y un botón de comando -Nombrar a los objetos
Text1.Text = "¿Cuál es tu nombre?"Text2.Text = "¿Qué edad tienes?"Text3.Text = "¿Cuánto mides?"Text4.Text = "¿Cuál es tu promedio escolar?"Label1.Caption = "Ingresa los siguientes datos y obten tu valoración"Command1.Caption = "Valoración"Text5.Text = ""
Text6.Text = ""Text7.Text = ""
-Asignar el tipo de dato adecuado para las cajas de texto con las que interactuara el usuario
Dim Text1 As StringDim Text2 As IntegerDim Text3 As SingleDim Text4 As Single
-Para que la maquina le de sus valoraciones se tendrá que utilizar la sentencia if…then…else
If Text2 > 18 ThenText5 = "Eres mayor de edad"ElseText5 = "Eres Menor de Edad"End IfIf Text3 > 1.6 Then
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Text6 = "Eres Alto"ElseText6 = "Eres Bajo"End IfIf Text4 > 8 ThenText7 = "Buen Aprovechamieto"ElseText7 = "Regular Aprovechamiento"
End If
Diseño de la solución del problema a) Algoritmo
1. Inicio2. Leer Text13. Leer Text24. Leer Text35. Leer Text46. 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)entoncesText7 = "Buen Aprovechamiento"Text7 = "Regular Aprovechamiento"Finalizar
9. FIN
b) Diagrama de flujo
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Desarrollo de la solución del problema
'Nombre: Perez Trujillo Karla Michelle N°Cuenta:314012483'Practica 4
Private Sub Command1_Click()Text1.Enabled = FalseText2.Enabled = FalseText3.Enabled = FalseText4.Enabled = FalseText5.Enabled = True
Label1.Caption = "Ingresa los siguientes datos y obten tu valoración"Label1.Alignment = 2Label1.FontSize = 18Label1.ForeColor = vbBlueCommand1.Caption = "Valoración"Command1.FontSize = 14Text5.Text = ""Text5.Alignment = 2Text5.FontSize = 14Text6.Text = ""Text6.Alignment = 2Text6.FontSize = 14Text7.Text = ""Text7.Alignment = 2Text7.FontSize = 14Form1.BackColor = vbBlackEnd Sub
Private Sub Salir_Click()MsgBox ("Salir")End Sub
Private Sub Text1_Change()Dim Text1 As StringEnd Sub
Private Sub Text1_Click()Text1.Enabled = TrueText1.Text = ""End SubPrivate Sub Text2_Change()Dim Text2 As IntegerEnd SubPrivate Sub Text2_Click()Text2.Enabled = TrueText2.Text = ""End Sub
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Private Sub Text3_Change()Dim Text3 As SingleEnd Sub
Private Sub Command1_Click()Text1.Enabled = FalseText2.Enabled = FalseText3.Enabled = FalseText4.Enabled = FalseText5.Enabled = True
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Private Sub Text3_Click()Text3.Enabled = TrueText3.Text = ""End Sub
Private Sub Text4_Change()Dim Text4 As SingleEnd Sub
Private Sub Text4_Click()Text4.Enabled = TrueText4.Text = ""End SubPrivate Sub Form_Terminate()MsgBox ("Salir")
End Sub
Practica 6 “Mini-calculadora”
Definición del problema
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Diseñar una calculadora que realice las operaciones básicas (suma , resta, división, multiplicación) agregando la exponenciación y la raíz en visual basic
Análisis del problema
-Se necesitaran 3 etiquetas, 3 cajas de texto y 6 botones de comando -Asignar los nombres a los objetos :
Label1.Caption = "MINICALCULADORA"Label2.Caption = ""Label3.Caption = "="Text1.Text = ""Text2.Text = ""Text3.Text = ""Command1.Caption = "+"Command2.Caption = "-"Command3.Caption = "/"Command4.Caption = "*"Command5.Caption = "^"Command6.Caption = "raiz"Command7.Caption=”!”(Factorial)
-Considerar el tipo de operador que utilizara cada comando Command1----- Str(Num1 + Num2)
Command2----- Str(Num1 - Num2)Command3----- Str(Num1 / Num2)Command4----- Str(Num1 * Num2)Command5----- Str(Num1 ^ Num2)Command6----- Sqr(Num1)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Commanad7---fac = 1cont = 1While (cont <= text1)fac = fac * contcont = cont + 1WendText3 = Str(fac)
Diseño de la solución del problema
a) Algoritmo
1. Inicio2. Leer num13. Leer num2 4. Suma5. Resta6. División7. Multiplicación8. Exponenciación9. Raíz10. Fin
b) Diagrama de Flujo
1. Suma1. Suma=(num1+num2)2. Mostrar suma3. Fin
1. Resta2. Resta=( num1-num2)3. Mostrar resta4. Fin
1. División2. División= (num1/num2)3. Mostrar división4. Fin
1. Multiplicación2. Multiplicación=(num1*num2)3. Mostrar Multiplicación4. Fin
1. Exponenciación 2. Exponenciación=( num1^num2)3. Mostrar exponenciación 4. Fin
1. Raíz2. Raiz= sqr(num1)3. Mostrar raíz4. Fin
1. Factorial2. fac = 13. cont = 14. 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)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Desarrollo a la solución del problema
'Nombre: Perez Trujillo Karla Michelle N°Cuenta:314012483
'Practica 6
Private Sub Command1_Click()
Text1.BackColor = vbWhite
Label2.Caption = "/"
Label2.Alignment = 2
Label2.FontSize = 26
Num1 = Val(Text1)
Num2 = Val(Text2)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Text1.Enabled = True
Text1.BackColor = vbWhite
Label2.Caption = "+"
Label2.Alignment = 2
Label2.FontSize = 24
Num1 = Val(Text1)
Num2 = Val(Text2)
Text3 = Str(Num1 + Num2)
End Sub
Private Sub Command2_Click()
Text1.Enabled = True
Text1.BackColor = vbWhite
Label2.Caption = "-"
Label2.Alignment = 2
Label2.FontSize = 30
Num1 = Val(Text1)
Num2 = Val(Text2)
Text3 = Str(Num1 - Num2)
End Sub
Private Sub Command3_Click()
Text1.Enabled = True
Private Sub Command5_Click()
Private Sub Command6_Click()
Text1.Enabled = False
Text1.BackColor = vbBlack
Label2.Caption = "raíz"
Label2.Alignment = 2
Label2.FontSize = 22
Num1 = Val(Text2)
Command5.Caption = "^"
Command5.FontSize = 28
Command6.Caption = "raiz"
Command6.FontSize = 22
Command7.Caption = "!"
Command7.FontSize = 28
Private Sub Form_Load()
Label1.Caption = "MINICALCULADORA"
Label1.Alignment = 2
Label1.FontSize = 16
Label2.Caption = ""
Label3.Caption = "="
Label3.Alignment = 2
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Private Sub Command6_Click()
Text1.Enabled = False
Text1.BackColor = vbBlack
Label2.Caption = "raíz"
Label2.Alignment = 2
Label2.FontSize = 22
Num1 = Val(Text2)
Command5.Caption = "^"
Command5.FontSize = 28
Command6.Caption = "raiz"
Command6.FontSize = 22
Command7.Caption = "!"
Command7.FontSize = 28
Private Sub Form_Load()
Label1.Caption = "MINICALCULADORA"
Label1.Alignment = 2
Label1.FontSize = 16
Label2.Caption = ""
Label3.Caption = "="
Label3.Alignment = 2
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
PRACTICA 7
“Colores”
Definición del problema
Diseñar un programa que tenga las siguientes opciones: azul, rojo, verde, amarillo, arriba y abajo. En cada opción tendrá que aparecer automáticamente un marco de asteriscos.
Análisis del problema
Asignar 6 botones de opción colocando 4 en un frame y 2 en otro , un cuadro de texto.
Nombrar a los objetos:
Form1.Caption = "COLORES"
Frame1.Caption = "Colores"
Frame1.FontSize = 14
Option1.Caption = "Azul"
Option2.Caption = "Rojo"
Option3.Caption = "Verde"
Option4.Caption = "Amarillo"
Frame2.Caption = "Posicion"
Frame2.FontSize = 14
Option5.Caption = "Arriba"
Option6.Caption = "Abajo"
Text1.Text = ""
Boton2
Text1.BackColor = vbRed
Boton3
Text1.BackColor = vbGreen
Boton4
Text1.BackColor = vbYellow
Boton5
Text1.Top = 0
Boton6
Text1.Top = Form1.ScaleHeight - Text1.Height
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Asignar las acciones que realizara cada botón
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
Diseño de la solución del problema
a) Algoritmo
1. Asteriscos2. For cont= 1 To 41
Text1.text=Text1.text+”*”
Next
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
1. Inicio 2. Azul3. Rojo4. Verde5. Amarillo6. Arriba7. Abajo8. Fin
b) Diagrama de flujo
Desarrollo de la solución del problema
'Perez Trujillo Karla Michelle'NªCuenta:314012483 Grupo:82-A
1. Asteriscos2. For cont= 1 To 41
Text1.text=Text1.text+”*”
Next
End Sub
Private Sub Option2_Click()Text1.BackColor = vbRedEnd Sub
Private Sub Option3_Click()Text1.BackColor = vbGreenEnd Sub
Private Sub Option4_Click()Text1.BackColor = vbYellowEnd Sub
Private Sub Option5_Click()Text1.Top = 0End Sub
Private Sub Option6_Click()Text1.Top = Form1.ScaleHeight - Text1.Height
End Sub
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Private Sub Form_Load()Form1.Caption = "COLORES"Frame1.Caption = "Colores"Frame1.FontSize = 14Option1.Caption = "Azul"Option2.Caption = "Rojo"Option3.Caption = "Verde"Option4.Caption = "Amarillo"Frame2.Caption = "Posicion"Frame2.FontSize = 14Option5.Caption = "Arriba"Option6.Caption = "Abajo"Text1.Text = ""End Sub
Private Sub Option1_Click()Text1.BackColor = vbBlueText1.Enabled = FalseText1.FontSize = 14Text1.Text = "**"For cont = 1 To 41Text1.Text = Text1.Text + "*"NextText1 = Text1 & vbCrLfFor ren = 1 To 5Text1 = Text1 & "*"For esp = 1 To 58Text1 = Text1 & " "NextText1 = Text1 + "*"Text1 = Text1 & vbCrLfNextFor cont = 1 To 49Text1.Text = Text1.Text + "*"Next
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
PRACTICA 8 “Palíndromo”
Definición del problema
Identificar si una palabra o frase es un palíndromo
Análisis del problema
Asignar 1 cuadro de texto, 1 botón y 2 etiquetas
Nombrar a los objetos:
-Label1.Caption = "Ingresa tu frase"
-Text1.Text = ""
-Command1.Caption = "Comprobar"
-Label2.Caption = ""
Asignar el tipo de dato para cada variable
-Dim frase2 As String
-Dim frase As String
-Dim Pain As String
-Dim F As Integer
-Dim cont As Integer
Para leer el número de letras dentro de la frase o palabra se utiliza Len
Para eliminar espacios Replace(palin, " ", "")
Para saber si no es un palíndromo se utilizara un ciclo de repetición
For cont = 1 To F
frase = Mid(palin, cont, 1)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
frase2 = Mid(palin, F, 1)
If frase = frase2 Then
F = F - 1
Else
Label2.Caption = "No es un palindromo"
Diseño de la solución del problema
a) Algoritmo
1. Inicio2. Leer Palin3. Comprobar4. Mostrar Es palindromo5. Fin
b) Diagrama de Flujo
1. Comprobar2. 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
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Desarrollo de la solución del problema
'Perez Trujillo Karla Michelle'NªCuenta:314012483 Grupo:82-A
Private Sub Command1_Click()palin = LCase(Text1.Text)palin = Replace(palin, " ", "")F = Len(palin)Label2.Caption = "Es un palindromo"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" End IfNext End Sub
Private Sub Form_Load()Label1.Caption = "Ingresa tu frase"Label1.Alignment = 2Label1.FontSize = 14Label2.FontSize = 16Text1.Text = ""Command1.Caption = "Comprobar"Label2.Caption = ""Dim frase2 As StringDim frase As StringDim Pain As StringDim F As IntegerDim cont As IntegerEnd Sub
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
For Letra = 1 To Len(frase)If Mid(Text1, Letra, 1) = "a" Then numero = numero + 1NextLabel2 = numero
Private Sub Command1_Click()frase = LCase(Text1.Text)Dim numero As IntegerDim abc(1 To 27) As StringDim texto As Stringabc(1) = "a"abc(2) = "b"abc(3) = "c"abc(4) = "d"abc(5) = "e"abc(6) = "f"abc(7) = "g"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" Mid(Text1, numero, 1)abc(26) = "y"abc(27) = "z"For numero = 1 To Len(frase)texto = Mid(Text1, numero,
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
texto = Mid(Text1, numero, 1)Label2 = "a" & numero & vbCrLfNextEnd Sub
Private Sub Form_Load()Label1.Caption = "Ingresa tu texto"Label1.FontSize = 14Label2.Caption = " "Text1.Text = " "Command1.Caption = "#Letras"Command1.FontSize = 14
End Sub
For Letra = 1 To Len(frase)If Mid(Text1, Letra, 1) = abc(1) Thennumero = numero + 1Text2.Text = "a" & numeroEnd IfNext
PROGRAMA DE CARACTERES
Private Sub Command1_Click()
frase = LCase(Text1.Text)
Dim Letra As Integer
Dim Letra2 As Integer
Dim numero As Integer
Dim abc(1 To 27) As String
abc(1) = "a"
abc(2) = "b"
abc(3) = "c"
abc(4) = "d"
abc(5) = "e"
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
abc(6) = "f"
abc(7) = "g"
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
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Next
Label2.Caption = Label2.Caption & abc(Letra) & "=" & numero & vbCrLf
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
Private Sub Command2_Click()
Dim i, n, s, p, a() As Integer
n = List1.ListCount
ReDim a(n)
For i = 0 To n - 1
a(i) = List1.List(i)
Next i
For i = 0 To n - 2
For s = i + 1 To n - 1
If a(i) > a(s) Then
p = a(i)
a(i) = a(s)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
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
Private Sub Command3_Click()
Dim i, n, s, p, a() As Integer
n = List1.ListCount
ReDim a(n)
For i = 0 To n - 1
a(i) = List2.List(i)
Next i
For i = 0 To n - 2
For s = i + 1 To n - 1
If a(i) < a(s) Then
p = a(i)
a(i) = a(s)
a(s) = p
End If
Next s
Next i
List2.Clear
For i = 0 To n - 1
List2.List(i) = a(i)
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
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
Private Sub Form_Load()
Label1.Caption = "RAÍZ CUADRADA"
Label1.Alignment = 2
Nombre: Pérez Trujillo Karla Michelle Fecha: 21 de Enero 2016No. Cuenta :314012483 Grupo:82A
Label1.FontSize = 14
Label2.Caption = "Ingresa un número real para obtener su raíz cuadrada "
Text1.Text = " "
Text1.FontSize = 14
Text1.Alignment = 2
text2.Text = " "
text2.FontSize = 14
text2.Alignment = 2
Command1.Caption = "Resultado"
End Sub
Private Sub Text1_Change()
Dim Text1 As Integer
End Sub
Private Sub Text2_Change()
Dim text2 As Single
End Sub