Visual Basic Curso
Visual Basic Curso
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
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
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
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
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