Proyecto de programacion iv

Page 1

UNIVERSIDAD CENTRAL DEL ECUADOR FACULTAD DE FILOSOFIA, LETRAS Y CIENCIAS DE LA EDUCACION ESCUELA DE CIENCIAS EXACTAS

PROGRAMACION IV

MCS. VICTOR ZAPATA

EJERCICIOS DE VISUAL STUDIO 2010 (VISUAL STUDIO 2010)

4TO SEMESTRE KARLA FLORES 2014-2014


ENLACE DE FORMULARIOS

PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b, c AsInteger a = TextBox1.Text b = TextBox2.Text c = a + b TextBox3.Text = c EndSub PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Form9.Show() Me.Hide() EndSub


MSGBOX 3 EJERCICIOS 1 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("HOLA COMO ESTAN") End Sub

2 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("Actualizaci贸n terminada", vbOKOnly, "Informaci贸n") End Sub

3 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("驴Quieres seguir?", vbYesNo, "Informaci贸n importante") End Sub


INPUTBOX 3 EJERCICIOS 1 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Val As String Val = InputBox("Cual es tu nombre", "Ejemplo 1.- INPUTBOX") MsgBox("Su nombre es: " & Val) End Sub

2 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Val As String Val = InputBox("Digita tu numero de cuenta", "Ejemplo 2.- INPUTBOX", "ABC123") End Sub


3 EJERCICIO

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim A As Double 'NĂşmeros con muchos decimales A = InputBox("Ingresa el precio del cual quieres obtener el IVA") A = A * 0.15 'Obtenemos el IVA MsgBox("El iva es: " & A) End Sub

EJERCICIOS DO WHILE TABLAS DE MULTIPLICAR


Private Sub Button1_Click(ByVal sender Handles Button1.Click Dim T As Integer Dim N As Integer = 0 Do While T <= 9 N += 1 T = N * 1 ComboBox1.Items.Add("1*" & Loop N = 0 Do While N <= 9 N += 1 T = N * 2 ComboBox2.Items.Add("2*" & Loop N = 0 Do While N <= 9 N += 1 T = N * 3 ComboBox3.Items.Add("3*" & Loop N = 0 Do While N <= 9 N += 1 T = N * 4 ComboBox4.Items.Add("4*" & Loop N = 0 Do While N <= 9 N += 1 T = N * 5 ComboBox5.Items.Add("5*" & 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 End Sub

As System.Object, ByVal e As System.EventArgs)

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 FUNCIONES PROCEDIMIENTOS

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.BackColor = Color.Aquamarine EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Text = "primer formulario" Me.ForeColor = Color.Yellow EndSub PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() EndSub EndClass


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click LABEL1.TEXT = "MI SEGUNDO FORMILARIO" EndSub PrivateSub Button2_MouseMove(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove Me.BackColor = Color.Blue EndSub PrivateSub Button3_MouseDoubleClick(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseDoubleClick Label1.ForeColor = Color.BurlyWood EndSub

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click IMAGEN1.Visible = True EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click IMAGEN1.Visible = False EndSub


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HHH.Click NOMBRE.TEXT = "UMIVERSIDAD CENTRAL" EndSub

EJERCICIO SELECT CASE VALIDACION DE FECHA Y 3 MAS 1 EJERCICIO

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, m, d, d1, bis AsInteger a = Mid(TextBox1.Text, 1, 4) m = Mid(TextBox1.Text, 6, 2) d1 = Mid(TextBox1.Text, 9, 2) bis = 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 SelectCase m Case 1, 3, 5, 7, 8, 10, 12 d = 31 Case 4, 6, 9, 11 d = 31 Case 2 If bis = 0 Then d = 29 Else d = 28 EndIf EndSelect If d1 > d Then MsgBox("Ingrese otro dia") TextBox1.Text = "" Else MsgBox("fecha validada") TextBox1.Text = "" EndIf EndIf EndIf


2 EJERCICIO

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a AsInteger a = TextBox1.Text SelectCase a Case 1 TextBox2.Text = "lunes" Case 2 TextBox2.Text = "martes" Case 3 TextBox2.Text = "miercoles" Case 4 TextBox2.Text = "jueves" Case 5 TextBox2.Text = "viernes" Case 6 TextBox2.Text = "sabado" Case 7 TextBox2.Text = "domingo" EndSelect EndSub


3 EJERCICIO

PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged SelectCase ComboBox1.SelectedIndex Case 0 TextBox1.Text =EJERCICIOS ComboBox1.SelectedItem CON CADENA DE CARACTERES Case 1 TextBox1.Text = ComboBox1.SelectedItem Case 2 TextBox1.Text = ComboBox1.SelectedItem Case 3 TextBox1.Text = ComboBox1.SelectedItem Case 4 TextBox1.Text = ComboBox1.SelectedItem Case 5 TextBox1.Text = ComboBox1.SelectedItem Case 6 TextBox1.Text = ComboBox1.SelectedItem EndSelect EndSub PrivateSub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load ComboBox1.Items.Add("lunes") ComboBox1.Items.Add("martes") ComboBox1.Items.Add("miercoles") ComboBox1.Items.Add("jueves") ComboBox1.Items.Add("viernes") ComboBox1.Items.Add("sabado") ComboBox1.Items.Add("domingo") EndSub


EJERCICIO SIMULARDOR WEB

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.Navigate(TextBox1.Text) 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 Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click WebBrowser1.Refresh() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click WebBrowser1.GoForward() End Sub


EJERCICIO DE AGENDA SYSTEM IO

Imports System Imports System.IO Imports System.Text PublicClassForm1 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim path AsString = "C:\Users\lab_infor_25\Desktop\Datos del registro.txt" IfFile.Exists(path) = FalseThen Dim datos AsStreamWriter = File.CreateText(path) datos.WriteLine("Nombre: " + TextBox1.Text + "Apellido: " + TextBox2.Text + "Tel茅fono: " + TextBox3.Text + "Direcci贸n: " + TextBox4.Text + "Estado civil: " + ComboBox1.SelectedItem) datos.Close() Else MsgBox("Desea reemplazar el archivo existente", MsgBoxStyle.YesNoCancel) EndIf EndSub PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" EndSub EndClass


EJERCICIO FIBONACCI

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, an, nu, si As Integer an = 0 si = 1 TextBox2.Text = an & "" & si For i = 1 To TextBox1.Text Step 1 nu = an + si TextBox2.Text = TextBox2.Text & "" & nu an = si si = nu Next End Sub


EJERCICIO FACTORIAL

PublicClassForm3 Dim I, F AsInteger PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For I = 1 ToVal(TextBox1.Text) F = F * I Next TextBox2.Text = F EndSub

EJERCICIO CARA FELIZ


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num1, num2 AsInteger num1 = Int(Rnd() * 10) num2 = Int(Rnd() * 10) TextBox1.Text = num1 TextBox2.Text = num2 PictureBox3.Image = Nothing TextBox3.Text = "" TextBox3.Focus() EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim r AsInteger r = Val(TextBox1.Text) + Val(TextBox2.Text) If (Val(TextBox3.Text)) = Val(TextBox1.Text) + Val(TextBox2.Text) Then PictureBox3.Image = feliz.Image Else PictureBox3.Image = triste.Image EndIf EndSub PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() EndSub EndClass

EJERCICIO NUMERO PRIMO Dim a As Integer Dim n As Integer n = TextBox1.Text For i As Integer = 1 To n + 1 If (n Mod i = 0) Then a = a + 1 End If Next i If (a = 2) Then MsgBox("No es Primo") Else MsgBox("Si es Primo") End If


EJERCICIO CEDULA VALIDACION

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim provincia, par2, par4, par6, par8, suma, impar1, impar3, impar5, impar7, impar9, ulcelu As Integer Dim sumaim, sumato, extraido, validacion, ulnu As Integer provincia = Mid(TextBox1.Text, 1, 2) TextBox3.Text = provincia If provincia = 4 Then TextBox2.Text = "LA PROVINCIA ES DE CARCHI" ElseIf provincia = 3 Then TextBox2.Text = "LA PROVINCIA ES DE CAÑAR" ElseIf provincia = 2 Then TextBox2.Text = "LA PROVINCIA ES DE BOLIVAR" ElseIf provincia = 1 Then TextBox2.Text = "LA PROVINCIA ES DE AZUAY" ElseIf provincia = 5 Then TextBox2.Text = "LA PROVINCIA ES DE COTOPAXI" ElseIf provincia = 6 Then TextBox2.Text = "LA PROVINCIA ES DE CHIMBORAZO" ElseIf provincia = 7 Then TextBox2.Text = "LA PROVINCIA ES DEL ORO" ElseIf provincia = 8 Then TextBox2.Text = "LA PROVINCIA ES DE ESMERALDAS" ElseIf provincia = 9 Then TextBox2.Text = "LA PROVINCIA ES DEL GUAYAS" ElseIf provincia = 10 Then TextBox2.Text = "LA PROVINCIA ES DE IMBABURA" ElseIf provincia = 11 Then TextBox2.Text = "LA PROVINCIA ES DE LOJA" ElseIf provincia = 12 Then TextBox2.Text = "LA PROVINCIA ES DE LOS RIOS" ElseIf provincia = 13 Then TextBox2.Text = "LA PROVINCIA ES DE MANABI" ElseIf provincia = 14 Then TextBox2.Text = "LA PROVINCIA ES DE MORONA SANTIAGO" ElseIf provincia = 15 Then TextBox2.Text = "LA PROVINCIA ES DE NAPO" ElseIf provincia = 16 Then TextBox2.Text = "LA PROVINCIA ES DE PASTAZA" ElseIf provincia = 17 Then TextBox2.Text = "LA PROVINCIA ES DE PICHINCHA"


ElseIf provincia = 18 Then TextBox2.Text = "LA PROVINCIA ES DE TUNGURAHUA" ElseIf provincia = 19 Then TextBox2.Text = "LA PROVINCIA ES DE ZAMORA CHINCHIPE" ElseIf provincia = 20 Then TextBox2.Text = "LA PROVINCIA ES DE GALAPAGOS" ElseIf provincia = 21 Then TextBox2.Text = "LA PROVINCIA ES DE SUCUMBIOS" ElseIf provincia = 23 Then TextBox2.Text = "LA PROVINCIA ES DE SANTO DOMINGO DE LOS TSACHILAS" ElseIf provincia = 22 Then TextBox2.Text = "LA PROVINCIA ES DE ORELLANA" ElseIf provincia = 24 Then TextBox2.Text = "LA PROVINCIA ES DE SANTA ELENA" End If par2 = Mid(TextBox1.Text, 2, 1) par4 = Mid(TextBox1.Text, 4, 1) par6 = Mid(TextBox1.Text, 6, 1) par8 = Mid(TextBox1.Text, 8, 1) suma = par2 + par4 + par6 + par8 TextBox4.Text = suma impar1 = Mid(TextBox1.Text, 1, 1) * 2 If impar1 > 9 Then impar1 = impar1 - 9 End If impar3 = Mid(TextBox1.Text, 3, 1) * 2 If impar3 > 9 Then impar3 = impar3 - 9 End If impar5 = Mid(TextBox1.Text, 5, 1) * 2 If impar5 > 9 Then impar5 = impar5 - 9 End If impar7 = Mid(TextBox1.Text, 7, 1) * 2 If impar7 > 9 Then impar7 = impar7 - 9 End If impar9 = Mid(TextBox1.Text, 9, 1) * 2 If impar9 > 9 Then impar9 = impar9 - 9 End If sumaim = impar1 + impar3 + impar5 + impar7 + impar9 TextBox5.Text = sumaim sumato = suma + sumaim TextBox6.Text = sumato extraido = Mid(TextBox6.Text, 1, 1) validacion = (extraido + 1) * 10 TextBox7.Text = validacion ulcelu = validacion - sumato TextBox8.Text = ulcelu ulnu = Mid(TextBox1.Text, 10, 1) TextBox9.Text = ulnu If Len(TextBox1.Text) > 10 Then MsgBox("CEDULA INCORRECTA") ElseIf Val(TextBox8.Text) = Val(TextBox9.Text) Then MsgBox("CEDULA CORRECTA") End If


EJERCICIO INGRESAR NUMERO Y SACAR PARES IMPARES PublicClassForm3 Dim N, L, PAR, IMP AsInteger PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click N = InputBox("INGRESE POSICIONES") Dim A(N) AsInteger For I = 0 To N - 1 A(I) = InputBox("INGRESE VECTORES ") ListBox1.Items.Add(A(I)) IfA(I) Mod (2) = 0 Then PAR = PAR + 1 EndIf IMP = IMP + 1 Next EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = PAR TextBox2.Text = IMP EndSub

EJERCICIO BARS


PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick animar() EndSub PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Timer1.Start() EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "1234"And TextBox2.Text = "1234"Then Timer2.Start() Else MsgBox("User o Pass incorrectos") TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() EndIf EndSub PrivateSub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick ProgressBar1.Increment(8) If ProgressBar1.Value = 100 Then Form2.Show() Me.Hide() EndIf EndSub

EJERCICIO MENU DE OPCIONES


PrivateSub CUADRADOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CUADRADOToolStripMenuItem.Click Form2.Show() Form1.Hide() EndSub PrivateSub RECTANGULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RECTANGULOToolStripMenuItem.Click Form3.Show() Form1.Hide() EndSub PrivateSub CIRCULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CIRCULOToolStripMenuItem.Click Form4.Show() Form1.Hide() EndSub PrivateSub TRIANGULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TRIANGULOToolStripMenuItem.Click Form5.Show() Form1.Hide() EndSub PrivateSub ARCHIVOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ARCHIVOToolStripMenuItem.Click EndSub

EJERCICIOS ANIMACION DE TEXTO


PublicClassForm4 Dim cont AsInteger = 0 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End EndSub PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If cont = "5"Then cont = "1" Else : cont = cont + 1 SelectCase cont Case 1 Label2.Visible = True Label3.Visible = False Label4.Visible = False Label5.Visible = False Label6.Visible = False Case 2 Label2.Visible = False Label3.Visible = True Label4.Visible = False Label5.Visible = False Label6.Visible = False Case 3 Label2.Visible = False Label3.Visible = False Label4.Visible = True Label5.Visible = False Label6.Visible = False Case 4 Label2.Visible = False Label3.Visible = False Label4.Visible = False Label5.Visible = True Label6.Visible = False Case 5 Label2.Visible = False Label3.Visible = False Label4.Visible = False Label5.Visible = False Label6.Visible = True EndSelect EndIf EndSub PrivateSub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Timer1.Start() EndSub


EJERCICIO DE CONTRASENA

PublicClassForm1 Dim cons AsInteger = 0 PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ProgressBar1.Increment(5) If ProgressBar1.Value = 100 Then Form2.Show() Else EndIf If cons = "3"Then cons = "1" Else cons = cons + 1 SelectCase cons Case 1 Label1.Visible = True Label5.Visible = False Label6.Visible = False Case 2 Label1.Visible = False Label5.Visible = True Label6.Visible = False Case 3 Label1.Visible = False Label5.Visible = False Label6.Visible = True EndSelect EndIf EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "karla"And TextBox2.Text = "12345"Then Timer1.Start() Else MsgBox("ingrese los datos bien") TextBox1.Text = "" TextBox2.Text = "" EndIf EndSub


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "karla"And TextBox2.Text = "12345"Then Timer1.Start() Else MsgBox("ingrese los datos bien") TextBox1.Text = "" TextBox2.Text = "" EndIf EndSub PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load EndSub PrivateSub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Timer1.Start() EndSub

EJERCICIO DE TEXTO VOCALES

Dim n As Integer Dim ESTRAER As String Dim contador As Integer n = Len(TextBox1.Text) TextBox2.Text = n For I = 1 To n Step 1 ESTRAER = Mid(TextBox1.Text, I, 1) TextBox2.Text = ESTRAER If ESTRAER = "a" Or ESTRAER = "A" Then contador = contador + 1 End If TextBox2.Text = ESTRAER Next


EJERCICIO FUNCION MID LEN

PublicClassForm1 Dim A AsInteger Dim EX AsString Dim CONT AsString = 0 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click A = Len(TextBox1.Text) TextBox2.Text = A For I = 1 To A Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox3.Text = EX If EX = "a"Or EX = "A"Then CONT = CONT + 1 EndIf TextBox4.Text = CONT Next EndSub PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load For I = 1 To A Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox3.Text = EX If EX = "E"Or EX = "e"Then CONT = CONT + 1 EndIf TextBox4.Text = CONT Next EndSub


EJERCICIO NUMERO PAR

Dim I AsInteger PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For I = 2 To 100 Step 2 ListBox1.Items.Add(I) Next EndSub

EJERCICIO CON TIMER


ModuleModule1 SubMain() Dim aDateString, aTimeString AsString Dim aDate, aTime AsDate aDateString = "February 12, 1969" aTimeString = "4:35:47 PM" ' The following line of code sets aDate to a Date value. aDate = CDate(aDateString) ' The following line of code sets aTime to Date value. aTime = CDate(aTimeString) Console.WriteLine(aDateString) Console.WriteLine(aTimeString) Console.WriteLine(aDate) Console.WriteLine(aTime) Console.ReadLine() EndSub EndModule

EJERCICIO CON IF ELSEIF ENDIF


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, par, imp, x, provincia AsInteger IfLen(TextBox1.Text) > 10 Then MsgBox("CEDULA INCORRECTA") Else provincia = Mid(TextBox1.Text, 1, 2) TextBox3.Text = provincia If provincia = 4 Then TextBox2.Text = " PROVINCIA ES CARCHI" ElseIf provincia = 3 Then TextBox2.Text = " PROVINCIA ES CAÑAR" ElseIf provincia = 2 Then TextBox2.Text = " PROVINCIA ES BOLIVAR" ElseIf provincia = 1 Then TextBox2.Text = " PROVINCIA ES AZUAY" ElseIf provincia = 5 Then TextBox2.Text = " PROVINCIA ES COTOPAXI" ElseIf provincia = 6 Then TextBox2.Text = " PROVINCIA ES CHIMBORAZO" ElseIf provincia = 7 Then TextBox2.Text = " PROVINCIA ES EL ORO" ElseIf provincia = 8 Then TextBox2.Text = " PROVINCIA ES ESMERALDAS" ElseIf provincia = 9 Then TextBox2.Text = " PROVINCIA ES GUAYAS" ElseIf provincia = 10 Then TextBox2.Text = " PROVINCIA ES IMBABURA" ElseIf provincia = 11 Then TextBox2.Text = " PROVINCIA ES LOJA" ElseIf provincia = 12 Then TextBox2.Text = " PROVINCIA ES LOS RIOS" ElseIf provincia = 13 Then TextBox2.Text = " PROVINCIA ES MANABI" ElseIf provincia = 14 Then TextBox2.Text = " PROVINCIA ES MORONA SANTIAGO" ElseIf provincia = 15 Then TextBox2.Text = " PROVINCIA ES NAPO" ElseIf provincia = 16 Then TextBox2.Text = " PROVINCIA ES PASTAZA" ElseIf provincia = 17 Then TextBox2.Text = " PROVINCIA ES PICHINCHA" ElseIf provincia = 18 Then TextBox2.Text = " PROVINCIA ES TUNGURAHUA" ElseIf provincia = 19 Then TextBox2.Text = " PROVINCIA ES ZAMORA CHINCHIPE" ElseIf provincia = 20 Then TextBox2.Text = "PROVINCIA ES GALAPAGOS" ElseIf provincia = 21 Then TextBox2.Text = " PROVINCIA ES SUCUMBIOS" ElseIf provincia = 23 Then TextBox2.Text = " PROVINCIA ES SANTO DOMINGO DE LOS TSACHILAS" ElseIf provincia = 22 Then TextBox2.Text = " PROVINCIA ES ORELLANA" ElseIf provincia = 24 Then TextBox2.Text = " PROVINCIA ES SANTA ELENA" EndIf


ElseIf provincia = 12 Then TextBox2.Text = " PROVINCIA ES LOS RIOS" ElseIf provincia = 13 Then TextBox2.Text = " PROVINCIA ES MANABI" ElseIf provincia = 14 Then TextBox2.Text = " PROVINCIA ES MORONA SANTIAGO" ElseIf provincia = 15 Then TextBox2.Text = " PROVINCIA ES NAPO" ElseIf provincia = 16 Then TextBox2.Text = " PROVINCIA ES PASTAZA" ElseIf provincia = 17 Then TextBox2.Text = " PROVINCIA ES PICHINCHA" ElseIf provincia = 18 Then TextBox2.Text = " PROVINCIA ES TUNGURAHUA" ElseIf provincia = 19 Then TextBox2.Text = " PROVINCIA ES ZAMORA CHINCHIPE" ElseIf provincia = 20 Then TextBox2.Text = "PROVINCIA ES GALAPAGOS" ElseIf provincia = 21 Then TextBox2.Text = " PROVINCIA ES SUCUMBIOS" ElseIf provincia = 23 Then TextBox2.Text = " PROVINCIA ES SANTO DOMINGO DE LOS TSACHILAS" ElseIf provincia = 22 Then TextBox2.Text = " PROVINCIA ES ORELLANA" ElseIf provincia = 24 Then TextBox2.Text = " PROVINCIA ES SANTA ELENA" EndIf For i = 2 To 8 Step 2 par = par + Mid(Val(TextBox1.Text), i, 1) Next For i = 1 To 9 Step 2 x = Mid(Val(TextBox1.Text), i, 1) * 2 If x >= 9 Then x = x - 9 EndIf imp = imp + x a = par + imp Next x = a Mod 10 If x > 0 Then x = 10 - x EndIf If x = Val(Mid(TextBox1.Text, 10, 1)) Then MsgBox("Numero de cedula bien") Else MsgBox("Numero de cedula no pasa la validacin") EndIf EndIf EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End EndSub PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox2.Text = "" TextBox1.Text = "" TextBox3.Text = "" EndSub


EJERCICIO DE POTENCIA

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Resultado, I AsInteger Resultado = 1 For I = 1 ToVal(TextBox2.Text) Resultado = Resultado * Val(TextBox1.Text) Next I TextBox3.Text = Resultado EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End EndSub

EJERCICOS LOS MESES DEL ANO


PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, m, d, d1, bis AsInteger a = Mid(TextBox1.Text, 1, 4) m = Mid(TextBox1.Text, 6, 2) d1 = Mid(TextBox1.Text, 9, 2) bis = a Mod (4) If a < 1900 Or a > 2014 Then MsgBox("INGRESE OTRO Aテ前") TextBox1.Text = "" Else If m <= 0 Or m > 12 Then MsgBox("INGRESE OTRO MES") TextBox1.Text = "" Else SelectCase m Case 1, 3, 5, 7, 8, 10, 12 d = 31 Case 4, 6, 9, 11 d = 31 Case 2 If bis = 0 Then d = 29 Else d = 28 EndIf EndSelect If d1 > d Then MsgBox("INGRESE OTRO DIA") TextBox1.Text = "" Else MsgBox("FECHA VALIDA") TextBox1.Text = "" EndIf

EJERCICIO NUMERO POSITIVO NEGATIVO


PrivateSub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click End EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" TextBox2.Text = "" EndSub PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim n AsInteger n = TextBox1.Text If (n = 0) Then TextBox2.Text = " NUMERO " + Trim(n) + " NULO" Else If (n > 0) Then TextBox2.Text = "NUMERO " + Trim(n) + " POSITIVO" Else TextBox2.Text = "NUMERO " + Trim(n) + " NEGATIVO" EndIf EndIf EndSub

EJERCICOS DE VECTORES


PublicClassForm3 Dim N, L, PAR, IMP AsInteger PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click N = InputBox("INGRESE POSICIONES") Dim A(N) AsInteger For I = 0 To N - 1 A(I) = InputBox("INGRESE VECTORES ") ListBox1.Items.Add(A(I)) IfA(I) Mod (2) = 0 Then PAR = PAR + 1 EndIf IMP = IMP + 1 Next EndSub PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = PAR TextBox2.Text = IMP EndSub EndClass

PublicClassForm2 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim TEXT AsTextBox() = NewTextBox() {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5} For I = 0 To 4 TEXT(I).Text = InputBox("INGRESE VECTOR") Next EndSub EndClass


PublicClassForm1 DimA(5), N AsInteger PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For I = 0 To 4 N = InputBox("INGRESE VECTOR DE 5 POCICIONES ") ListBox1.Items.Add(N) Next EndSub PrivateSub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click EndSub PrivateSub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged EndSub EndClass

REDIM EJERCICIOS


PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dimsum(), num() AsInteger, tum, nn AsInteger ReDimsum(0 To nn) ReDimnum(0 To nn) TextBox1.Text = InputBox("ingrese numeros") TextBox2.Text = InputBox("ingrese otros numeros") sum(tum) = Val(TextBox1.Text) For tum = 1 Tosum(tum) sum(tum) = InputBox("ingrese otros numeros") ListBox1.Items.Add(sum(tum)) Next tum nn = sum(tum) + tum tum = Val(TextBox2.Text) ReDimPreservenum(nn) For tum = 1 Tosum(tum) sum(tum) = InputBox("ingrese otros numeros") Next tum For tum = 1 To nn ListBox2.Items.Add(tum) Next EndSub EndClass


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.