UNIVERSIDAD CENTRAL DEL ECUADOR ESCUELA DE CIENCIAS EXACTAS
MAS DE 50 PROGRAMAS EN VB SALAZAR DIEGO
UNIVERSIDAD CENTRAL DEL ECUADOR PROGRAMAS EN VISUAL BASIC 2010 PROGRAMACION
IV
QUITO - ECUADOR 17/08/2014
El contenido de este documento se basa en la programaci贸n que se puede realizar en visual Basic 2010. Aqu铆 realizamos algunos ejercicios que nos han sido de utilidad para entender el modo de programar en visual. Net, por lo tanto espero que le sea de utilidad al lector.
Contenido 1.
Enlace de formulario ................................................................................................................... 2
2.
Msgbox 3 ejercicios ..................................................................................................................... 3
3.
Inputbox 3 ejercicios ................................................................................................................... 5
4.
Ejercicios do while tablas de multiplicar .................................................................................... 8
6.
Ejercicios funciones procedimientos......................................................................................... 10
7.
Ejercicio select case validacion de fecha y 3 mas...................................................................... 17
8.
Ejercicios con cadena de caracteres.......................................................................................... 21
10.
Ejercicio de agenda system io ............................................................................................... 25
11.
Ejercicio fibonacci.................................................................................................................. 26
12.
Ejercicio factorial ................................................................................................................... 27
13.
Ejercicio cara feliz .................................................................................................................. 28
14.
Ejercicio numero primo ......................................................................................................... 31
15.
Ejercicio cedula validacion .................................................................................................... 32
16.
Ejercicio ingresar numero y sacar pares impares.................................................................. 34
17.
Ejercicio bars ......................................................................................................................... 35
18.
Ejercicio menu de opciones .................................................................................................. 36
19.
Ejercicios animacion de texto................................................................................................ 38
20.
Ejercicio de contrasena ......................................................................................................... 42
21.
Ejercicio funcion mid len ....................................................................................................... 43
22.
Ejercicio de texto vocales ...................................................................................................... 44
23.
Ejercicio numero par ............................................................................................................. 45
25.
Ejercicio con timer ................................................................................................................. 46
26.
Ejercicio con if elseif endif ..................................................................................................... 47
27.
Ejercicio de potencia ............................................................................................................. 49
28.
Ejercicos los meses del ano ................................................................................................... 50
29.
Ejercicio numero positivo negativo ....................................................................................... 51
30.
Ejercicos de vectores 4 .......................................................................................................... 52
31.
Redim ejercicios 2 ................................................................................................................. 54
1. Enlace de formulario
ESTE EJERCICIO TRATA DE EN LAZAR DOS FORMULARIOS CON UN BOTÓN SIGUIENTE EN EL CUAL PODEMOS OBSERVAR QUE LA PROGRAMACIÓN ES SIMPLE, PARA NADA COMPLICADA.
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b, c As Integer a = TextBox1.Text b = TextBox2.Text c=a+b TextBox3.Text = c End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Form2.Show() Me.Hide() End Sub End Class
AQUÍ PODEMOS OBSERVAR LA APRACION DEL SEGUNDO FORMULARIO Y SU RESPECTIVA PROGRAMACION.
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer = 10 Dim r As Boolean r = 5 > a TextBox1.Text = r End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close() End Sub End Class
2. Msgbox 3 ejercicios
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("FIN PROGRAMA", vbOKOnly + vbCritical, "Informaci贸n") End End Sub End Class
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Public Class Form2
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 End Class
Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intRespuesta As Integer intRespuesta = MsgBox("驴Quieres seguir?", vbQuestion + vbYesNo, "Informaci贸n importante") If intRespuesta = 6 Then MsgBox("Seguimos") Else MsgBox("Terminamos") End End If End Sub End Class
3. Inputbox 3 ejercicios Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a(2, 3), b(3, 2), r(2, 2) As Integer Dim acu As Integer For I = 1 To 2 For j = 1 To 3 a(I, j) = InputBox(" ingrese NUMEROS") ListBox1.Items.Add(a(I, j)) Next Next For I = 1 To 3 For j = 1 To 2 b(I, j) = InputBox(" ingrese NUMEROS") ListBox2.Items.Add(b(I, j)) Next Next For I = 1 To 2 For J = 1 To 2 For K = 1 To 3 acu = a(I, K) * b(K, J) + acu Next r(I, J) = acu
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg ListBox3.Items.Add(r(I, J)) acu = 0
Next
Next End Sub End Class
Public Class Form2
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 la matriz") ListBox1.Items.Add(mat(i, j)) Next Next End Sub End Class
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nfa, nca As Integer Dim nfb, ncb As Integer Dim acu As Integer nfa nca nfb ncb
= = = =
InputBox("Número InputBox("Número InputBox("Número InputBox("Número
de de de de
filas de columnas filas de columnas
la de la de
Matriz A") la Matriz A") Matriz B") la Matriz B")
If nca = nfb Then
Dim a(nfa, nca), b(nfb, ncb), r(nfa, ncb) As Integer
For I = 1 To nfa For j = 1 To nca a(I, j) = InputBox(" ingrese numeros") ListBox1.Items.Add(a(I, j)) Next Next For I = 1 To nfb For j = 1 To ncb b(I, j) = InputBox(" ingrese numeros") ListBox2.Items.Add(b(I, j)) Next Next For i = 1 To nfa For J = 1 To ncb For K = 1 To nfb acu = a(i, K) * b(K, J) + acu Next r(i, J) = acu ListBox3.Items.Add(r(i, J)) acu = 0
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui 4. Ejercicios do while tablas de multiplicar opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Next
Next
Else
MsgBox("no existe producto") End If End Sub End Class
Public Class Form2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim R, X As Integer X = 1 Do While X <= 12 R = X * 1 ComboBox1.Items.Add(R.ToString & "=" & X.ToString & "*" & "1") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 2 ComboBox2.Items.Add(R.ToString & "=" & X.ToString & "*" & "2") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 3 ComboBox3.Items.Add(R.ToString & "=" & X.ToString & "*" & "3") X = X + 1
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Loop X = 1 Do While X <= 12 R = X * 4 ComboBox4.Items.Add(R.ToString & "=" & X.ToString & "*" & "4") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 5 ComboBox5.Items.Add(R.ToString & "=" & X.ToString & "*" & "5") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 6 ComboBox6.Items.Add(R.ToString & "=" & X.ToString & "*" & "6") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 7 ComboBox7.Items.Add(R.ToString & "=" & X.ToString & "*" & "7") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 8 ComboBox8.Items.Add(R.ToString & "=" & X.ToString & "*" & "8") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 9 ComboBox9.Items.Add(R.ToString & "=" & X.ToString & "*" & "9") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 10 ComboBox10.Items.Add(R.ToString & "=" & X.ToString & "*" & "10") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 11 ComboBox11.Items.Add(R.ToString & "=" & X.ToString & "*" & "11") X = X + 1 Loop X = 1 Do While X <= 12 R = X * 12 ComboBox12.Items.Add(R.ToString & "=" & X.ToString & "*" & "12") X = X + 1 Loop End Sub End Class
6. Ejercicios funciones procedimientos
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BackColor = Color.Blue End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Text = "primer formulario" Me.ForeColor = Color.Green End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close() End Sub End Class
Public Class Form4 Private Sub PictureBox4_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox4.MouseMove
TextBox1.Text = "TECLADO" End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
TextBox1.Text = "MONITOR" End Sub Private Sub PictureBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox2.MouseMove
TextBox1.Text = "CPU" End Sub Private Sub PictureBox3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox3.MouseMove
TextBox1.Text = "MOUSE" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
FORM5.SHOW() End Sub End Class
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
LABEL1.TEXT = "MI SEGUNDO FORMILARIO" End Sub Private Sub Button2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
Me.BackColor = Color.Blue End Sub Private Sub Button3_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button3.MouseDoubleClick
Label1.ForeColor = Color.BurlyWood End Sub End Class
Public Class Form11 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Visible = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PictureBox1.Visible = False End Sub End Class
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HHH.Click
NOMBRETEXT.TEXT = "UMIVERSIDAD CENTRAL" End Sub End Class
Public Class Form2 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.BackColor = Color.Aqua Me.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
NUM3.Text = Val(NUM1.Text) + Val(NUM2.Text) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
NUM3.Text = Val(NUM1.Text) - Val(NUM2.Text) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
NUM3.Text = Val(NUM1.Text) * Val(NUM2.Text) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
NUM3.Text = Val(NUM1.Text) / Val(NUM2.Text) End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
ListBox1.Items.Add(NUM3.Text) NUM3.Text = "" NUM3.Focus() End Sub End Class
Public Class Form3 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text) End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox1.Focus() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
End End Sub End Class
Public Class Form8 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim X As Integer Do While X < 10 TextBox3.Text = TextBox3.Text & X.ToString & " X = X + 1 Loop End Sub
"
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim X As Integer Do TextBox2.Text = TextBox2.Text & X.ToString & "" X = X + 1 Loop Until X >= 10 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim X As Integer While X <= 10 TextBox1.Text = TextBox1.Text & X.ToString & "" X += 1 End While End Sub End Class
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim aDateString, aTimeString As String Dim aDate, aTime As Date 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) TextBox1.Text = aDateString TextBox2.Text = aTimeString TextBox3.Text = aDate TextBox4.Text = aTime End Sub End Class
7. Ejercicio select case validacion de fecha y 3 mas
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, m, d, d1, bis As Integer 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 Select Case 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 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 Form2 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 Case 2 TextBox2.Text Case 3 TextBox2.Text Case 4 TextBox2.Text Case 5 TextBox2.Text Case 6 TextBox2.Text Case 7 TextBox2.Text End Select End Sub End Class
= "lunes" = "martes" = "miercoles" = "jueves" = "viernes" = "sabado" = "domingo"
Public Class Form3
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 = ComboBox1.SelectedItem 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 End Select End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.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") End Sub End Class
Public Class Form1 Dim cont As Integer = 0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End End Sub Private Sub 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 Select Case cont Case 1 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 2 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 3 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 4 Label1.Visible Label2.Visible Label3.Visible
= = = = =
True False False False False
= = = = =
False True False False False
= = = = =
False False True False False
= False = False = False
Label4.Visible = True Label5.Visible = False Case 5 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible End Select End If
= = = = =
False False False False True
End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start() End Sub End Class
8. Ejercicios con cadena de caracteres
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Dim CONT As Integer Dim EX As String Dim N As Integer N = Len(TextBox1.Text) TextBox2.Text = N For I = 1 To N Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox2.Text = EX If EX = "a" Or EX = "A" Then CONT = CONT + 1 End If TextBox2.Text = CONT
Next End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Dim CONT As Integer Dim EX As String Dim N As Integer N = Len(TextBox1.Text) TextBox2.Text = N For I = 1 To N Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox2.Text = EX If EX = "e" Or EX = "E" Then CONT = CONT + 1 End If TextBox2.Text = CONT Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CONT As Integer Dim EX As String Dim N As Integer N = Len(TextBox1.Text) TextBox2.Text = N For I = 1 To N Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox2.Text = EX If EX = "i" Or EX = "I" Then CONT = CONT + 1 End If TextBox2.Text = CONT Next End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
Dim CONT As Integer Dim EX As String Dim N As Integer N = Len(TextBox1.Text) TextBox2.Text = N For I = 1 To N Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox2.Text = EX If EX = "o" Or EX = "O" Then CONT = CONT + 1 End If TextBox2.Text = CONT Next End Sub
Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
Dim CONT As Integer Dim EX As String Dim N As Integer N = Len(TextBox1.Text) TextBox2.Text = N For I = 1 To N Step 1 EX = Mid(TextBox1.Text, I, 1) TextBox2.Text = EX If EX = "u" Or EX = "U" Then CONT = CONT + 1 End If TextBox2.Text = CONT Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Text = "" End Sub End Class
Public Class Form1 Dim A As Integer Dim EX As String Dim CONT As String = 0 Private Sub 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 End If TextBox4.Text = CONT Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub End Class
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = Mid(TextBox1.Text, 2, 2) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Text = Len(TextBox1.Text) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = Microsoft.VisualBasic.Left(TextBox1.Text, 5) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox2.Text = Microsoft.VisualBasic.Right(TextBox1.Text, 5) End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox2.Text = Microsoft.VisualBasic.Trim(TextBox1.Text) End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox2.Text = Space(TextBox1.Text) End Sub End Class
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim H As Integer H = TextBox1.Text Select Case H Case 1 To 5 MsgBox("MADRUGADA") Case 6 To 11 MsgBox("MAÑANA") Case 12 To 18 MsgBox("TARDE") Case 18 To 24 MsgBox("NOCHE") End Select End Sub End Class
10.
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_23\Desktop\Datos del registro.txt" If File.Exists(path) = False Then Dim datos As StreamWriter = 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) End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub 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 = "" End Sub End Class
11.
Ejercicio fibonacci
Public Class Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TotalNumeros As Integer TotalNumeros = 12 Dim fibonacci(12) As Long Dim i As Integer fibonacci(1) = 1 fibonacci(2) = 1 For i = 3 To TotalNumeros fibonacci(i) = fibonacci(i - 1) + fibonacci(i - 2) Next i For i = 1 To TotalNumeros MsgBox("fibonacci(i)") Next i End Sub End Class
12.
Ejercicio factorial Public Class Form3 Dim I, F As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For I = 1 To Val(TextBox1.Text) F = F * I Next TextBox2.Text = F End Sub End Class
13.
Ejercicio cara feliz
Public Class Form7 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End End Sub 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 PictureBox3.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
Dim r As Integer r = Val(TextBox1.Text) + Val(TextBox2.Text) If (Val(TextBox3.Text)) = Val(TextBox1.Text) + Val(TextBox2.Text) Then PictureBox3.Image = PictureBox1.Image Else PictureBox3.Image = PictureBox2.Image End If End Sub End Class
Public Class Form2 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
PictureBox1.Visible = True End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
PictureBox6.Visible = True End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
PictureBox2.Visible = True End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
PictureBox3.Visible = True End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
PictureBox4.Visible = True End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
PictureBox7.Visible = True End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
PictureBox8.Visible = True End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
PictureBox5.Visible = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If PictureBox1.Visible = True And PictureBox5.Visible = True Then PictureBox1.Visible = True
Else PictureBox1.Visible = False End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If PictureBox2.Visible = True And PictureBox8.Visible = True Then PictureBox2.Visible = True Else PictureBox2.Visible = False End If End Sub Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If PictureBox3.Visible = True And PictureBox6.Visible = True Then PictureBox3.Visible = True Else PictureBox3.Visible = False End If End Sub Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
If PictureBox4.Visible = True And PictureBox7.Visible = True Then PictureBox4.Visible = True Else PictureBox4.Visible = False End If End Sub Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
If PictureBox5.Visible = True And PictureBox1.Visible = True Then PictureBox5.Visible = True Else PictureBox5.Visible = False End If End Sub Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
If PictureBox6.Visible = True And PictureBox3.Visible = True Then PictureBox6.Visible = True Else PictureBox6.Visible = False End If End Sub Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
If PictureBox7.Visible = True And PictureBox4.Visible = True Then PictureBox7.Visible = True Else PictureBox7.Visible = False End If End Sub Private Sub Timer8_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer8.Tick
If PictureBox8.Visible = True And PictureBox2.Visible = True Then PictureBox8.Visible = True Else PictureBox8.Visible = False
End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Visible PictureBox2.Visible PictureBox3.Visible PictureBox4.Visible PictureBox5.Visible PictureBox6.Visible PictureBox7.Visible PictureBox8.Visible End Sub End Class
14.
= = = = = = = =
False False False False False False False False
Ejercicio numero primo
Public Class Form6 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer = 0 Dim r, i As Integer r = TextBox1.Text For i = 1 To r Step 1 If r Mod i = 0 Then a = a + 1 End If Next If a > 2 Then TextBox2.Text = "No es Primo" Else TextBox2.Text = "Si es Primo" End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Text = "" TextBox1.Text = "" End Sub End Class
15.
Ejercicio cedula validacion
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, par, imp, x, provincia As Integer If Len(TextBox1.Text) > 10 Then MsgBox("CEDULA INCORRECTA") Else provincia = Mid(TextBox1.Text, 1, 2) TextBox3.Text = provincia If provincia = 1 Then TextBox2.Text = " PROVINCIA ES AZUAY" ElseIf provincia = 2 Then TextBox2.Text = " PROVINCIA ES BOLIVAR" ElseIf provincia = 3 Then TextBox2.Text = " PROVINCIA ES CAÑAR" ElseIf provincia = 4 Then TextBox2.Text = " PROVINCIA ES CARCHI" 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" End If 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 x = x End If imp = imp a = par +
Then - 9 + x imp
Next x = a Mod 10 If x > 0 Then x = 10 - x End If If x = Val(Mid(TextBox1.Text, 10, 1)) Then MsgBox("NUMERO DE CEDULA CORRECTO") Else MsgBox("NO PASA LA VALIDACION") End If
End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = "" TextBox1.Text = "" TextBox3.Text = "" End Sub End Class
16.
Ejercicio ingresar numero y sacar pares impares
Public Class Form3 Dim N, L, PAR, IMP As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
N = InputBox("INGRESE POSICIONES") Dim A(N) As Integer For I = 0 To N - 1 A(I) = InputBox("INGRESE VECTORES ") ListBox1.Items.Add(A(I)) If A(I) Mod (2) = 0 Then PAR = PAR + 1 End If IMP = IMP + 1 Next End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = PAR TextBox2.Text = IMP End Sub End Class
17.
Ejercicio bars
Public Class Form1 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
animar() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "diego" And TextBox2.Text = "123" Then Timer2.Start() Else MsgBox("User o Pass incorrectos") TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() End If End Sub Private Sub 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() End If
End Sub End Class
18.
Ejercicio menu de opciones
Public Class Form2 Private Sub CUADRADOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CUADRADOToolStripMenuItem.Click
Form3.Show() Form1.Hide() End Sub Private Sub RECTANGULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RECTANGULOToolStripMenuItem.Click
Form4.Show() Form1.Hide() End Sub Private Sub CIRCULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CIRCULOToolStripMenuItem.Click
Form5.Show() Form1.Hide() End Sub Private Sub TRIANGULOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TRIANGULOToolStripMenuItem.Click
Form6.Show() Form1.Hide() End Sub
Private Sub ARCHIVOToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ARCHIVOToolStripMenuItem.Click End Sub End Class
Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
respuesta.Text = (Val(lado.Text) ^ 2) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
respuesta.Text = 4 * (Val(lado.Text)) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
animar() End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start() End Sub End Class
19.
Ejercicios animacion de texto
Public Class Form4 Dim cont As Integer = 0 Private Sub 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 Select Case cont Case 1 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 2 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 3 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible Case 4 Label1.Visible Label2.Visible Label3.Visible
= = = = =
True False False False False
= = = = =
False True False False False
= = = = =
False False True False False
= False = False = False
Label4.Visible = True Label5.Visible = False Case 5 Label1.Visible Label2.Visible Label3.Visible Label4.Visible Label5.Visible End Select End If End Sub
= = = = =
False False False False True
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() End Sub Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click End Sub End Class
Public Class Form7 Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged TextBox1.Text = "CENTRAL" End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
TextBox1.Text = "UNIVERSIDAD" End Sub End Class
Public Class Form6 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ListBox1.Items.Add(TextBox1.Text) TextBox1.Text = "" TextBox1.Focus() End Sub End Class
Public Class Form5 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HHH.Click NOMBRE.TEXT = "UMIVERSIDAD CENTRAL" End Sub End Class
Public Class Form10 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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = suma() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub End Class
20.
Ejercicio de contrasena
Public Class Form5 Dim cons As Integer = 0 Private Sub 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 End If If cons = "3" Then cons = "1" Else cons = cons + 1 Select Case cons Case 1 Label1.Visible = True Label2.Visible = False Label3.Visible = False Case 2 Label1.Visible = False
Label2.Visible Label3.Visible Case 3 Label1.Visible Label2.Visible Label3.Visible End Select End If End Sub
= True = False = False = False = True
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "diego" And TextBox2.Text = "123" Then Timer1.Start() Else MsgBox("ingrese los datos bien") TextBox1.Text = "" TextBox2.Text = "" End If End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer1.Start() End Sub End Class
21.
Ejercicio funcion mid len
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = Mid(TextBox1.Text, 2, 2)
End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Text = Len(TextBox1.Text) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = Microsoft.VisualBasic.Left(TextBox1.Text, 5) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox2.Text = Microsoft.VisualBasic.Right(TextBox1.Text, 5) End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox2.Text = Microsoft.VisualBasic.Trim(TextBox1.Text) End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox2.Text = Space(TextBox1.Text) End Sub End Class
22.
Ejercicio de texto vocales
Public Class Form1 Dim A As Integer Dim EX As String Dim CONT As String = 0 Private Sub 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 End If TextBox4.Text = CONT Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub End Class
23.
Ejercicio numero par
Public Class Form2 Dim I As Integer Private Sub 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 End Sub End Class
25.
Ejercicio con timer
Module Module1 Sub Main() Dim aDateString, aTimeString As String Dim aDate, aTime As Date 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() End Sub End Module
26.
Ejercicio con if elseif endif
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, par, imp, x, provincia As Integer If Len(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" End If 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 x = x End If imp = imp a = par +
Then - 9 + x imp
Next x = a Mod 10 If x > 0 Then x = 10 - x End If If x = Val(Mid(TextBox1.Text, 10, 1)) Then MsgBox("Numero de cedula bien") Else MsgBox("Numero de cedula no pasa la validacin")
End If End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox2.Text = "" TextBox1.Text = "" TextBox3.Text = "" End Sub End Class
27.
Ejercicio de potencia
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Resultado, I As Integer Resultado = 1 For I = 1 To Val(TextBox2.Text) Resultado = Resultado * Val(TextBox1.Text) Next I TextBox3.Text = Resultado End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub End Class
28.
Ejercicos los meses del ano
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim H As Integer H = TextBox1.Text If H > 12 Then MsgBox("INGRESE OTRO MES", vbOKOnly + vbCritical, "Informaci贸n") TextBox1.Text = "" Else Select Case H Case 1 MsgBox("ENERO") Case 2 MsgBox("FEBRERO") Case 3 MsgBox("MARZO") Case 4 MsgBox("ABRIL") Case 5 MsgBox("MAYO") Case 6 MsgBox("JUNIO") Case 7 MsgBox("JULIO") Case 8 MsgBox("AGOSTO") Case 9 MsgBox("SEPTIEMBRE") Case 10 MsgBox("OCTUBRE") Case 11 MsgBox("NOVIEMBRE") Case 12 MsgBox("DICIEMBRE")
End Select End If End Sub End Class
29.
Ejercicio numero positivo negativo
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim n As Integer n = TextBox1.Text If (n = 0) Then TextBox2.Text = "El numero " + Trim(n) + " es nulo" Else If (n > 0) Then TextBox2.Text = "El numero " + Trim(n) + " es positivo" Else TextBox2.Text = "El numero " + Trim(n) + " es negativo" End If End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = "" TextBox2.Text = "" End Sub End Class
qwertyuiopasdfghjklzxcvbnmqw 30. Ejercicos de vectores 4 ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Public Class Form3 Dim N, L, PAR, IMP As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
N = InputBox("INGRESE POSICIONES") Dim A(N) As Integer For I = 0 To N - 1 A(I) = InputBox("INGRESE VECTORES ") ListBox1.Items.Add(A(I)) If A(I) Mod (2) = 0 Then PAR = PAR + 1 End If IMP = IMP + 1 Next End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = PAR TextBox2.Text = IMP End Sub End Class
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg 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") Next End Sub End Class
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa 31. Redim ejercicios 2 sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg Public Class Form1 Dim A(5), N As Integer
Private Sub 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 End Sub End Class
Public Class Form6
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sum(), num() As Integer, tum, nn As Integer ReDim sum(0 To nn) ReDim num(0 To nn)
TextBox1.Text = InputBox("ingrese numeros") TextBox2.Text = InputBox("ingrese otros numeros") sum(tum) = Val(TextBox1.Text) For tum = 1 To sum(tum) sum(tum) = InputBox("ingrese otros numeros") ListBox1.Items.Add(sum(tum)) Next tum
qwertyuiopasdfghjklzxcvbnmqw ertyuiopasdfghjklzxcvbnmqwert yuiopasdfghjklzxcvbnmqwertyui opasdfghjklzxcvbnmqwertyuiopa sdfghjklzxcvbnmqwertyuiopasdf ghjklzxcvbnmqwertyuiopasdfghj klzxcvbnmqwertyuiopasdfghjklz xcvbnmqwertyuiopasdfghjklzxcv bnmqwertyuiopasdfghjklzxcvbn mqwertyuiopasdfghjklzxcvbnmq wertyuiopasdfghjklzxcvbnmqwe rtyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuio pasdfghjklzxcvbnmqwertyuiopas dfghjklzxcvbnmqwertyuiopasdfg nn = sum(tum) + tum tum = Val(TextBox2.Text) ReDim Preserve num(nn) For tum = 1 To sum(tum) sum(tum) = InputBox("ingrese otros numeros") Next tum For tum = 1 To nn ListBox2.Items.Add(tum) Next End Sub
End Class
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num() As Integer, reng As Integer ReDim num(0 To 4) For reng = 1 To 4 num(reng) = reng * 5 ListBox1.Items.Add(num(reng)) Next reng ReDim Preserve num(7) For reng = 5 To 7 num(reng) = reng * 10 Next reng For reng = 1 To 7 ListBox2.Items.Add(num(reng)) Next End Sub End Class