0% found this document useful (0 votes)
34 views

Visual Basic Curso

The document contains code for multiple sessions that define user interface elements and functions for calculating and displaying results. It includes: 1) Code for buttons that perform multiplication, division, and clear fields. It displays results and labels. 2) Code that calculates total price and price in dollars using a tax rate, clears fields, and focuses on elements. 3) Code that calculates averages from exam scores, displays results and conditions, and clears fields. 4) Code for login validation, hiding and showing forms, adding items to lists and combo boxes for course selection. 5) Additional code for form controls, calculations, validation and displaying consolidated student results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Visual Basic Curso

The document contains code for multiple sessions that define user interface elements and functions for calculating and displaying results. It includes: 1) Code for buttons that perform multiplication, division, and clear fields. It displays results and labels. 2) Code that calculates total price and price in dollars using a tax rate, clears fields, and focuses on elements. 3) Code that calculates averages from exam scores, displays results and conditions, and clears fields. 4) Code for login validation, hiding and showing forms, adding items to lists and combo boxes for course selection. 5) Additional code for form controls, calculations, validation and displaying consolidated student results.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Session 04

Private Sub btnmulti_Click(sender As Object, e As EventArgs) Handles btnmulti.Click


txtr.Text = Val(txtn1.Text) * Val(txtn2.Text)
lblr.Text = "La Multiplicacin es:"
btnnuevo.Visible = True
End Sub
Private Sub btndiv_Click(sender As Object, e As EventArgs) Handles btndiv.Click
txtr.Text = Val(txtn1.Text) / Val(txtn2.Text)
lblr.Text = "La Divisin es:"
btnnuevo.Visible = True
End Sub
Private Sub btnnuevo_Click(sender As Object, e As EventArgs) Handles btnnuevo.Click
txtn1.Text = ""
txtn2.Text = ""
txtr.Text = ""
lblr.Text = "Resultado"
txtn2.Visible = False
btnsuma.Enabled = False
btnresta.Enabled = False
btnmulti.Enabled = False
btndiv.Enabled = False
txtn1.Focus()
End Sub
Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles btnsalir.Click
MsgBox("Hasta la vista baby")
End
End Sub
Private Sub txtn2_TextChanged(sender As Object, e As EventArgs) Handles txtn2.TextChanged
btnsuma.Enabled = True
btnresta.Enabled = True
btnmulti.Enabled = True
btndiv.Enabled = True
End Sub

Session 05
Public Class Form1
Const TC As Double = 3.2
Private Sub btncalc_Click(sender As Object, e As EventArgs) Handles btncalc.Click
Dim CANT As Integer = Val(txtcant.Text)
Dim PU As Double = Val(txtprecuni.Text)
Dim PS As Double
PS = PU * CANT
txtprecsol.Text = PS
txtprecdol.Text = PS / TC
End Sub
Private Sub btnnuev_Click(sender As Object, e As EventArgs) Handles btnnuev.Click
txtnomp.Clear()
txtcant.Clear()
txtprecuni.Clear()
txtprecsol.Clear()
txtprecdol.Clear()
txtnomp.Focus()
End Sub
Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles btnsalir.Click
End
End Sub
End Class

Sesin 06
Public Class Form1
Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles btnsalir.Click
End
End Sub
Private Sub txtnomb_TextChanged(sender As Object, e As EventArgs) Handles txtnomb.TextChanged
End Sub
Private Sub btncalc_Click(sender As Object, e As EventArgs) Handles btncalc.Click
Dim E1 As Double = Val(txtexap.Text)
Dim E2 As Double = Val(txtexaf.Text)
Dim P As Double
P = (E1 + E2) / 2
txtprom.Text = P
If P >= 0 And P < 11 Then
txtcond.Text = "MALO"
ElseIf P >= 11 And P < 15 Then
txtcond.Text = "REGULAR"
ElseIf P >= 15 And P < 19 Then
txtcond.Text = "BUENO"
ElseIf P = 20 Then
txtcond.Text = "EXELENTE"
Else
txtcond.Text = ""
txtprom.Text = ""
End If
End Sub
Private Sub btnnuev_Click(sender As Object, e As EventArgs) Handles btnnuev.Click
txtnomb.Clear()
txtexap.Clear()
txtexaf.Clear()
txtprom.Clear()
txtcond.Clear()
txtnomb.Focus()
End Sub
Private Sub txtexap_TextChanged(sender As Object, e As EventArgs) Handles txtexap.TextChanged
If Not IsNumeric(txtexap.Text) Then
txtexap.Text = ""
txtexap.Focus()
End If
End Sub
Private Sub txtexaf_TextChanged(sender As Object, e As EventArgs) Handles txtexaf.TextChanged
If Not IsNumeric(txtexaf.Text) Then
txtexaf.Text = ""
txtexaf.Focus()
End If
End Sub
End Class

Public Class Form2


Private Sub btnsalir_Click(sender As Object, e As EventArgs) Handles btnsalir.Click
End
End Sub
Private Sub btncalc_Click(sender As Object, e As EventArgs) Handles btncalc.Click
Dim E1 As Double = Val(txtexap.Text)
Dim E2 As Double = Val(txtexaf.Text)
Dim P As Double
P = (E1 + E2) / 2
txtprom.Text = P
Select Case Math.Round(P)
Case 20
txtcond.Text = "Excelente"
Case 19, 18, 17, 16, 15
txtcond.Text = "Bueno"
Case 11 To 14
txtcond.Text = "Regular"
Case Is < 11
txtcond.Text = "Malo"
Case Else
txtcond.Text = "Error"
End Select
End Sub
Private Sub btnnuev_Click(sender As Object, e As EventArgs) Handles btnnuev.Click
txtnomb.Clear()
txtexap.Clear()
txtexaf.Clear()
txtprom.Clear()
txtcond.Clear()
txtnomb.Focus()
End Sub
End Class

Sesin 07
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btnSalir.Click
End
End Sub
Private Sub btnAcep_Click(sender As Object, e As EventArgs) Handles btnAcep.Click
Dim D, A, C, TP As String
If chkDes.Checked = True Then : D = "Desayuno"
Else : D = ""
End If
If chkAlm.Checked = True Then : A = "Almuerzo"
Else : A = ""
End If
If chkCen.Checked = True Then : C = "Cena"
Else : C = ""
End If
If rbtCont.Checked = True Then : TP = "Contado"
Else : TP = "Credito"
End If
lblServ.Text = "Ud seleccion " + D + " " + A + " " + C + " y su tipo de pago ser al " + TP
End Sub
Private Sub lblServ_Click(sender As Object, e As EventArgs) Handles lblServ.Click
End Sub
End Class

Sesin 08
Public Class Form1
'Abrev. del List.Box: "lst"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lstSigno.Items.Add("Aries")
lstSigno.Items.Add("Leo")
lstSigno.Items.Add("Tauro")
btnAgreg.Enabled = False

End Sub
Private Sub btnSalir_Click(sender As Object, e As EventArgs) Handles btnSalir.Click
End
End Sub
Private Sub btnAgreg_Click(sender As Object, e As EventArgs) Handles btnAgreg.Click
lstSigno.Items.Add(txtSigno.Text)
txtSigno.Text = ""
txtSigno.Focus()

End Sub
'para eliminar el item seleccionado del ListBox
Private Sub Eliminar_Click(sender As Object, e As EventArgs) Handles Eliminar.Click
lstSigno.Items.RemoveAt(lstSigno.SelectedIndex)
End Sub
Private Sub btnBorrar_Click(sender As Object, e As EventArgs) Handles btnBorrar.Click
lstSigno.Items.Clear()
End Sub
Private Sub lstSigno_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
lstSigno.SelectedIndexChanged
End Sub
Private Sub btnNext_Click(sender As Object, e As EventArgs) Handles btnNext.Click
Form2.Show()
Me.Hide()
End Sub
Private Sub txtSigno_TextChanged(sender As Object, e As EventArgs) Handles txtSigno.TextChanged
If Len(txtSigno.Text) > 0 Then
btnAgreg.Enabled = True
Else
btnAgreg.Enabled = False
End If
End Sub
End Class

Public Class Form2


'abrev. del comboBox: "cbo"
'Propiedad: DropDown >>> para cambiar la apariencia del objeto (comboBox)
'cambiar en <proyect> las propiedades del formulario para mostrar la 2da Form
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
cbo1.Items.Add("aries")
cbo1.Items.Add("Leo")
cbo1.Items.Add("Tauro")
cbo1.Items.Add("Geminis")
With cbo2.Items
.Add("Aries")
.Add("Leo")
End With
End Sub
Private Sub btnAnt_Click(sender As Object, e As EventArgs) Handles btnAnt.Click
'PARA MOSTRAR OTRO FORMULARIO:
SHOW
'PARA ESCONDER EL FORMULARIO
ACTUAL: "Me"...selecciona el formula en el
cual estoy trabajando
Me.Hide()
Form1.Show()
End Sub

Parcial
Public Class frmING
Private Sub btnCANC_Click(sender As Object, e As EventArgs) Handles btnCANC.Click
End
End Sub
Private Sub txtUsuario_TextChanged(sender As Object, e As EventArgs) Handles txtUsuario.TextChanged
If Len(txtUsuario.Text) > 0 Then
txtPass.Enabled = True
End If
End Sub
Private Sub btnING_Click(sender As Object, e As EventArgs) Handles btnING.Click
If txtPass.Text = "parcial" And txtUsuario.Text = "eleazar" Then
frmFORM.Show()
Me.Hide()
Else
txtUsuario.Text = ""
txtUsuario.Focus()
txtPass.Clear()
txtPass.Enabled = False
End If
End Sub
End Class

Public Class frmFORM


Private Sub btnSalir_Click(sender As Object, e As EventArgs) Handles btnSalir.Click
MsgBox("Estas Seguro?")
End
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lstCurso.Items
.Add("Calculo")
.Add("Lenguaje")
.Add("Historia")
.Add("Estadistica")
End With
With cboEspec.Items
.Add("Administracin")
.Add("Contabilidad")
.Add("Finanzas")
.Add("Marketing")
End With
End Sub
Private Sub btnConsolidado_Click(sender As Object, e As EventArgs) Handles btnConsolidado.Click
txtAlumno.Text = txtAp.Text + " " + txtNomb.Text
txtLlevC.Text = lstCurso.SelectedItem
Dim N1 As Double = Val(txtP1.Text), N2 As Double = Val(txtP2.Text), N3 As Double =
Val(txtEP.Text), N4 As Double = Val(txtEF.Text)
Dim P As Double
P = (N1 + N2 + N3 + N4) / 4
txtTenProm.Text = Math.Round(P)
If P >= 13 And P <= 20 Then
txtOBS.Text = "Aprobado"
Else

txtOBS.Text = "Desaprobado"
End If
btnNuev.Enabled = True

End Sub
Private Sub btnNuev_Click(sender As Object, e As EventArgs) Handles btnNuev.Click
txtAp.Text = ""
txtNomb.Text = ""
txtDir.Text = ""
lstCurso.SelectedIndex = False
txtP1.Text = ""
txtP2.Text = ""
txtEP.Text = ""
txtEF.Text = ""
txtAlumno.Text = ""
txtLlevC.Text = ""
txtTenProm.Text = ""
txtOBS.Text = ""
txtAp.Focus()
btnNuev.Enabled = False
lstCurso.Enabled = False
btnConsolidado.Enabled = False
GroupBox1.Enabled = False
txtNomb.Enabled = False
cboEspec.Enabled = False
lstCurso.Items.Clear()
With lstCurso.Items
.Add("Calculo")
.Add("Lenguaje")
.Add("Historia")
.Add("Estadistica")
End With
End Sub
Private Sub cboEspec_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
cboEspec.SelectedIndexChanged
If Len(cboEspec.Text) > 0 Then
lstCurso.Enabled = True
End If
End Sub
Private Sub lstCurso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
lstCurso.SelectedIndexChanged
If Len(lstCurso.Text) > 0 Then
GroupBox1.Enabled = True
End If
End Sub
Private Sub txtP1_TextChanged(sender As Object, e As EventArgs) Handles txtP1.TextChanged
If Not IsNumeric(txtP1.Text) Then
txtP1.Text = ""
txtP1.Focus()
End If
End Sub
Private Sub txtP2_TextChanged(sender As Object, e As EventArgs) Handles txtP2.TextChanged
If Not IsNumeric(txtP2.Text) Then
txtP2.Text = ""
txtP2.Focus()
End If
End Sub

Private Sub txtEP_TextChanged(sender As Object, e As EventArgs) Handles txtEP.TextChanged


If Not IsNumeric(txtEP.Text) Then
txtEP.Text = ""
txtEP.Focus()
End If
End Sub
Private Sub txtEF_TextChanged(sender As Object, e As EventArgs) Handles txtEF.TextChanged
If Not IsNumeric(txtEF.Text) Then
txtEF.Text = ""
txtEF.Focus()
End If
If Len(txtEF.Text) > 0 Then
btnConsolidado.Enabled = True
End If
End Sub
Private Sub txtAp_TextChanged(sender As Object, e As EventArgs) Handles txtAp.TextChanged
If Len(txtAp.Text) > 0 Then
txtNomb.Enabled = True
End If
End Sub
Private Sub txtNomb_TextChanged(sender As Object, e As EventArgs) Handles txtNomb.TextChanged
If Len(txtNomb.Text) > 0 Then
cboEspec.Enabled = True
End If
End Sub

End Class

Session 10
Public Class Form1
Private Sub chkMostrar_CheckedChanged(sender As Object, e As EventArgs) Handles
chkMostrar.CheckedChanged
If chkMostrar.Checked = True Then
picImag.Visible = True
Else
picImag.Visible = False
End If
End Sub
Private Sub cboImag_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
cboImag.SelectedIndexChanged
Select Case cboImag.SelectedIndex
Case 0
picImag.Image = My.Resources.Mickey
Case 1
picImag.Image = My.Resources.Minnie
Case 2
picImag.Image = My.Resources.Pluto
Case 3
picImag.Image = My.Resources.Simba
Case 4
picImag.Image = My.Resources.Tribilin
End Select
End Sub
Private Sub btnSalir_Click(sender As Object, e As EventArgs) Handles btnSalir.Click
Dim M As DialogResult
M = MessageBox.Show("Estas Seguro?", "AVISO", MessageBoxButtons.YesNo,
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
If M = DialogResult.Yes Then
End
End If
End Sub
End Class

You might also like