Y tu…. Qué Programas?
Programar en Visual
REVISTA: -Leon Yanez Carlos Andrés
- Cuarto semestre B
INDICE
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29.
Enlace de formularios Ejercicios do while tablas de multiplicar Ejercicio for each netx Ejercicios funciones procedimientos Ejercicio select case validacion de fecha y 3 mas Ejercicios con cadena de caracteres Ejercicio simulardor web Ejercicio de agenda system io Ejercicio fibonacci Ejercicio factorial Ejercicio cara feliz Ejercicio numero primo Ejercicio cedula validacion Ejercicio ingresar numero y sacar pares impares Ejercicio bars Ejercicio menu de opciones Ejercicios animacion de texto Ejercicio de contrasena Ejercicio funcion mid len Ejercicio de texto vocales Ejercicio numero par Ejercicio ejercicos con if cartas Ejercicio con timer Ejercicio con if elseif endif Ejercicio de potencia Ejercicos los meses del a単o Ejercicio numero positivo negativo Ejercicos de vectores 4 Redim ejercicios 2
PR O G R A M A S :
Enlace de Formularios
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form2.Show() Me.Hide()
End Sub
PR O G R A M A S :
EDADES
PROGRAMACION
PR O G R A M A S :
Usuario y Contrase単a con Progress Bar
PROGRAMACION
PR O G R A M A S :
Verificar Cédula - Ecuador
PROGRAMACION Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Dim Dim Dim
prov As Integer par1, par2, par3, par4, pars As Integer im1, im2, im3, im4, im5, ims As Integer ced, ced1, ced2, n10, nt As Integer
'Validación Ingreso nt = Len(TextBox1.Text) If nt > 10 Or nt < 10 Then MsgBox("CÉDULA INCORRECTA") TextBox1.Text = "" TextBox1.Focus() Else 'provincia prov = Mid(TextBox1.Text, 1, 2) 'número de validación n10 = Mid(TextBox1.Text, 10, 1)
PR O G R A M A S :
Verificar Cédula - Ecuador
PROGRAMACION par1 = Mid(TextBox1.Text, 2, 1) par2 = Mid(TextBox1.Text, 4, par3 = Mid(TextBox1.Text, 6, par4 = Mid(TextBox1.Text, 8, 'suma pars = Val(par1) + Val(par2)
1) 1) 1) + Val(par3) + Val(par4)
'****************************************** 'impares im1 = Mid(TextBox1.Text, 1, 1) * 2 If im1 > 9 Then im1 = im1 - 9 im2 = Mid(TextBox1.Text, 3, 1) * 2 If im2 > 9 Then im2 = im2 - 9 im3 = Mid(TextBox1.Text, 5, 1) * 2 If im3 > 9 Then im3 = im3 - 9 im4 = Mid(TextBox1.Text, 7, 1) * 2 If im4 > 9 Then im4 = im4 - 9 im5 = Mid(TextBox1.Text, 9, 1) * 2 If im5 > 9 Then im5 = im5 - 9
PR O G R A M A S :
Verificar Cédula - Ecuador
PROGRAMACION ims = Val(im1) + Val(im2) + Val(im3) + Val(im4) + Val
(im5) '******************************************* 'validacion último número ced = ims + pars ced1 = Mid(ced, 1, 1) + 1 ced2 = ced1 * 10 ced = ced2 - ced If ced = n10 Then MsgBox("Cédula Válida")
PR O G R A M A S :
Verificar Cédula - Ecuador
PROGRAMACION If If If If If If If If If If If If If If If
prov prov prov prov prov prov prov prov prov prov prov prov prov prov prov
= = = = = = = = = = = = = = =
1 Then TextBox2.Text = " La Provincia es: AZUAY" 2 Then TextBox2.Text = " La Provincia es: BOLIVAR" 3 Then TextBox2.Text = " La Provincia es: CAÑAR" 4 Then TextBox2.Text = " La Provincia es: CARCHI" 4 Then TextBox2.Text = " La Provincia es: CARCHI" 5 Then TextBox2.Text = " La Provincia es: COTOPAXI" 6 Then TextBox2.Text = " La Provincia es: CHIMBORAZO" 7 Then TextBox2.Text = " La Provincia es: EL ORO" 8 Then TextBox2.Text = " La Provincia es: ESMERALDAS" 9 Then TextBox2.Text = " La Provincia es: GUAYAS" 10 Then TextBox2.Text = " La Provincia es: IMBABURA" 11 Then TextBox2.Text = " La Provincia es: LOJA" 12 Then TextBox2.Text = " La Provincia es: LOS RIOS" 13 Then TextBox2.Text = " La Provincia es: MANABÍ" 14 Then TextBox2.Text = " La Provincia es: MORONA SANTIAGO"
If prov = 15 Then TextBox2.Text = " La Provincia es: NAPO" If prov = 16 Then TextBox2.Text = " La Provincia If prov = 17 Then TextBox2.Text = " La Provincia If prov = 18 Then TextBox2.Text = " La Provincia If prov = 19 Then TextBox2.Text = " La Provincia If prov = 20 Then TextBox2.Text = " La Provincia If prov = 21 Then TextBox2.Text = " La Provincia If prov = 22 Then TextBox2.Text = " La Provincia If prov = 23 Then TextBox2.Text = " La Provincia If prov = 24 Then TextBox2.Text = " La Provincia Else MsgBox("Cédula no Valida") TextBox1.Text = "" TextBox1.Focus() End If End If
End Sub End Class
es: es: es: es: es: es: es: es: es:
PASTAZA" PICHINCHA" TUNGURAHUA" ZAMORA CHINCHIPE" GALAPAGOS" SUCUMBIOS" ORELLANA" Santo Domingo de los Tsachilas" SANTA ELENA"
PR O G R A M A S :
Tablas de Multiplicar
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim X, R, T, A, B, C, D, F, G, H, I, J, L As Integer While X < 10 X = X + 1 R = X * 1 ListBox1.Items.Add(R & "=" & X.ToString & " X " & "1") T = T + 1 R = T * 2 ListBox2.Items.Add(R & "=" & T.ToString & " X " & "2") A = A + 1 R = A * 3 ListBox3.Items.Add(R & "=" & A.ToString & " X " & "3") B = B + 1 R = B * 4
PR O G R A M A S :
Tablas de Multiplicar
PROGRAMACION B = B + 1
R = B * 4 ListBox4.Items.Add(R & "=" & B.ToString & " X " & "4") C = C + 1
R = C * 5 ListBox5.Items.Add(R & "=" & C.ToString & " X " & "5") D = D + 1
R = D * 6 ListBox6.Items.Add(R & "=" & D.ToString & " X " & "6") F = F + 1
R = F * 7 ListBox7.Items.Add(R & "=" & F.ToString & " X " & "7")
PR O G R A M A S :
Tablas de Multiplicar
PROGRAMACION
R = G * 8 ListBox8.Items.Add(R & "=" & G.ToString & " X " & "8") H = H + 1
R = H * 9 ListBox9.Items.Add(R & "=" & H.ToString & " X " & "9") L = L + 1
R = H * 12 ListBox12.Items.Add(R & "=" & L.ToString & " X " & "12") End While
End Sub
PR O G R A M A S :
For Each
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each dato As Control In Me.Controls 'sirve para todos los objetos del formulario 'If dato.GetType.ToString.Contains("Label") Then 'pinta todos los labels If dato.GetType.ToString.Contains("Button") Then 'pinta todos los butons dato.BackColor = Color.Aqua End If Next End Sub
PR O G R A M A S :
Funciones y Procedimientos
PROGRAMACION Public Function suma() As Integer Return Val(TextBox1.Text) + Val (TextBox2.Text) End Function Public Sub limpiar() TextBox1.Text = "" TextBox2.Text = "" Label2.Text = "" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label2.Text = suma() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click limpiar() End Sub
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A As Integer A = TextBox1.Text Select Case A Case 1 TextBox2.Text = "LUNES" Case 2 TextBox2.Text = "MARTES"
Case 3 TextBox2.Text = "MIERCOLES" Case 4 TextBox2.Text = "JUEVES" Case 5
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION TextBox2.Text = "VIERNES"
Case 6
TextBox2.Text = "SABADO" Case 7 TextBox2.Text = "DOMINGO"
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Form3.Show() Me.Hide()
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Select Case ComboBox1.SelectedIndex Case 0 TextBox1.Text = 1 Case 1 TextBox1.Text = 2 Case 2 TextBox1.Text = 3 Case 3 TextBox1.Text = 4 Case 4 TextBox1.Text = 5 Case 5
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 6 TextBox1.Text = 7
End Select
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Form4.Show() Me.Hide()
End Sub
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Dim A As Integer = 0
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If A = 7 Then A = 0 Else A = A + 1
Select Case A
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 1 Label1.Visible = True Label3.Visible = False
Label4.Visible = False Label5.Visible = False Label6.Visible = False
Label2.Visible = False Label7.Visible = False Case 2
Label1.Visible = False Label3.Visible = False Label4.Visible = False
Label5.Visible = False Label6.Visible = False Label2.Visible = True
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 3 Label1.Visible = False Label3.Visible = True
Label4.Visible = False Label5.Visible = False Label6.Visible = False
Label2.Visible = False Label7.Visible = False Case 4
Label1.Visible = False Label3.Visible = False Label4.Visible = True
Label5.Visible = False Label6.Visible = False Label2.Visible = False
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 5 Label1.Visible = False Label3.Visible = False
Label4.Visible = False Label5.Visible = True Label6.Visible = False
Label2.Visible = False Label7.Visible = False Case 6
Label1.Visible = False Label3.Visible = False Label4.Visible = False
Label5.Visible = False Label6.Visible = True Label2.Visible = False
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 7 Label1.Visible = False Label3.Visible = False
Label4.Visible = False Label5.Visible = False Label6.Visible = False
Label2.Visible = False Label7.Visible = True End Select
End If End Sub
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Dim COUNT As Integer = 0 Public Sub ANIMAR() If COUNT = 3 Then
COUNT = 0 Else COUNT = COUNT + 1
Select Case COUNT Case 1 Form1.PictureBox1.Visible = True
Form1.PictureBox2.Visible = False Form1.PictureBox3.Visible = False Form2.PictureBox1.Visible = True
Form2.PictureBox2.Visible = False Form2.PictureBox3.Visible = False
PR O G R A M A S :
Ejercicio select case validaci贸n de fecha y 3 mas
PROGRAMACION Case 2
Form1.PictureBox1.Visible = False Form1.PictureBox2.Visible = True
Form1.PictureBox3.Visible = False Form2.PictureBox1.Visible = False Form2.PictureBox2.Visible = True Form2.PictureBox3.Visible = False Case 3 Form1.PictureBox1.Visible = False Form1.PictureBox2.Visible = False Form1.PictureBox3.Visible = True Form2.PictureBox1.Visible = False Form2.PictureBox2.Visible = False Form2.PictureBox3.Visible = True End Select End If End Sub
PR O G R A M A S :
Manipular caracteres con MID
PROGRAMACION
PR O G R A M A S :
Manipular caracteres con LED
PROGRAMACION
PR O G R A M A S :
Manipular caracteres con LED
PROGRAMACION
PR O G R A M A S :
Manipular caracteres con RIGHT
PROGRAMACION
PR O G R A M A S :
Manipular caracteres con SPACE
PROGRAMACION
PR O G R A M A S :
Manipular caracteres con TRIM
PROGRAMACION
PR O G R A M A S :
Convertir Caracteres
PROGRAMACION
PR O G R A M A S :
Ejercicio de agenda system io
PROGRAMACION
PR O G R A M A S :
Ejercicio fibonacci
PROGRAMACION Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N, f1, f2, s As Integer N = Val(TextBox1.Text) f1 = 0 f2 = 1 For I = 1 To N Step 1 f1 = f2 f2 = s TextBox2.Text = TextBox2.Text & " " & s ListBox1.Items.Add(TextBox2.Text) s = f1 + f2 Next End Sub
PR O G R A M A S :
Ejercicio fibonacci
PROGRAMACION Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N, primo As Double N = Val(TextBox1.Text) For i = 1 To N Step 1 If N Mod i = 0 Then primo += 1 End If Next If primo = 2 Then MsgBox(N & " es Primo") TextBox1.Text = "" TextBox1.Focus()
PR O G R A M A S :
Ejercicio fibonacci
PROGRAMACION Else MsgBox(N & " No es Primo") TextBox1.Text = ""
TextBox1.Focus() End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub
End Class
PR O G R A M A S :
Ejercicio simulardor web
PROGRAMACION Public Class Navegador
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.GoBack() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click WebBrowser1.Refresh() End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click WebBrowser1.GoForward() End Sub
PR O G R A M A S :
Ejercicio simulardor web
PROGRAMACION Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click WebBrowser1.Navigate(TextBox1.Text) End Sub End Class
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click WebBrowser1.Navigate(TextBox1.Text) End Sub End Class
PR O G R A M A S :
Ejercicio cara feliz
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num1, num2 As Integer num1 = Int((Rnd()) * 10) num2 = Int((Rnd()) * 10) TextBox1.Text = num1 TextBox2.Text = num2 PictureBox1.Image = Nothing TextBox3.Text = "" TextBox3.Focus() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Val(TextBox3.Text) = Val(TextBox1.Text) + Val(TextBox2.Text) Then
PR O G R A M A S :
Ejercicio cara feliz
PROGRAMACION Else PictureBox1.Image = triste.Image
End If End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click End End Sub End Class
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click feliz1.Visible = True End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click feliz2.Visible = True End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click triste1.Visible = True End Sub
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click triste2.Visible = True End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click rosa1.Visible = True End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click rosa2.Visible = True End Sub
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If feliz1.Visible = True And feliz2.Visible = True Then feliz1.Visible = True Else feliz1.Visible = False
End If End Sub
Private Sub Timer8_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer8.Tick If feliz2.Visible = True And feliz1.Visible = True Then feliz2.Visible = True Else feliz2.Visible = False
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Else feliz2.Visible = False End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click love1.Visible = True End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click love2.Visible = True End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION If rosa1.Visible = True And rosa2.Visible = True Then rosa1.Visible = True Else
rosa1.Visible = False End If End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick If rosa2.Visible = True And rosa1.Visible = True Then rosa2.Visible = True Else rosa2.Visible = False End If End Sub
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick If triste1.Visible = True And triste2.Visible = True Then triste1.Visible = True Else triste1.Visible = False End If End Sub
Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick If triste2.Visible = True And feliz1.Visible = True Then triste2.Visible = True Else triste2.Visible = False End If
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick If love1.Visible = True And love2.Visible = True Then love1.Visible = True Else love1.Visible = False End If End Sub
Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick If love2.Visible = True And love1.Visible = True Then love2.Visible = True Else love2.Visible = False End If
PR O G R A M A S :
Ejercicios con imรกgenes
PROGRAMACION End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click feliz1.Visible = False feliz2.Visible = False triste1.Visible = False triste2.Visible = False rosa1.Visible = False rosa2.Visible = False love1.Visible = False love2.Visible = False End Sub End Class
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Utilizando un M贸dulo
PROGRAMACION
PR O G R A M A S :
Operadores Aritmeticos
PROGRAMACION
PR O G R A M A S :
Ejercicio de texto vocales
PROGRAMACION Public contador As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click contador = 0 For i = 1 To Len(TextBox1.Text) If Mid(TextBox1.Text, i, 1) = "a" Or Mid(TextBox1.Text, i, 1) = "A" Then contador = contador + 1 End If Next TextBox2.Text = contador End Sub
PR O G R A M A S :
Ejercicio de texto vocales
PROGRAMACION Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click contador = 0 For i = 1 To Len(TextBox1.Text) If Mid(TextBox1.Text, i, 1) = "e" Or Mid(TextBox1.Text, i, 1) = "E" Then contador = contador + 1 End If Next TextBox3.Text = contador End Su Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
contador = 0 "
PR O G R A M A S :
Ejercicio de texto vocales
PROGRAMACION If Mid(TextBox1.Text, i, 1) = "i" Or Mid(TextBox1.Text, i, 1) = "I" Then contador = contador + 1 End If Next TextBox4.Text = contador End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click contador = 0 For i = 1 To Len(TextBox1.Text) If Mid(TextBox1.Text, i, 1) = "o" Or Mid(TextBox1.Text, i, 1) = "O" Then
contador = contador + 1 End If Next
PR O G R A M A S :
Ejercicio de texto vocales
PROGRAMACION TextBox5.Text = contador End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click contador = 0 For i = 1 To Len(TextBox1.Text) If Mid(TextBox1.Text, i, 1) = "u" Or Mid(TextBox1.Text, i, 1) = "U" Then contador = contador + 1 End If Next TextBox6.Text = contador End Sub
PR O G R A M A S :
Ejercicio de texto vocales
PROGRAMACION Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click End End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox1.Focus() End Sub
PR O G R A M A S :
Ejercicio numero par
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a As Integer Dim par, impar As Integer For I = 1 To 5 Step 1 a = InputBox("Ingrese el número: ") If a Mod 2 = 0 Then par = par + 1 Else impar = impar + 1 End If Next MsgBox(" LOS NÚMEROS SON:" & Chr(13) & Chr(13) & "Números Pares= " & par & Chr(13) & "Números Impares= " & impar & Chr(13) & Chr(13) & " Click en Aceptar para continuar") End Sub
PR O G R A M A S :
Ejercicio ejercicos con if cartas
PROGRAMACION Public N, N1, N2, N3, N4, N5, N6 As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click N = N1 + N2 + N3 + N4 + N5 + N6 Label1.Text = N End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then N1 = 8 Else N1 = 0 End If End Sub
PR O G R A M A S :
Ejercicio ejercicos con if cartas
PROGRAMACION Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged If CheckBox2.Checked = True Then N2 = 4 Else N2 = 0 End If End Sub Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged If CheckBox3.Checked = True Then N3 = 32 Else N3 = 0 End If End Sub
PR O G R A M A S :
Ejercicio ejercicos con if cartas
PROGRAMACION Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged If CheckBox4.Checked = True Then N4 = 1 Else N4 = 0 End If End Sub Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged If CheckBox5.Checked = True Then N5 = 16 Else N5 = 0 End If End Sub
PR O G R A M A S :
Ejercicio ejercicos con if cartas
PROGRAMACION Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox6.CheckedChanged If CheckBox6.Checked = True Then N6 = 2 Else N6 = 0 End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub
PR O G R A M A S :
Ejercicio ejercicos con if cartas
PROGRAMACION Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click CheckBox1.Checked = False CheckBox2.Checked = False CheckBox3.Checked = False CheckBox4.Checked = False CheckBox5.Checked = False CheckBox6.Checked = False Label1.Text = "" End Sub
PR O G R A M A S :
Usuario y Contraseña
PROGRAMACION Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Usuario As String Dim contraseña As String Usuario = "Nombre" contraseña = "123" If TextBox1.Text = Usuario And TextBox2.Text = contraseña Then Timer1.Start() Else MsgBox("El nombre de usuario o contraseña es incorrecto.") TextBox1.Text = "" TextBox2.Text = "" End If End Sub
PR O G R A M A S :
Ejercicio con if elseif endif
PROGRAMACION Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N1 As Double N1 = TextBox1.Text If N1 = 0 Then MsgBox("Ingresaste 0, prueba un nuevo número") TextBox1.Text = "" TextBox1.Focus() ElseIf N1 > 0 Then TextBox2.Text = "POSITIVO" Else TextBox2.Text = "NEGATIVO" End If End Sub
PR O G R A M A S :
Ejercicio con if elseif endif
PROGRAMACION Dim public s, sf, a, au As Double Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click a = TextBox2.Text If a >= 10 Then au = s * 0.1 ElseIf a > 5 Then au = s * 0.07 ElseIf a > 3 Then
au = s * 0.05 Else : au = s * 0.03 End If TextBox5.Text = au sf = s + au TextBox3.Text = sf End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load s = 40000 / 12
TextBox4.Text = s End Sub
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A(5) As Integer Dim N As Integer For I = 0 To 4 N = InputBox("Ingrese vector: " & I + 1) ListBox1.Items.Add(N) Next End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged End Sub End Class
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim TEXT As TextBox() = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5} For I = 0 To 4 TEXT(I).Text = InputBox("Ingrese vector:" & I) Next End Sub End Class
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N As Integer Dim N1 As Integer N = TextBox1.Text For I = 1 To N N1 = InputBox("Ingrese vector: " & I) ListBox1.Items.Add(N1) Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim A As Integer Dim B As Integer Dim C As Integer Dim I As Integer For I = 1 To Val(ListBox1) Step 1 'A = Val(Mid(ListBox1, I, 1)) If A Mod 2 = 0 Then B = B + AE lse C = C + A End If TextBox2.Text = B TextBox3.Text = C Next
End Sub End Class
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A(4) As Integer For I = 1 To 4 A(I) = I * 5 ListBox1.Items.Add(A(I)) Next ReDim Preserve A(7) For I = 4 To 7 A(I) = I * 10 Next For I = 1 To 7 ListBox2.Items.Add(A(I)) Next End Sub
End Sub End Class
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A(4) As Integer For I = 1 To 4 A(I) = InputBox("Ingrese vector: " & I) ListBox1.Items.Add(A(I)) Next ReDim Preserve A(7) For I = 4 To 7 A(I) = InputBox("Ingrese vector: " & I) Next For I = 1 To 7 ListBox2.Items.Add(A(I)) Next End Sub
End Class
PR O G R A M A S :
Ejercicos de vectores 4
PROGRAMACION Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N1, N2, N3 As Integer N1 = InputBox("Ingrese cuántos vectores") Dim VEC(N1) As Integer For I = 1 To N1 VEC(I) = InputBox("Ingrese los vectores") ListBox1.Items.Add(VEC(I)) Next N2 = InputBox("Ingrese redimensión del vector") N3 = N1 + N2 ReDim Preserve VEC(N3) For I = N1 + 1 To N3 VEC(I) = InputBox("Números de vectores a redimensionar") Next For I = 1 To N3 ListBox2.Items.Add(VEC(I)) Next End Sub
PR O G R A M A S :
Matrices
PROGRAMACION Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mat1(3, 3) As Integer For I = 1 To 3 For J = 1 To 3 mat1(I, J) = InputBox("Ingrese los valores de la matriz") ListBox1.Items.Add(mat1(I, J)) Next Next End Sub End Class
PR O G R A M A S :
Matrices
PROGRAMACION Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mat1(2, 3) As Integer For I = 1 To 2 For J = 1 To 3 mat1(I, J) = InputBox("Ingrese los valores de la matriz") ListBox1.Items.Add(mat1(I, J)) Next Next Dim mat2(3, 2) As Integer For K = 1 To 3 For L = 1 To 2 mat2(K, L) = InputBox("Ingrese los valores de la matriz") ListBox2.Items.Add(mat2(K, L)) Next Next End Sub
End Sub End Class
PR O G R A M A S :
Matrices
PROGRAMACION Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mat1(2, 3) As Integer For I = 1 To 2 For J = 1 To 3 mat1(I, J) = InputBox("Ingrese los valores de la matriz") ListBox1.Items.Add(mat1(I, J)) Next Next Dim mat2(3, 2) As Integer For K = 1 To 3 For L = 1 To 2 mat2(K, L) = InputBox("Ingrese los valores de la matriz") ListBox2.Items.Add(mat2(K, L)) Next Next Dim mat3(2, 2) As Integer Dim ACUM As Integer For M = 1 To 2 For N = 1 To 2 For P = 1 To 3 ACUM = mat1(M, P) * mat2(P, N) + ACUM Next mat3(M, N) = ACUM ListBox3.Items.Add(mat3(M, N)) ACUM = 0 Next Next
End Sub
PR O G R A M A S :
Suma Y Resta de Matrices
PROGRAMACION
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim F1 As Integer Dim C1 As Integer Dim F2 As Integer Dim C2 As Integer F1 = InputBox("Ingrese el número de filas de la primera matriz") C1 = InputBox("Ingrese el número de columnas de la primera matriz") F2 = InputBox("Ingrese el número de filas de la segunda matriz") C2 = InputBox("Ingrese el número de columnas de la segunda matriz") If C1 = C2 And F1 = F2 Then Dim mat1(F1, C1) As Integer For I = 1 To F1 For J = 1 To C1 mat1(I, J) = InputBox("Ingrese los valores de la matriz") ListBox1.Items.Add(mat1(I, J)) Next Next Dim mat2(F2, C2) As Integer For K = 1 To F2 For L = 1 To C2 mat2(K, L) = InputBox("Ingrese los valores de la matriz") ListBox2.Items.Add(mat2(K, L)) Next Next Dim mat3(F1, F2) As Integer Dim ACUM As Integer For M = 1 To F1 For N = 1 To F2 For P = 1 To C2 ACUM = mat1(M, N) + mat2(M, N) Next
PR O G R A M A S :
Suma Y Resta de Matrices
PROGRAMACION
mat3(M, N) = ACUM ListBox3.Items.Add(mat3(M, N)) ACUM = 0 Next Next Else MsgBox("ERROR") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim F1 As Integer Dim C1 As Integer Dim F2 As Integer Dim C2 As Integer F1 = InputBox("Ingrese el número de filas de la primera matriz") C1 = InputBox("Ingrese el número de columnas de la primera matriz") F2 = InputBox("Ingrese el número de filas de la segunda matriz") C2 = InputBox("Ingrese el número de columnas de la segunda matriz") If C1 = C2 And F1 = F2 Then Dim mat1(F1, C1) As Integer For I = 1 To F1 For J = 1 To C1 mat1(I, J) = InputBox("Ingrese los valores de la matriz") ListBox1.Items.Add(mat1(I, J)) Next Next Dim mat2(F2, C2) As Integer For K = 1 To F2 For L = 1 To C2 mat2(K, L) = InputBox("Ingrese los valores de la matriz") ListBox2.Items.Add(mat2(K, L))
PR O G R A M A S :
Suma Y Resta de Matrices
PROGRAMACION
Dim mat2(F2, C2) As Integer For K = 1 To F2 For L = 1 To C2 mat2(K, L) = InputBox("Ingrese los valores de la matriz") ListBox2.Items.Add(mat2(K, L)) Next Next Dim mat3(F1, F2) As Integer Dim ACUM As Integer For M = 1 To F1 For N = 1 To F2 For P = 1 To C2 ACUM = mat1(M, N) - mat2(M, N) Next mat3(M, N) = ACUM ListBox3.Items.Add(mat3(M, N)) ACUM = 0 Next Next Else MsgBox("ERROR") End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ListBox1.Items.Clear() ListBox2.Items.Clear() ListBox3.Items.Clear() End Sub End Class Next Next
PR O G R A M A S :
Suma Y Resta de Vectores
PROGRAMACION Public Class Form2 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ListBox1.Items.Clear() ListBox2.Items.Clear() ListBox3.Items.Clear() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim C1 As Integer Dim C2 As Integer C1 = InputBox("Ingrese el número de filas del primer vector") C2 = InputBox("Ingrese el número de filas del segundo vector") If C1 = C2 Then Dim mat1(C1) As Integer For I = 1 To C1 mat1(I) = InputBox("Ingrese los valores de los vectores") ListBox1.Items.Add(mat1(I)) Next Dim mat2(C2) As Integer For K = 1 To C2 mat2(K) = InputBox("Ingrese los valores de los vectores") ListBox2.Items.Add(mat2(K)) Next
PR O G R A M A S :
Suma Y Resta de Vectores
PROGRAMACION Dim mat3(C1) As Integer Dim ACUM As Integer For M = 1 To C1 ACUM = mat1(M) + mat2(M) mat3(M) = ACUM ListBox3.Items.Add(mat3(M)) ACUM = 0 Next Else MsgBox("ERROR") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim C1 As Integer Dim C2 As Integer C1 = InputBox("Ingrese el número de filas del primer vector") C2 = InputBox("Ingrese el número de filas del segundo vector")
PR O G R A M A S :
Suma Y Resta de Vectores
PROGRAMACION If C1 = C2 Then Dim mat1(C1) As Integer For I = 1 To C1 mat1(I) = InputBox("Ingrese los valores del vector") ListBox1.Items.Add(mat1(I)) Next Dim mat2(C2) As Integer For K = 1 To C2 mat2(K) = InputBox("Ingrese los valores del vector") ListBox2.Items.Add(mat2(K)) Next Dim mat3(C1) As Integer Dim ACUM As Integer For M = 1 To C1 ACUM = mat1(M) - mat2(M) mat3(M) = ACUM ListBox3.Items.Add(mat3(M)) ACUM = 0 Next Else MsgBox("ERROR") End If End Sub End Class