Programacion I Visual Basic PDF
Programacion I Visual Basic PDF
EJERCICIO # 1
1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
End Sub
_________________________________________________________________________________
End Sub
End Class
__________________________________________________________________________________
EJERCICIO # 2
2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Energía potencial
'Fecha:
'Declaración de variables
Dim ep, m, x As Single
m = TextBox1.Text
x = TextBox2.Text
'Visualizar resultado
TextBox3.Text = ep
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 = " "
End Sub
_________________________________________________________________________________
_________________________________________________________________________________
EJERCICIO # 3
3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa:Trabajo
'Fecha:
'Declaración de variables
Dim w, m, vf, vi As Single
m = TextBox1.Text
vf = TextBox2.Text
vi = TextBox3.Text
'Calcular el trabajo
w = (m * (vf ^ 2) / 2) - (m * (vi ^ 2) / 2)
'visualizar resultado en cada de mensaje
MsgBox("El trabajo calculado es: " & w)
End Sub
_________________________________________________________________________________
4
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
_________________________________________________________________________________
EJERCICIO # 4
5
a = TextBox1.Text
b = TextBox2.Text
c=a-b
TextBox3.Text = c
End Sub
_________________________________________________________________________________
6
TextBox3.Text = " "
End Sub
_________________________________________________________________________________
_________________________________________________________________________________
EJERCICIO # 5
7
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Area de cilindro
'Fecha:
'Declaración de variables
Dim a, r, h As Single
r = TextBox1.Text
h = TextBox2.Text
'Visualizando resultado
TextBox3.Text = a
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 = " "
End Sub
8
_________________________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
_________________________________________________________________________________
EJERCICIO # 6
9
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Declaración de variables
Dim grad, dato As Single
dato = TextBox1.Text
'Calculando grados
grad = (dato * 180)
'Visualizar resultado en grados
TextBox2.Text = grad
Label3.Text = "Grados"
End Sub
_________________________________________________________________________________
EJERCICIO # 7
10
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: área y perímetro de parábola
'Fecha
'Declaración de variables
Dim are, p, a, b As Single
a = TextBox1.Text
b = TextBox2.Text
If RadioButton1.Checked = True Then
are = 3.141592 * a * b
MsgBox("El área de la parábola es : " & are)
Else
If RadioButton2.Checked = True Then
p = 2 * 3.141592 * (1 / 2 * (a ^ 2 + b ^ 2)) ^ 0.5
MsgBox("El perímetro de la parábola es : " & p)
End If
End If
End Sub
_________________________________________________________________________________
11
End
End Sub
_________________________________________________________________________________
EJERCICIO # 8
12
TextBox4.Text = d
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
_______________________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
_________________________________________________________________________________
EJERCICIO # 9
13
r=a+b
Else
If RadioButton2.Checked = True Then
r=a-b
Else
If RadioButton3.Checked = True Then
r=a*b
Else
If RadioButton4.Checked = True Then
r=a/b
Else
If RadioButton5.Checked = True Then
r=a^b
End If
End If End If End If
End If
MsgBox("El resultado es : " & r)
End Sub
_____________________________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
End Sub
_________________________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
_________________________________________________________________________________
EJERCICIO # 10
14
Public Class Form1
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles ComboBox1.Selected
IndexChanged
'Programa: Conceptos
'Uso de ciclo condicional IF-THEN-ELSE
If ComboBox1.Text = "Aceleración" Then
Label1.Text = "La aceleración es el cambio de velocidad en el tiempo para desplazar un cuerpo de un punto A a un punto B."
Label3.Text = "a = (Vf -Vo) / t"
Label2.Text = "Ingrese velocidad final (Vf):"
Label4.Text = "Ingrese velocidad inicial (Vo):"
Label5.Text = "Ingrese el tiempo ( t ):"
Label6.Text = "La aceleración es ( a ):"
Else
If ComboBox1.Text = "Velocidad inicial (Vo)" Then
Label1.Text = "Es la Velocidad que tiene un cuerpo al INICIAR su movimiento en un período de tiempo."
Label3.Text = "Vo = Vf - a t"
Label2.Text = "Ingrese velocidad final (Vf):"
Label4.Text = "Ingrese aceleración ( a ):"
Label5.Text = "Ingrese el tiempo ( t ):"
Label6.Text = "La velocidad inicial es (Vo):"
15
Else
If ComboBox1.Text = "Velocidad final (Vf)" Then
Label1.Text = "Es la Velocidad que tiene un cuerpo al FINALIZAR su movimiento en un período de tiempo."
Label3.Text = "Vf = Vo + a t"
Label2.Text = "Ingrese velocidad inicial (Vo):"
Label4.Text = "Ingrese aceleración ( a ):"
Label5.Text = "Ingrese el tiempo ( t ):"
Label6.Text = "La velocidad final es (Vf):"
End If
End If
End If
End Sub
_________________________________________________________________________________
16
TextBox4.Text = vf
End If
End If
End If
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
_________________________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class
_________________________________________________________________________________
EJERCICIO # 11
17
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Funciones trigonométricas
'Declaración de variables
Dim r, ang As Single
ang = TextBox1.Text
'Evaluando condición, para seleccionar función
If RadioButton1.Checked = True Then
r = Math.Cos(ang)
Else
If RadioButton2.Checked = True Then
r = Math.Sin(ang)
Else
If RadioButton3.Checked = True Then
r = Math.Tan(ang)
End If
End If
End If
TextBox2.Text = r
End Sub
_________________________________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
End Sub
_________________________________________________________________________________
EJERCICIO # 12
18
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Área de circulo
'Fecha: 14 de Agosto de 2012
'Declaración de variables
Dim a, r As Single
r = TextBox1.Text
'Visualizar resultado
TextBox2.Text = a
End Sub
________________________________________________________________________________
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = " "
TextBox2.Text = " "
End Sub
_________________________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
19
End
End Sub
_________________________________________________________________________________
EJERCICIO # 13
20
_______________________________________________________________________
________________________________________________________________________
EJERCICIO # 14
21
Dim x2, x1, y2, y1, d As Single
x2 = TextBox1.Text
x1 = TextBox2.Text
y2 = TextBox3.Text
y1 = TextBox4.Text
'Calculo de distancia
d = ((x2 - x1) ^ 2 + (y2 - y1) ^ 2) ^ 0.5
'Visualizar resuldo
TextBox5.Text = d
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 = " "
TextBox5.Text = " "
End Sub
_______________________________________________________________________
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
_______________________________________________________________________
EJERCICIO # 15
22
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Ciclo condicional promedio
Dim nomb As String
Dim estado As String
Dim p1, p2, p3, p4, prom As Single
nomb = TextBox1.Text
p1 = TextBox2.Text
p2 = TextBox3.Text
p3 = TextBox4.Text
p4 = TextBox5.Text
prom = (p1 + p2 + p3 + p4) / 4
'Ciclo condicional para evaluar el estado
If prom >= 7 Then
estado = "Aprobado"
23
Else
If prom < 7 Then
estado = "R e p r o b a d o"
End If
End If
MsgBox(nomb & "su promedio es:" & prom & "Su estado actual:" & estado)
End Sub
________________________________________________________________________
________________________________________________________________________
24
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Programa: Estructura de control Select Case (Meses)
Dim numeromes As String
numeromes = TextBox1.Text
Select Case numeromes
Case "1"
TextBox2.Text = "Enero"
Case "2"
TextBox2.Text = "Febrero"
Case "3"
TextBox2.Text = "Marzo"
Case "4"
TextBox2.Text = "Abril"
Case "5"
TextBox2.Text = "Mayo"
Case "6"
TextBox2.Text = "Junio"
Case "7"
TextBox2.Text = "Julio"
Case "8"
25
TextBox2.Text = "Agosto"
Case "9"
TextBox2.Text = "Septiembre"
Case "10"
TextBox2.Text = "Octubre"
Case "11"
TextBox2.Text = "Noviembre"
Case "12"
TextBox2.Text = "Diciembre"
Case Else
TextBox2.Text = "Digite dato correctamente"
End Select
End Sub
________________________________________________________________________
________________________________________________________________________
EJERCICIO # 17
26
Formulario usando variables y caja de mensaje
27
RGB2 = TextBox2.Text
RGB3 = TextBox3.Text
Me.BackColor = Color.FromArgb(RGB1, RGB2, RGB3)
End Sub
________________________________________________________________________
________________________________________________________________________
28