UNIVERSIDAD CENTRAL DEL ECUADOR PROGRAMACIÓN IV
EJERCICIOS VISUAL STUDIO 2010 BYRON GUACHO CUARTO SEMESTRE
1
2
Ejercicios Visual Studio 2010
1
Enlace de formularios
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
System.Object, ByVal e As System.EventArgs)
Ejercicios Visual Studio 2010
Public Class Form1 Private Sub Button1_Click(ByVal sender As Handles Button1.Click N3.Text = Val(N1.Text) + Val(N2.Text) End Sub Private Sub Button2_Click(ByVal sender As Handles Button2.Click N3.Text = Val(N1.Text) - Val(N2.Text) End Sub Private Sub Button3_Click(ByVal sender As Handles Button3.Click N3.Text = Val(N1.Text) * Val(N2.Text) End Sub Private Sub Button4_Click(ByVal sender As Handles Button4.Click N3.Text = Val(N1.Text) / Val(N2.Text) End Sub Private Sub Button5_Click(ByVal sender As Handles Button5.Click N3.Text = Val(N1.Text) \ Val(N2.Text) End Sub Private Sub Button6_Click(ByVal sender As Handles Button6.Click N3.Text = Val(N1.Text) ^ Val(N2.Text) End Sub Private Sub Button7_Click(ByVal sender As Handles Button7.Click N3.Text = Val(N1.Text) Mod Val(N2.Text) End Sub Private Sub Button10_Click(ByVal sender As Handles Button10.Click N1.Text = "" N2.Text = "" N3.Text = "" N1.Focus() End Sub Private Sub Button8_Click(ByVal sender As Handles Button8.Click Me.Close() End Sub Private Sub Button9_Click(ByVal sender As Handles Button9.Click Me.Hide() Form2.show() End Sub End Class
3
Public Class Form2 Private Sub salario_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles salario.Click Dim SB, HT, PPH, D, SN As Double HT = Val(HORAST.Text) PPH = Val(PAGOH.Text) SB = HT * PPH D = SB * 0.2 SN = SB - D SALARION.Text = SN End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click NOMBREA.Text = "" HORAST.Text = "" PAGOH.Text = "" SALARION.Text = "" End Sub
Ejercicios Visual Studio 2010
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Form1.Close()
4
End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Form3.Show() Me.Hide() End Sub End Class
Public Class Form3 As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
Ejercicios Visual Studio 2010
Private Sub salario_Click(ByVal sender Handles salario.Click Dim C, V, VT, I, T C = Val(CANT.Text) V = Val(VUNI.Text) VT = C * V I = VT * 0.12 T = VT + I ListBox1.Items.Add(PROD.Text) VTOTAL.Text = VT IVA.Text = I TOTAL.Text = T End Sub Private Sub Button10_Click(ByVal sender Handles Button10.Click ListBox1.Items.Clear() VTOTAL.Text = "" IVA.Text = "" TOTAL.Text = "" CANT.Text = "" VUNI.Text = "" PROD.Text = "" PROD.Focus() End Sub Private Sub Button8_Click(ByVal sender Handles Button8.Click Form1.Close() End Sub Private Sub Button9_Click(ByVal sender Handles Button9.Click fORM4.SHOW() Me.Hide() End Sub End Class
5
Ejercicios Visual Studio 2010 6
Public Class Form4 Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove RESP.Text = "MONITOR" End Sub Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove RESP.Text = "TECLADO" End Sub Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click End Sub Private Sub PictureBox3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseMove RESP.Text = "RATĂ“N" End Sub Private Sub PictureBox4_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseMove RESP.Text = "CPU" End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click RESP.Text = "" End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Form1.Close() End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Form5.Show() Me.Hide() End Sub End Class
Public Class Form5 Private Sub Button1_Click(ByVal sender Handles Button1.Click TextBox1.ForeColor = Color.Red End Sub Private Sub Button2_Click(ByVal sender Handles Button2.Click Me.BackColor = Color.Black End Sub Private Sub Button10_Click(ByVal sender Handles Button10.Click Me.BackColor = Color.White TextBox1.ForeColor = Color.Black TextBox1.Text = "" TextBox1.Focus() End Sub Private Sub Button8_Click(ByVal sender Handles Button8.Click Form1.Close() End Sub
As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
As System.Object, ByVal e As System.EventArgs)
Ejercicios Visual Studio 2010
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click Form1.Show() Me.Hide() End Sub End Class
7
2 Ejercicios MsgBox
Ejercicios Visual Studio 2010
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim v, c As Integer For i = 1 To Val(TextBox1.Text) Step 1 v = Val(TextBox1.Text) Mod i If v = 0 Then c = c + 1 End If Next If c = 2 Then MsgBox(Val(TextBox1.Text) & " ES PRIMO" & Chr(13) & Chr(13) & "Click en Aceptar para continuar", MsgBoxStyle.Information, "Validaci贸n") Else MsgBox(Val(TextBox1.Text) & " NO ES PRIMO" & Chr(13) & Chr(13) & "Click en Aceptar para continuar", MsgBoxStyle.Information, "Validaci贸n") End If End Sub End Class
8
3 Ejercicios Inputbox
Public Class Form1 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 End Class
Ejercicios Visual Studio 2010 9
4 Ejercicios do while tablas de multiplicar
Ejercicios Visual Studio 2010
Public Class Form2
10
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ComboBox1.Items.Clear() ComboBox2.Items.Clear() ComboBox3.Items.Clear() ComboBox4.Items.Clear() ComboBox5.Items.Clear() ComboBox6.Items.Clear() ComboBox7.Items.Clear() ComboBox8.Items.Clear() ComboBox9.Items.Clear() ComboBox10.Items.Clear() ComboBox11.Items.Clear() ComboBox12.Items.Clear() Dim t As Integer Dim n As Integer = 0 Do While n <= 9 n += 1 t = n * 1 ComboBox1.Items.Add("1 * " & n.ToString & " = " & t.ToString) Loop n = 0 Do While n <= 9 n += 1 t = n * 2 ComboBox2.Items.Add("2 * " & n.ToString & " = " & t.ToString) Loop n = 0 Do While n <= 9 n += 1 t = n * 3 ComboBox3.Items.Add("3 * " & n.ToString & " = " & t.ToString) Loop n = 0 Do While n <= 9 n += 1 t = n * 4 ComboBox4.Items.Add("4 * " & n.ToString & " = " & t.ToString) Loop n = 0 Do While n <= 9 n += 1 t = n * 5 ComboBox5.Items.Add("5 * " & n.ToString & " = " & t.ToString) Loop n = 0
Do While n <= 9 n += 1 t = n * 6 ComboBox6.Items.Add("6 * Loop n = 0 Do While n <= 9 n += 1 t = n * 7 ComboBox7.Items.Add("7 * Loop n = 0 Do While n <= 9 n += 1 t = n * 8 ComboBox8.Items.Add("8 * Loop n = 0 Do While n <= 9 n += 1 t = n * 9 ComboBox9.Items.Add("9 * Loop n = 0 Do While n <= 9 n += 1 t = n * 10 ComboBox10.Items.Add("10 Loop n = 0 Do While n <= 9 n += 1 t = n * 11 ComboBox11.Items.Add("11 Loop n = 0 Do While n <= 9 n += 1 t = n * 12 ComboBox12.Items.Add("12 Loop End Sub
" & n.ToString & " = " & t.ToString)
" & n.ToString & " = " & t.ToString)
" & n.ToString & " = " & t.ToString)
" & n.ToString & " = " & t.ToString)
* " & n.ToString & " = " & t.ToString)
* " & n.ToString & " = " & t.ToString)
* " & n.ToString & " = " & t.ToString)
Ejercicios Visual Studio 2010
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click ComboBox1.Items.Clear() ComboBox2.Items.Clear() ComboBox3.Items.Clear() ComboBox4.Items.Clear() ComboBox5.Items.Clear() ComboBox6.Items.Clear() ComboBox7.Items.Clear() ComboBox8.Items.Clear() ComboBox9.Items.Clear() ComboBox10.Items.Clear() ComboBox11.Items.Clear() ComboBox12.Items.Clear() Dim t As Integer Dim n As Integer = 1 Do While n <= 10 t = n * 1 ComboBox1.Items.Add("1 * " & n.ToString & " = " & t.ToString) t = n * 2 ComboBox2.Items.Add("2 * " & n.ToString & " = " & t.ToString) t = n * 3
11
ComboBox3.Items.Add("3 * t = n * 4 ComboBox4.Items.Add("4 * t = n * 5 ComboBox5.Items.Add("5 * t = n * 6 ComboBox6.Items.Add("6 * t = n * 7 ComboBox7.Items.Add("7 * t = n * 8 ComboBox8.Items.Add("8 * t = n * 9 ComboBox9.Items.Add("9 * t = n * 10 ComboBox10.Items.Add("10 t = n * 11 ComboBox11.Items.Add("11 t = n * 12 ComboBox12.Items.Add("12 n += 1
" & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) " & n.ToString & " = " & t.ToString) * " & n.ToString & " = " & t.ToString) * " & n.ToString & " = " & t.ToString) * " & n.ToString & " = " & t.ToString)
Loop End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub ComboBox12_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox12.SelectedIndexChanged
Ejercicios Visual Studio 2010
End Sub End Class
12
5 Ejercicio Funciones y procedimientos
Ejercicios Visual Studio 2010
'Funciones son procesos matemรกticos que se utilizan las variables 'Procedmientos modifican las caracteristicas de los objetos Public Class Form1 Public Function suma() As Integer Return Val(TextBox1.Text) + Val(TextBox2.Text) End Function Public Sub limpiar() TextBox1.Text = "" TextBox2.Text = "" Label1.Text = "" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Label1.Text = suma() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click limpiar() End Sub End Class
13
6 Ejercicio Select Case
Ejercicios Visual Studio 2010
Public Class Form2
14
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a As Integer a = TextBox1.Text If a <= 0 Or a >= 8 Then MsgBox("INGRESE OTRO NUMERO DE 1 A 7") TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() Else Select Case a Case 1 TextBox2.Text = "LUNES" Case 2 TextBox2.Text = "MARTES" Case 3 TextBox2.Text = "MIÉRCOLES" Case 4 TextBox2.Text = "JUEVES" Case 5 TextBox2.Text = "VIERNES" Case 6 TextBox2.Text = "SÁBADO" Case 7 TextBox2.Text = "DOMINGO" End Select End If End Sub End Class
7
Ejercicio cadena de caracteres
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim texto1, texto2 As String texto1 = TextBox1.Text texto2 = TextBox2.Text TextBox3.Text = texto1 + texto2 End Sub End Class
Ejercicios Visual Studio 2010 15
8 Ejercicio simulador web
Public Class Form1 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click WebBrowser1.Navigate(TextBox1.Text)
Ejercicios Visual Studio 2010
End Sub
16
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click WebBrowser1.Refresh() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click WebBrowser1.GoBack() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.GoForward() End Sub End Class
9
Ejercicio de agenda system io
Imports System Imports System.IO Imports System.Text Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim path As String = "C:\Users\lab_infor_25\Desktop\Datos del registro.txt" If File.Exists(path) = False Then Dim datos As StreamWriter = File.CreateText(path) datos.WriteLine("Nombre: " + TextBox1.Text) datos.WriteLine("Apellido: " + TextBox2.Text) datos.WriteLine("Tel茅fono: " + TextBox3.Text) datos.WriteLine("Direcci贸n: " + TextBox4.Text) datos.WriteLine("Estado civil: " + ComboBox1.SelectedItem) datos.Close() Else MsgBox("Desea reemplazar el archivo existente", MsgBoxStyle.YesNoCancel) 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
Ejercicios Visual Studio 2010
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" ComboBox1.Items.Clear() TextBox1.Focus() End Sub
17
10
Ejercicio Fibonacci
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim N As Integer = 0 Dim S As Integer = 1 Dim C As Integer For I = 1 To Val(TextBox1.Text) Step 1 C = N N = C + S S = C ListBox1.Items.Add(S) Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" ListBox1.Items.Clear() End Sub End Class
Ejercicios Visual Studio 2010
11
18
Ejercicio Factorial
Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim I, F As Integer F = 1 For I = 1 To Val(TextBox1.Text) F = F * I Next TextBox2.Text = F End Sub End Class
12
Ejercicio Cara feliz
Public Class Form1 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 PictureBox1.Image = feliz.Image Else PictureBox1.Image = triste.Image End If End Sub
End Class
Ejercicios Visual Studio 2010
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub
19
13
Ejercicio N煤meros primos
Ejercicios Visual Studio 2010
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim v, c As Integer For i = 1 To Val(TextBox1.Text) Step 1 v = Val(TextBox1.Text) Mod i If v = 0 Then c = c + 1 End If Next If c = 2 Then MsgBox(Val(TextBox1.Text) & " ES PRIMO" & Chr(13) & Chr(13) & "Click en Aceptar para continuar", MsgBoxStyle.Information, "Validaci贸n") Else MsgBox(Val(TextBox1.Text) & " NO ES PRIMO" & Chr(13) & Chr(13) & "Click en Aceptar para continuar", MsgBoxStyle.Information, "Validaci贸n") End If End Sub End Class
20
14
Ejercicio C茅dula validaci贸n
Public Class Form1 Public contador As Integer Public u, v, x, y, z, u2, v2, x2, y2, z2, uc, vc, xc, yc, zc, impares As Integer Public o, p, q, r, pares As Integer Public suma, prueba, respuesta, ultimo As Integer Public provincia As String
Ejercicios Visual Studio 2010
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click u = Mid(TextBox1.Text, 1, 1) u2 = u * 2 If u2 >= 9 Then uc = u2 - 9 Else uc = u2 End If v = Mid(TextBox1.Text, 3, 1) v2 = v * 2 If v2 >= 9 Then vc = v2 - 9 Else vc = v2 End If x = Mid(TextBox1.Text, 5, 1) x2 = x * 2 If x2 >= 9 Then xc = x2 - 9 Else xc = x2 End If y = Mid(TextBox1.Text, 7, 1) y2 = y * 2 If y2 >= 9 Then yc = y2 - 9 Else yc = v2 End If z = Mid(TextBox1.Text, 9, 1) z2 = z * 2 If z2 >= 9 Then zc = z2 - 9 Else zc = z2 End If impares = uc + vc + xc + yc + zc 'PARES o = Mid(TextBox1.Text, 2, 1) p = Mid(TextBox1.Text, 4, 1) q = Mid(TextBox1.Text, 6, 1) r = Mid(TextBox1.Text, 8, 1) pares = o + p + q + r suma = pares + impares prueba = (Mid(suma, 1, 1) + 1) * 10
21
Ejercicios Visual Studio 2010 22
respuesta = prueba - suma ultimo = Mid(TextBox1.Text, 10, 1) provincia = Mid(TextBox1.Text, 1, 2) If Val(provincia) > 24 Then MsgBox("Cédula errónea", MsgBoxStyle.Critical) Else If respuesta = ultimo And provincia = "01" Then MsgBox("Cédula validada, Provincia: Azuay",MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "02" Then MsgBox("Cédula validada, Provincia: Bolivar", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "03" Then MsgBox("Cédula validada, Provincia: Cañar", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "04" Then MsgBox("Cédula validada, Provincia: Carchi", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "05" Then MsgBox("Cédula validada, Provincia: Cotopaxi", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "06" Then MsgBox("Cédula validada, Provincia: Chimborazo", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "07" Then MsgBox("Cédula validada, Provincia: El Oro", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "08" Then MsgBox("Cédula validada, Provincia: Esmeraldas", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "09" Then MsgBox("Cédula validada, Provincia: Guayas", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "10" Then MsgBox("Cédula validada, Provincia: Imbabura", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "11" Then MsgBox("Cédula validada, Provincia: Loja", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "12" Then MsgBox("Cédula validada, Provincia: Los Ríos", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "13" Then MsgBox("Cédula validada, Provincia: Manabí", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "14" Then MsgBox("Cédula validada, Provincia: Morona", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "15" Then MsgBox("Cédula validada, Provincia: Napo", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "16" Then MsgBox("Cédula validada, Provincia: Pastaza", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "17" Then MsgBox("Cédula validada, Provincia: Pichincha", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "18" Then MsgBox("Cédula validada, Provincia: Tungurahua", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "19" Then MsgBox("Cédula validada, Provincia: Zamora", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "20" Then MsgBox("Cédula validada, Provincia: Galapagos", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "21" Then MsgBox("Cédula validada, Provincia: Sucumbios", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "22" Then MsgBox("Cédula validada, Provincia: Orellana", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "23" Then MsgBox("Cédula validada, Provincia: Sto. Domingo", MsgBoxStyle.Information) ElseIf respuesta = ultimo And provincia = "24" Then MsgBox("Cédula validada, Provincia: Sta. Elena", MsgBoxStyle.Information) Else MsgBox("Cédula errónea", MsgBoxStyle.Critical) End If End If TextBox1.Text = "" End Sub End Class
15
Ejercicio ingresar numero y sacar pares impares
Ejercicios Visual Studio 2010
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n, im, par, total, d As Integer TextBox2.Text = Len(TextBox1.Text) For i = 1 To Val(TextBox2.Text) Step 1 n = Val(Mid(TextBox1.Text, i, 1)) If n Mod 2 = 0 Then par = par + n Else im = im + n End If total = total + n Next TextBox3.Text = im TextBox4.Text = par TextBox5.Text = total For i = 1 To Val(TextBox1.Text) Step 1 d = Val(TextBox1.Text) Mod i If d = 0 Then ListBox1.Items.Add(i) End If Next Dim p1, p2 As Integer For i = 1 To Val(TextBox2.Text) Step 1 p1 = Val(Mid(TextBox1.Text, i, 1)) If p1 > p2 Then p2 = Val(Mid(TextBox1.Text, i, 1)) p2 = p1 End If TextBox6.Text = p2 Next Dim p3, p4 As Integer p4 = Val(Mid(TextBox1.Text, 1, 1)) For i = 1 To Val(TextBox2.Text) Step 1 p3 = Val(Mid(TextBox1.Text, i, 1)) If p3 < p4 Then p4 = Val(Mid(TextBox1.Text, i, 1)) p4 = p3 End If TextBox7.Text = p4 Next End Sub
23
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim c, n, im, par, total, d As Integer TextBox2.Text = Len(TextBox1.Text) Do While c < Val(TextBox2.Text) c += 1 n = Val(Mid(TextBox1.Text, c, 1)) If n Mod 2 = 0 Then par = par + n Else im = im + n End If total = total + n Loop TextBox3.Text = im TextBox4.Text = par TextBox5.Text = total c = 0 Do While c < Val(TextBox1.Text) c += 1 d = Val(TextBox1.Text) Mod c If d = 0 Then ListBox1.Items.Add(c) End If Loop
Ejercicios Visual Studio 2010
Dim p1, p2 As Integer c = 0 Do While c < Val(TextBox2.Text) c += 1 p1 = Val(Mid(TextBox1.Text, c, 1)) If p1 > p2 Then p2 = Val(Mid(TextBox1.Text, c, 1)) p2 = p1 End If TextBox6.Text = p2 Loop
24
Dim p3, p4 As Integer p4 = Val(Mid(TextBox1.Text, 1, 1)) c = 0 Do While c < Val(TextBox2.Text) c += 1 p3 = Val(Mid(TextBox1.Text, c, 1)) If p3 < p4 Then p4 = Val(Mid(TextBox1.Text, c, 1)) p4 = p3 End If TextBox7.Text = p4 Loop End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim c, n, im, par, total, d As Integer TextBox2.Text = Len(TextBox1.Text) Do c += 1 n = Val(Mid(TextBox1.Text, c, 1)) If n Mod 2 = 0 Then par = par + n Else im = im + n End If total = total + n Loop Until c > Val(TextBox2.Text) TextBox3.Text = im TextBox4.Text = par TextBox5.Text = total c = 0 Do c += 1 d = Val(TextBox1.Text) Mod c If d = 0 Then ListBox1.Items.Add(c) End If Loop Until c > Val(TextBox1.Text) Dim p1, p2 As Integer c = 0 Do c += 1 p1 = Val(Mid(TextBox1.Text, c, 1)) If p1 > p2 Then p2 = Val(Mid(TextBox1.Text, c, 1)) p2 = p1 End If TextBox6.Text = p2 Loop Until c > Val(TextBox2.Text)
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim c, n, im, par, total, d As Integer TextBox2.Text = Len(TextBox1.Text) While c < Val(TextBox2.Text) c += 1 n = Val(Mid(TextBox1.Text, c, 1)) If n Mod 2 = 0 Then par = par + n Else im = im + n End If total = total + n End While
Ejercicios Visual Studio 2010
Dim p3, p4 As Integer p4 = Val(Mid(TextBox1.Text, 1, 1)) c = 0 Do c += 1 p3 = Val(Mid(TextBox1.Text, c, 1)) If p3 < p4 Then p4 = Val(Mid(TextBox1.Text, c, 1)) p4 = p3 End If TextBox7.Text = p4 Loop Until c >= Val(TextBox2.Text) End Sub
25
TextBox3.Text = im TextBox4.Text = par TextBox5.Text = total c = 0 While c < Val(TextBox1.Text) c += 1 d = Val(TextBox1.Text) Mod c If d = 0 Then ListBox1.Items.Add(c) End If End While Dim p1, p2 As Integer c = 0 While c < Val(TextBox2.Text) c += 1 p1 = Val(Mid(TextBox1.Text, c, 1)) If p1 > p2 Then p2 = Val(Mid(TextBox1.Text, c, 1)) p2 = p1 End If TextBox6.Text = p2 End While
Ejercicios Visual Studio 2010
Dim p3, p4 As Integer p4 = Val(Mid(TextBox1.Text, 1, 1)) c = 0 While c < Val(TextBox2.Text) c += 1 p3 = Val(Mid(TextBox1.Text, c, 1)) If p3 < p4 Then p4 = Val(Mid(TextBox1.Text, c, 1)) p4 = p3 End If TextBox7.Text = p4 End While End Sub
26
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 = "" TextBox7.Text = "" ListBox1.Items.Clear() TextBox1.Focus() End Sub End Class
16
Ejercicio MenĂşs
Public Class Form1 Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click End End Sub
Private Sub ProyectoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProyectoToolStripMenuItem.Click Form2.Show() Me.Hide() End Sub End Class
Ejercicios Visual Studio 2010 27
Ejercicios Visual Studio 2010
17
28
Ejercicio Animaci贸n texto
Public Class Form4 Dim C 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 C = 6 Then C = 1 Else C = C + 1 Select Case C Case 1 Label1.Visible = True Label2.Visible = False Label3.Visible = False Label6.Visible = False Label5.Visible = False Label4.Visible = False Case 2 Label1.Visible = False Label2.Visible = True Label3.Visible = False Label6.Visible = False Label5.Visible = False Label4.Visible = False Case 3 Label1.Visible = False Label2.Visible = False Label3.Visible = True Label6.Visible = False Label5.Visible = False Label4.Visible = False Case 4 Label1.Visible = False Label2.Visible = False Label3.Visible = False Label6.Visible = True Label5.Visible = False Label4.Visible = False
Case 5 Label1.Visible Label2.Visible Label3.Visible Label6.Visible Label5.Visible Label4.Visible Case 6 Label1.Visible Label2.Visible Label3.Visible Label6.Visible Label5.Visible Label4.Visible End Select End If End Sub End Class
= = = = = =
False False False False True False
= = = = = =
False False False False False True
Ejercicios Visual Studio 2010 29
18
Ejercicio Contraseña
Public Class Form2
Ejercicios Visual Studio 2010
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
30
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 Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Increment(5) If ProgressBar1.Value = 100 Then Form1.Show() End If End Sub End Class
19
Ejercicio Mid Len
Ejercicios Visual Studio 2010
Public Class Form7 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b, m, d, d1 As Integer a = Mid(TextBox1.Text, 1, 4) m = Mid(TextBox1.Text, 6, 2) d1 = Mid(TextBox1.Text, 9, 2) b = a Mod (4) If a < 1900 Or a > 2014 Then MsgBox("Ingrese otro a単o") TextBox1.Text = "" Else If m <= 0 Or m > 12 Then MsgBox("Ingrese otro mes") TextBox1.Text = "" Else Select Case m Case 1, 3, 5, 7, 8, 10, 12 d = 31 Case 4, 6, 9, 11 d = 30 Case 2 If b = 0 Then d = 29 Else d = 28 End If End Select If d1 > d Then MsgBox("Ingrese otro dia") TextBox1.Text = "" Else MsgBox("Fecha validada") TextBox1.Text = "" End If End If End If End Sub End Class
31
Ejercicios Visual Studio 2010
20
32
Ejercicio de vocales
Public Class Form1 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 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 Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click contador = 0 For i = 1 To Len(TextBox1.Text) 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 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 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 End Class
Ejercicios Visual Studio 2010 33
21
Ejercicio de pares/impares
Public Class Form1 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")
Ejercicios Visual Studio 2010
End Sub End Class
34
22
Ejercicio if cartas
Public Class Form2 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 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
Ejercicios Visual Studio 2010
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
35
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 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
Ejercicios Visual Studio 2010
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
36
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MsgBox("Piensa un nĂşmero del 0 al 60 y marca la o las tarjetas en las cuales se repita") End Sub End Class
23
Ejercicio con if elseif endif
Public Class Form1 Private Sub Button1_Click(ByVal Handles Button1.Click Dim A1, N1, N2 As Double N1 = TextBox3.Text N2 = TextBox4.Text A1 = (N1 + N2) / 2 TextBox1.Text = A1 If (A1 >= 18.5) Then TextBox2.Text = "A" ElseIf (A1 >= 15.5) And (A1 TextBox2.Text = "B" ElseIf (A1 >= 13.5) And (A1 TextBox2.Text = "C" ElseIf (A1 >= 11.5) And (A1 TextBox2.Text = "D" Else TextBox2.Text = "E" End If End Sub End Class
sender As System.Object, ByVal e As System.EventArgs)
<= 17.5) Then <= 14.5) Then <= 12.5) Then
Ejercicios Visual Studio 2010 37
Ejercicios Visual Studio 2010
24
38
Ejercicio Meses del a単o
Public Class Form7 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b, m, d, d1 As Integer a = Mid(TextBox1.Text, 1, 4) m = Mid(TextBox1.Text, 6, 2) d1 = Mid(TextBox1.Text, 9, 2) b = a Mod (4) If a < 1900 Or a > 2014 Then MsgBox("Ingrese otro a単o") TextBox1.Text = "" Else If m <= 0 Or m > 12 Then MsgBox("Ingrese otro mes") TextBox1.Text = "" Else Select Case m Case 1, 3, 5, 7, 8, 10, 12 d = 31 Case 4, 6, 9, 11 d = 30 Case 2 If b = 0 Then d = 29 Else d = 28 End If End Select If d1 > d Then MsgBox("Ingrese otro dia") TextBox1.Text = "" Else MsgBox("Fecha validada") TextBox1.Text = "" End If End If End If End Sub End Class
Public Class Form3 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 End Class
Ejercicios Visual Studio 2010 39
25
Ejercicio Arreglos dinรกmicos
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 = 5 To 7 A(i) = i * 10 Next
Ejercicios Visual Studio 2010
For i = 1 To 7 ListBox2.Items.Add(A(i)) Next End Sub End Class
40
26
Ejercicio Matrices
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MAT(3, 3) As Integer For i = 1 To 3 For j = 1 To 3 MAT(i, j) = InputBox("Ingrese el nĂşmero: ") ListBox1.Items.Add(MAT(i, j)) Next Next End Sub End Class
Ejercicios Visual Studio 2010 41
27
Ejercicio Producto de Matrices
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MAT1(3, 2) As Integer MAT1(3, 2) = InputBox("Ingrese el número: ") ListBox2.Items.Add(MAT1(3, 2))
Ejercicios Visual Studio 2010
Dim MAT(2, 3) As Integer For i = 1 To 2 For j = 1 To 3 MAT(i, j) = InputBox("Ingrese el número" & j & ":") ListBox1.Items.Add(MAT(i, j)) Next Next
42
Dim MAT3(2, 2) As Integer Dim p, q, r, s As Integer p = ((MAT(1, 1) * MAT1(1, 1)) + (MAT(1, ListBox3.Items.Add(p) q = ((MAT(1, 1) * MAT1(1, 2)) + (MAT(1, ListBox3.Items.Add(q) r = ((MAT(2, 1) * MAT1(1, 1)) + (MAT(2, ListBox3.Items.Add(r) s = ((MAT(2, 1) * MAT1(1, 2)) + (MAT(2, ListBox3.Items.Add(s) Dim MAT4(2, 2) As Integer Dim p1 As Integer For i = 1 To 2 For j = 1 To 2 For k = 1 To 3 p1 = MAT(i, k) * MAT1(k, j) MsgBox(p1) Next MAT4(i, j) = p1 ListBox4.Items.Add(MAT4(i, j)) p1 = 0 Next Next End Sub End Class
2) * MAT1(2, 1)) + (MAT(1, 3) * MAT1(3, 1))) 2) * MAT1(2, 2)) + (MAT(1, 3) * MAT1(3, 2))) 2) * MAT1(2, 1)) + (MAT(2, 3) * MAT1(3, 1))) 2) * MAT1(2, 2)) + (MAT(2, 3) * MAT1(3, 2)))
+ p1
28
Ejercicio Vectores
Public Class Form2 Public n, f, par, impar As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Clear() f = InputBox("Ingrese el límite:") - 1 For I = 0 To f n = InputBox("INGRESE VECTOR DE POSICIÓN: " & I + 1) If n Mod 2 = 0 Then par = par + 1 Else impar = impar + 1 End If ListBox1.Items.Add(n) Next End Sub
Ejercicios Visual Studio 2010
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click MsgBox("PARES: " & par) MsgBox("IMPARES: " & impar) End Sub End Class
43
29
Ejercicio Suma de vectores
Public Class Suma_Vectores Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Clear() ListBox2.Items.Clear() ListBox3.Items.Clear() Dim f1, f2, f3 As Integer 'ingrese magnitud vector f1 = InputBox("Ingrese el límite 1º vector") f2 = InputBox("Ingrese el límite 2º vector") f3 = f1 If f1 = f2 Then Dim v1(f1), v2(f2), vs(f1)
Ejercicios Visual Studio 2010
'ingrese vector 1 For i = 1 To f1 v1(i) = InputBox("INGRESE VECTOR DE POSICIÓN: " & i) ListBox1.Items.Add(v1(i)) Next
44
'ingreso vector 2 For i = 1 To f2 v2(i) = InputBox("INGRESE VECTOR DE POSICIÓN: " & i) ListBox2.Items.Add(v2(i)) Next 'suma vectores For i = 1 To f3 vs(i) = Val(v1(i)) + Val(v2(i)) ListBox3.Items.Add(vs(i)) Next Else MsgBox("Vectores desiguales") End If End Sub End Class
30
Ejercicio Determinantes
Public Class Form1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub
Ejercicios Visual Studio 2010
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, TextBox6, TextBox7, TextBox8, TextBox9, TextBox10, TextBox11, TextBox12} '++++MATRIZ DETERMINANTE++++ Dim A(9) As Double Dim I As Double = 0 For j = 0 To 8 I = I + 1 A(I) = (TEXT(j).Text) Next ReDim Preserve A(15) Dim P As Double = 9 For k = 0 To 5 P = P + 1 A(P) = (TEXT(k).Text) Next For l = 1 To 15 ListBox1.Items.Add(A(l)) Next 'CÁLCULOS DETERMINANTE Dim O As Double = 1 Dim fin As Double = 7 Dim F1 As Double For inicio = 3 To 9 Step 3 For x = inicio To fin Step 2 O = A(x) * O ' MsgBox(O1) fin = fin + 1 Next F1 = O + F1 O = 1 Next 'MsgBox(F1) Dim O1 As Double = 1 Dim fin1 As Double = 9 Dim F2 As Double For inicio = 1 To 9 Step 3
45
For x = inicio To fin1 Step 4 O1 = A(x) * O1 'MsgBox(O) fin1 = fin1 + 1 Next F2 = O1 + F2 O1 = 1 Next 'MsgBox(F2) Dim dt As Double dt = F1 - F2 MsgBox("Determinante del sistema: " & dt)
'++++MATRIZX++++ Dim Ax(3) As Double Dim Ix As Double = 0 For j = 9 To 11 Ix = Ix + 1 Ax(Ix) = (TEXT(j).Text) Next ReDim Preserve Ax(9) Dim Px As Double = 3 For k = 3 To 8 Px = Px + 1 Ax(Px) = (TEXT(k).Text) Next
Ejercicios Visual Studio 2010
ReDim Preserve Ax(12) Dim Qx As Double = 9 For j = 9 To 11 Qx = Qx + 1 Ax(Qx) = (TEXT(j).Text) Next
46
ReDim Preserve Ax(15) Dim Rx As Double = 12 For j = 3 To 5 Rx = Rx + 1 Ax(Rx) = (TEXT(j).Text) Next For l = 1 To 15 ListBox2.Items.Add(Ax(l)) Next 'CÁLCULOS X Dim Ox As Double = 1 Dim finx As Double = 7 Dim F1x As Double For inicio = 3 To 9 Step 3 For x = inicio To finx Step 2 Ox = Ax(x) * Ox 'MsgBox(Ox) finx = finx + 1 Next F1x = Ox + F1x Ox = 1 Next 'MsgBox(F1x)
Dim Dim Dim For
O1x As Double = 1 fin1x As Double = 9 F2x As Double inicio = 1 To 9 Step 3 For x = inicio To fin1x Step 4 O1x = Ax(x) * O1x 'MsgBox(O1x) fin1x = fin1x + 1 Next F2x = O1x + F2x O1x = 1
Next 'MsgBox(F2x) Dim dtx As Double dtx = F1x - F2x MsgBox("Determinante en X: " & dtx) '++++MATRIZY++++ Dim Ay(3) As Double Dim Iy As Double = 0 For j = 0 To 2 Iy = Iy + 1 Ay(Iy) = (TEXT(j).Text) Next ReDim Preserve Ay(6) Dim Py As Double = 3 For k = 9 To 11 Py = Py + 1 Ay(Py) = (TEXT(k).Text) Next ReDim Preserve Ay(9) Dim Qy As Double = 6 For j = 6 To 8 Qy = Qy + 1 Ay(Qy) = (TEXT(j).Text) Next
ReDim Preserve Ay(15) Dim Sy As Double = 12 For j = 9 To 11 Sy = Sy + 1 Ay(Sy) = (TEXT(j).Text) Next For l = 1 To 15 ListBox3.Items.Add(Ay(l)) Next
Ejercicios Visual Studio 2010
ReDim Preserve Ay(12) Dim Ry As Double = 9 For j = 0 To 2 Ry = Ry + 1 Ay(Ry) = (TEXT(j).Text) Next
47
'CÁLCULOS Y Dim Oy As Double = 1 Dim finy As Double = 7 Dim F1y As Double For inicio = 3 To 9 Step 3 For x = inicio To finy Step 2 Oy = Ay(x) * Oy 'MsgBox(Oy) finy = finy + 1 Next F1y = Oy + F1y Oy = 1 Next 'MsgBox(F1y) Dim Dim Dim For
O1y As Double = 1 fin1y As Double = 9 F2y As Double inicio = 1 To 9 Step 3 For x = inicio To fin1y Step 4 O1y = Ay(x) * O1y 'MsgBox(O1y) fin1y = fin1y + 1 Next F2y = O1y + F2y O1y = 1
Next 'MsgBox(F2y) Dim dty As Double dty = F1y - F2y MsgBox("Determinante en Y: " & dty)
Ejercicios Visual Studio 2010
'++++MATRIZZ++++ Dim Az(6) As Double Dim Iz As Double = 0 For j = 0 To 5 Iz = Iz + 1 Az(Iz) = (TEXT(j).Text) Next
48
ReDim Preserve Az(9) Dim Pz As Double = 6 For k = 9 To 11 Pz = Pz + 1 Az(Pz) = (TEXT(k).Text) Next ReDim Preserve Az(15) Dim Qz As Double = 9 For j = 0 To 5 Qz = Qz + 1 Az(Qz) = (TEXT(j).Text) Next For l = 1 To 15 ListBox4.Items.Add(Az(l)) Next
'CÁLCULOS Z Dim Oz As Double = 1 Dim finz As Double = 7 Dim F1z As Double For inicio = 3 To 9 Step 3 For x = inicio To finz Step 2 Oz = Az(x) * Oz 'MsgBox(Oz) finz = finz + 1 Next F1z = Oz + F1z Oz = 1 Next ' MsgBox(F1z) Dim Dim Dim For
O1z As Double = 1 fin1z As Double = 9 F2z As Double inicio = 1 To 9 Step 3 For x = inicio To fin1z Step 4 O1z = Az(x) * O1z ' MsgBox(O1z) fin1z = fin1z + 1 Next F2z = O1z + F2z O1z = 1
Next 'MsgBox(F2z) Dim dtz As Double dtz = F1z - F2z MsgBox("Determinante en Z: " & dtz) Dim VX, VY, VZ As Double VX = dtx / dt VY = dty / dt VZ = dtz / dt TextBox15.Text = VX TextBox14.Text = VY TextBox13.Text = VZ End Sub
Ejercicios Visual Studio 2010
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox9.Text = "" TextBox10.Text = "" TextBox11.Text = "" TextBox12.Text = "" TextBox13.Text = "" TextBox14.Text = "" TextBox15.Text = "" ListBox1.Items.Clear() ListBox2.Items.Clear() ListBox3.Items.Clear() ListBox4.Items.Clear() TextBox1.Focus() End Sub
49
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Ejercicios Visual Studio 2010
End Sub End Class
50