You are on page 1of 10

Prcticas En Visual Basic 2 Parcial

Introduccin. En este documento se muestran diferentes programas elaborados en Visual Basic, la ventana y para que nos sirven los distintos programas.
Con este programa podemos insertar un nmero y nos dar un da de la semana.

Public Class Form1 Dim dia As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click dia = TextBox1.Text Select Case (dia) Case 1 MsgBox("Lunes") Case 2 MsgBox("Martes") Case 3 MsgBox("Miercoles") Case 4 MsgBox("Jueves") Case 5 MsgBox("Viernes") End Select End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Close() End Sub End Class

Con este programa podemos calcular el promedio de 5 calificaciones y nos muestra el nivel si es bueno, regular, etc.

Public Class Form1 Dim c1 As Integer Dim c2 As Integer Dim c3 As Integer Dim c4 As Integer Dim c5 As Integer Dim prom As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click c1 = TextBox1.Text c2 = TextBox2.Text c3 = TextBox3.Text c4 = TextBox4.Text c5 = TextBox5.Text prom = (c1 + c2 + c3 + c4 + c5) / 5 TextBox6.Text = prom prom = TextBox6.Text Select Case (prom) Case 10 MsgBox("Exelente") Case 9 MsgBox("Muy Bien") Case 8 MsgBox("Bien") Case 7 MsgBox("Regular") Case 6 MsgBox("Suficiente") Case Is < 6 MsgBox("insuficiente")

End Select End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Clear() TextBox2.Clear()

TextBox3.Clear() TextBox4.Clear() TextBox5.Clear() TextBox6.Clear() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Close() End Sub End Class

Este programa nos muestra un men y los precios de los productos y nos da el costo total del paquete o paquetes que seleccionemos.
Public Class Form1 Dim numpaquete As Integer Dim cantpaquete As Integer Dim costo As Integer Dim subtotal As Integer Dim descuento As Integer Dim total As Integer Dim porcentaje As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click numpaquete = TextBox1.Text Select Case (numpaquete) Case 1 costo = 40 Case 2 costo = 50 Case 3 costo = 70

End Select cantpaquete = TextBox2.Text subtotal = cantpaquete * costo TextBox3.Text = subtotal porcentaje = TextBox4.Text porcentaje = (subtotal * porcentaje) / 100 total = subtotal - porcentaje TextBox5.Text = total End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox5.Clear() End Sub End Class

Este programa nos suma la cantidad que seleccionemos a la cantidad que ingresemos.

Public Class Form1 Dim cantidad As Integer Dim resultado As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cantidad = TextBox1.Text If RadioButton1.Checked = True Then resultado = cantidad + 100 End If If RadioButton2.Checked = True Then resultado = cantidad + 200 End If TextBox2.Text = resultado End Sub End Class

Este programa nos hace la operacin dependiendo a la opcin que seleccionemos.

Public Class Form1 Dim cantidad1 As Decimal Dim cantidad2 As Decimal Dim resultado As Decimal Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cantidad1 = TextBox1.Text cantidad2 = TextBox2.Text If RadioButton1.Checked = True Then resultado = cantidad1 + cantidad2 End If If RadioButton2.Checked = True Then resultado = cantidad1 - cantidad2 End If If RadioButton3.Checked = True Then resultado = cantidad1 / cantidad2 End If If RadioButton4.Checked = True Then resultado = cantidad1 * cantidad2 End If TextBox3.Text = resultado End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() End Sub End Class

Este programa es un men sobre computadoras, dependiendo las opciones que seleccionemos nos dar el precio.

Public Class Form1 Dim total As Integer Dim memoria As Integer Dim procesador As Integer Dim hd As Integer Dim windows As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButton1.Checked = True Then memoria = 2000 End If If RadioButton2.Checked = True Then memoria = 3000 End If If RadioButton3.Checked = True Then memoria = 4000 End If If RadioButton4.Checked = True Then procesador = 3500 End If If RadioButton5.Checked = True Then procesador = 4000 End If If RadioButton6.Checked = True Then

procesador = 4500 End If If RadioButton7.Checked = True Then hd = 1500 End If If RadioButton8.Checked = True Then hd = 2500 End If If RadioButton9.Checked = True Then hd = 4000 End If If RadioButton10.Checked = True Then windows = 1000 End If If RadioButton11.Checked = True Then windows = 2000 End If If RadioButton12.Checked = True Then windows = 3000 End If total = memoria + procesador + hd + windows TextBox1.Text = total End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Private Sub PictureBox7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox7.Click End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Clear() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Close() End Sub Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click End Sub End Class

Este es un conversor de temperaturas, nos convierte la temperatura Celsius a Fahrenheit y viceversa.

Public Class Form1 Dim cen As Decimal Dim fare As Decimal

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click cen = TextBox1.Text fare = cen * 9 / 5 + 32 TextBox2.Text = fare 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.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear()

End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Close() End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click fare = TextBox3.Text cen = (fare - 32) * 5 / 9 TextBox4.Text = cen End Sub Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter End Sub End Class

You might also like