Vous êtes sur la page 1sur 29

ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO

DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA1

Public Class Form1

Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click


Dim nota1, nota2, nota3, puntos, promedio As Single
nota1 = Single.Parse(txtnota1.Text)
nota2 = Single.Parse(txtnota2.Text)
nota3 = Single.Parse(txtnota3.Text)
puntos = nota1 + nota2 + nota3
promedio = puntos / 3
txtpuntos.Text = puntos.ToString
txtpromedio.Text = promedio.ToString("##0.00")
If promedio > 10.5 Then
txtpromedio.ForeColor = Color.Blue
Else
txtpromedio.ForeColor = Color.Red
End If

End Sub
End Class
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA2 (validación)

Public Class Form2


Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click
If txtalumno.Text.Trim <> "" And IsNumeric(txtnota1.Text) And IsNumeric(txtnota2.Text) And IsNumeric(txtnota3.Text) Then
Dim nota1, nota2, nota3, puntos, promedio As Single
nota1 = Single.Parse(txtnota1.Text)
nota2 = Single.Parse(txtnota2.Text)
nota3 = Single.Parse(txtnota3.Text)
If nota1 < 0 Or nota1 > 20 Then
MessageBox.Show("ingrese la nota N° 01 entre 0 y 20", "por favor", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtnota1.Text = ""
txtnota1.Focus()
Exit Sub
End If
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
If nota2 < 0 Or nota2 > 20 Then
MessageBox.Show("ingrese la nota N° 02 entre 0 y 20", "por favor", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtnota2.Text = ""
txtnota2.Focus()
Exit Sub
End If
If nota3 < 0 Or nota3 > 20 Then
MessageBox.Show("ingrese la nota N° 02 entre 0 y 20", "por favor", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtnota3.Text = ""
txtnota3.Focus()
Exit Sub
End If
puntos = nota1 + nota2 + nota3
promedio = puntos / 3
lblpuntos.Text = puntos.ToString
lblpromedio.Text = promedio.ToString
If promedio > 10.5 Then
lblpromedio.ForeColor = Color.Blue
Else
lblpromedio.ForeColor = Color.Red

End If

Else
MsgBox("verifique los datos a ingresar")
lblpuntos.Text = ""
lblpromedio.Text = ""
txtalumno.Focus()
End If

End Sub
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET

Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnuevo.Click


txtalumno.Text = ""
txtnota1.Text = ""
txtnota2.Text = ""
txtnota3.Text = ""
lblpuntos.Text = ""
lblpromedio.Text = ""
txtalumno.Focus()
End Sub

Private Sub btncerrar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncerrar.Click


End
End Sub
Private Sub txtalumno_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtalumno.KeyPress
If Asc(e.KeyChar) = 13 Then
txtnota1.Enabled = True
txtnota1.Focus()
End If
End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


DESACTIVAR()
End Sub
Private Sub DESACTIVAR()
txtnota1.Enabled = False
txtnota2.Enabled = False
txtnota3.Enabled = False
End Sub

Private Sub txtnota1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnota1.KeyPress


ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
If Asc(e.KeyChar) = 13 Then
txtnota2.Enabled = True
txtnota2.Focus()
End If
End Sub

Private Sub txtnota2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnota2.KeyPress


If Asc(e.KeyChar) = 13 Then
txtnota3.Enabled = True
txtnota3.Focus()
End If
End Sub

Private Sub txtnota3_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnota3.KeyPress


If Asc(e.KeyChar) = 13 Then
btncalcular.Focus()
End If
End Sub

End Class
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 3

Maxlenght 2

Public Class Form1


Private Sub txtnombre_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnombre.KeyPress
If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then
e.Handled = True
End If
'keychar=Obtiene el caracter correspondiente a la tecla
'handled=controla el evento de keychar
End Sub
Private Sub txtedad_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtedad.KeyPress
If (Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
'If (Asc(e.KeyChar) > 1 And Asc(e.KeyChar) < 8 And Asc(e.KeyChar) > 8 And Asc(e.KeyChar) < 48) Or Asc(e.KeyChar) > 57 Then
e.Handled = True
'End If
End Sub
Private Sub txtsexo_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtsexo.KeyPress
If Asc(e.KeyChar) <> 102 And Asc(e.KeyChar) <> 109 And Asc(e.KeyChar) <> 70 And Asc(e.KeyChar) <> 77 Then
e.Handled = True
End If
End Sub
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 4

Timer1 lblreloj
Propiedades
Enabled=true
Interval=1000 1 segundo
lblmarco
Timer2
Propiedades lbltitulo
Enabled=true
Interval=2000 2 segundo

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

lblreloj.Text = TimeString
'TimeString devuelve siempre la hora del sistema como "HH:mm:ss", que es un formato de 24 horas.
'Este formato es independiente de la referencia cultural, es decir, no cambia aunque cambie la
'Configuración regional en el Panel de control.

End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

lblmarco.Visible = Not lblmarco.Visible

End Sub
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 5

Public Class frminicio


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Value = ProgressBar1.Value + 2
If ProgressBar1.Value <= 30 Then
lblinforme.Text = "Inicializando....."
ElseIf ProgressBar1.Value <= 50 Then
lblinforme.Text = "Leyendo componentes....."
ElseIf ProgressBar1.Value <= 70 Then
lblinforme.Text = "Integrando la Base de datos...."
ElseIf ProgressBar1.Value <= 100 Then
lblinforme.Text = "Por Favor Espere..."
End If
If ProgressBar1.Value = 100 Then
If Timer1.Interval >= 1 Then
Timer1.Enabled = False
Dim principal As New frmclave
Me.Hide()
principal.ShowDialog()
End If
End If
End Sub

Private Sub frminicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


Timer1.Enabled = True
End Sub
End Class
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 6
Control: Imagelist( Componentes) Control: ToolBar(Elegir Elementos)

Propiedad:
• Buttons
• Imagelist

Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles


ToolBar1.ButtonClick
Select Case ToolBar1.Buttons.IndexOf(e.Button)
Case 0
'Codigo Item Mostrar Formulario
Dim Formulario2 As New Form1
Formulario2.MdiParent = Me
Formulario2.Show()
Case 1
'Codigo Item Mostrar Formulario
Dim Formulario3 As New frminicio
Formulario3.MdiParent = Me
Formulario3.Show()
Case 2
Msgbox(“practica3”) ‘MdiParent=para identificar que es un formulario secundario
End Select
End Sub
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 7
Control: PictureBox

Propiedad : SizeMode txtuser

- stretchimage: El tamaño de la imagen


se ajusta al tamaño que se ha dibujado.
txtclave

Public Class frmclave


Private Sub Timer1_Tick(ByVal sender........................
ProgressBar1.Value = ProgressBar1.Value + 2
If ProgressBar1.Value = 100 Then
Timer1.Enabled = False
Dim principal As New Form3 ( mostrar el formulario menu)
principal.ShowDialog()
Close()
End If
End Sub
Private Sub frmclave_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
End Sub
Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click
If txtuser.Text.Trim = "user01" And txtClave.Text.Trim = "123" Then
Timer1.Enabled = True
Else
MessageBox.Show("Acceso Incorrecto", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtClave.Clear() : txtClave.Focus()
End If ....... End Sub ……… End Class
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
PRACTICA 8

DropDownHeight: Cambia el tamaño de


la Lista, 106 es el valor normal

DropDownStyle: Cambia la forma como


se fuera un texto, ejemplo simple

Public Class Form4


Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'llenar cuadro color de texto
'Me.ComboBox1.Items.Add("Rojo")
'Me.ComboBox1.Items.Add("Verde")
'Me.ComboBox1.Items.Add("Azul")
'Me.ComboBox1.Items.Add("Amarillo")
'Me.ComboBox1.Items.Add("Negro")
'esto de arriba se puede cambiar y ahorrar codigo con esto
With Me.ComboBox1.Items
.Add("Rojo")
.Add("Verde")
.Add("Azul")
.Add("Amarillo")
.Add("Negro")
End With
'llenar cuadro color fondo
With Me.ComboBox2.Items
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
.Add("Rojo")
.Add("Verde")
.Add("Azul")
.Add("Amarillo")
.Add("Negro")
End With
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


‘cada selección de un index se va cambiando su index es el metodo
Select Case Me.ComboBox1.SelectedIndex
Case 0 : Me.TextBox1.ForeColor = Color.Red ‘rojo
Case 1 : Me.TextBox1.ForeColor = Color.Green ‘verde
Case 2 : Me.TextBox1.ForeColor = Color.Blue ‘azul
Case 3 : Me.TextBox1.ForeColor = Color.Yellow ‘amarillo
Case 4 : Me.TextBox1.ForeColor = Color.Black ‘negro
End Select
End Sub

Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged


Select Case Me.ComboBox2.SelectedIndex
Case 0 : Me.TextBox1.BackColor = Color.Red
Case 1 : Me.TextBox1.BackColor = Color.Green
Case 2 : Me.TextBox1.BackColor = Color.Blue
Case 3 : Me.TextBox1.BackColor = Color.Yellow
Case 4 : Me.TextBox1.BackColor = Color.Black
End Select
End Sub
End Class
PRACTICA 9
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET

Public Class Form2


Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click
Dim sumpar As Integer
Select Case Me.cmbcodigo.SelectedItem
Case "Nivel A"
sumpar = CType(txthoras.Text, Integer) * CType(txtpago.Text, Integer) + 5000
Select Case Me.lsthijos.SelectedIndex
Case "0"
txttotal.Text = sumpar + 50
Case "1"
txttotal.Text = sumpar + 100
Case "2"
txttotal.Text = sumpar + 150
Case "3"
txttotal.Text = sumpar + 200
Case "4"
txttotal.Text = sumpar + 250
Case "5"
txttotal.Text = sumpar + 300
End Select
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Case "Nivel B"
sumpar = CType(txthoras.Text, Integer) * CType(txtpago.Text, Integer) + 3500
Select Case Me.lsthijos.SelectedIndex
Case "0"
txttotal.Text = sumpar + 50

Case "1"
txttotal.Text = sumpar + 100
Case "2"
txttotal.Text = sumpar + 150
Case "3"
txttotal.Text = sumpar + 200
Case "4"
txttotal.Text = sumpar + 250
Case "5"
txttotal.Text = sumpar + 300
End Select
Case "Nivel C"
sumpar = CType(txthoras.Text, Integer) * CType(txtpago.Text, Integer) + 4300
Select Case Me.lsthijos.SelectedIndex
Case "0"
txttotal.Text = sumpar + 50
Case "1"
txttotal.Text = sumpar + 100
Case "2"
txttotal.Text = sumpar + 150
Case "3"
txttotal.Text = sumpar + 200
Case "4"
txttotal.Text = sumpar + 250
Case "5"
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
txttotal.Text = sumpar + 300
End Select
End Select
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.cmbcodigo.SelectedIndex = 0
Me.lsthijos.SelectedIndex = 0
With Me.cmbtexto.Items
.Add("rojo")
.Add("verde")
.Add("azul")
.Add("Amarillo")
.Add("Negro")
End With

With Me.cmbfondo.Items
.Add("rojo")
.Add("verde")
.Add("azul")
.Add("Amarillo")
.Add("Negro")
End With
End Sub
Private Sub cmbtexto_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbtexto.SelectedIndexChanged
Select Case Me.cmbtexto.SelectedItem
Case "rojo"
Me.txtnombres.ForeColor = Color.Red
Me.txthoras.ForeColor = Color.Red
Me.txtpago.ForeColor = Color.Red
Me.txttotal.ForeColor = Color.Red
Me.cmbcodigo.ForeColor = Color.Red
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Me.cmbfondo.ForeColor = Color.Red
Me.lsthijos.ForeColor = Color.Red
Me.cmbtexto.ForeColor = Color.Red
Case "verde"
Me.txtnombres.ForeColor = Color.Green
Me.txthoras.ForeColor = Color.Green
Me.txtpago.ForeColor = Color.Green
Me.txttotal.ForeColor = Color.Green
Me.cmbcodigo.ForeColor = Color.Green
Me.cmbfondo.ForeColor = Color.Green
Me.lsthijos.ForeColor = Color.Green
Me.cmbtexto.ForeColor = Color.Green
Case "azul"
Me.txtnombres.ForeColor = Color.Blue
Me.txthoras.ForeColor = Color.Blue
Me.txtpago.ForeColor = Color.Blue
Me.txttotal.ForeColor = Color.Blue
Me.cmbcodigo.ForeColor = Color.Blue
Me.cmbfondo.ForeColor = Color.Blue
Me.lsthijos.ForeColor = Color.Blue
Me.cmbtexto.ForeColor = Color.Blue

Case "Amarillo"
Me.txtnombres.ForeColor = Color.Yellow
Me.txthoras.ForeColor = Color.Yellow
Me.txtpago.ForeColor = Color.Yellow
Me.txttotal.ForeColor = Color.Yellow
Me.cmbcodigo.ForeColor = Color.Yellow
Me.cmbfondo.ForeColor = Color.Yellow
Me.lsthijos.ForeColor = Color.Yellow
Me.cmbtexto.ForeColor = Color.Yellow
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Case "Negro"
Me.txtnombres.ForeColor = Color.Black
Me.txthoras.ForeColor = Color.Black
Me.txtpago.ForeColor = Color.Black
Me.txttotal.ForeColor = Color.Black
Me.cmbcodigo.ForeColor = Color.Black
Me.cmbfondo.ForeColor = Color.Black
Me.lsthijos.ForeColor = Color.Black
Me.cmbtexto.ForeColor = Color.Black
End Select
End Sub
Private Sub cmbfondo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbfondo.SelectedIndexChanged
Select Case Me.cmbfondo.SelectedItem
Case "rojo"
Me.txtnombres.BackColor = Color.Red
Me.txthoras.BackColor = Color.Red
Me.txtpago.BackColor = Color.Red
Me.txttotal.BackColor = Color.Red
Me.cmbcodigo.BackColor = Color.Red
Me.cmbfondo.BackColor = Color.Red
Me.cmbtexto.BackColor = Color.Red
Case "verde"
Me.txtnombres.BackColor = Color.Green
Me.txthoras.BackColor = Color.Green
Me.txtpago.BackColor = Color.Green
Me.txttotal.BackColor = Color.Green
Me.cmbcodigo.BackColor = Color.Green
Me.cmbfondo.BackColor = Color.Green
Me.lsthijos.BackColor = Color.Green
Me.cmbtexto.BackColor = Color.Green
Case "azul"
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Me.txtnombres.BackColor = Color.Blue
Me.txthoras.BackColor = Color.Blue
Me.txtpago.BackColor = Color.Blue
Me.txttotal.BackColor = Color.Blue
Me.cmbcodigo.BackColor = Color.Blue
Me.cmbfondo.BackColor = Color.Blue
Me.lsthijos.BackColor = Color.Blue
Me.cmbtexto.BackColor = Color.Blue
Case "Amarillo"
Me.txtnombres.BackColor = Color.Yellow
Me.txthoras.BackColor = Color.Yellow
Me.txtpago.BackColor = Color.Yellow
Me.txttotal.BackColor = Color.Yellow
Me.cmbcodigo.BackColor = Color.Yellow
Me.cmbfondo.BackColor = Color.Yellow
Me.lsthijos.BackColor = Color.Yellow
Me.cmbtexto.BackColor = Color.Yellow
Case "Negro"
Me.txtnombres.BackColor = Color.Black
Me.txthoras.BackColor = Color.Black
Me.txtpago.BackColor = Color.Black
Me.txttotal.BackColor = Color.Black
Me.cmbcodigo.BackColor = Color.Black
Me.cmbfondo.BackColor = Color.Black
Me.lsthijos.BackColor = Color.Black
Me.cmbtexto.BackColor = Color.Black
End Select
End Sub
End Class
PRACTICA 10
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Public Class Form1
Private Sub btnagregar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnagregar.Click, btneliminar.Click, btnsalir.Click,
btneliminartodo.Click
Dim Boton As Button
Boton = CType(sender, Button)
Select Case Boton.Name
Case "btnagregar"
If IsNumeric(txtelemento.Text) Then
lstelemento.Items.Add(txtelemento.Text.Trim)
Me.txtelemento.Text = ""
Me.txtelemento.Focus()
Else
MsgBox("Ingrese un numero")
Me.txtelemento.Text = ""
Me.txtelemento.Focus()
End If
Case "btneliminar"
If lstelemento.SelectedIndex <> -1 Then
lstelemento.Items.Remove(lstelemento.SelectedItem)
End If
Case "btneliminartodo"
lstelemento.Items.Clear()
Case "btnsalir"
End

End Select

End Sub

PRACTICA 11
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET

Public Class FrmCurso

Private Sub rbnJava_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbnJava.CheckedChanged,


rbnCs.CheckedChanged, rbnVBnet.CheckedChanged

Dim Boton As RadioButton


Boton = CType(sender, RadioButton)
Select Case Boton.Name
Case "rbnJava"
'txtPagoxHora.Text = sender.tag
txtPagoxHora.Text = "30,00"
'If txtcostocurso.Text <> "" Then
' txtcostocurso.Text = (Decimal.Parse(txtPagoxHora.Text) * Integer.Parse(txtnrohora.Text)).ToString
'End If
txtnrohora.Focus()
Case "rbnVBnet"
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
'txtPagoxHora.Text = sender.tag
txtPagoxHora.Text = "22,00"
'If txtcostocurso.Text <> "" Then
' txtcostocurso.Text = (Decimal.Parse(txtPagoxHora.Text) * Integer.Parse(txtnrohora.Text)).ToString
'End If
txtnrohora.Focus()
Case "rbnCs"
'txtPagoxHora.Text = sender.tag
txtPagoxHora.Text = "25,00"
'If txtcostocurso.Text <> "" Then
' txtcostocurso.Text = (Decimal.Parse(txtPagoxHora.Text) * Integer.Parse(txtnrohora.Text)).ToString
'End If
txtnrohora.Focus()
End Select
End Sub

Private Sub txtnrohora_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtnrohora.TextChanged


If txtnrohora.Text <> "" Then
txtcostocurso.Text = (Decimal.Parse(txtPagoxHora.Text) * Integer.Parse(txtnrohora.Text)).ToString
Else
txtcostocurso.Clear()
End If
End Sub

Private Sub chkCD_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkCD.CheckedChanged


If chkCD.Checked = True Then
txtCostocd.Text = "10,00"
Else
txtCostocd.Text = "0,0"
End If
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
End Sub

Private Sub chkManual_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkManual.CheckedChanged


If chkManual.Checked = True Then
txtManual.Text = "15,00"
Else
txtManual.Text = "0,0"
End If
End Sub

Private Sub btnCalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalcular.Click


txtTotal.Text = (Decimal.Parse(txtcostocurso.Text) + Decimal.Parse(txtCostocd.Text) + Decimal.Parse(txtManual.Text)).ToString("n2")
End Sub

Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click

chkCD.Checked = False
chkManual.Checked = False
rbnJava.Checked = False
rbnVBnet.Checked = False
rbnCs.Checked = False
txtPagoxHora.Clear()
txtnrohora.Clear()
txtcostocurso.Clear()
txtCostocd.Clear()

End Sub

PRACTICA 12
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET

Public Class mayusminuscant


Private Sub btnmayus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmayus.Click
txtmayusculas.Enabled = True
txtmayusculas.Text = txttexto.Text.ToUpper
End Sub

Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click


txtminusculas.Enabled = True
txtminusculas.Text = txttexto.Text.ToLower
End Sub

Private Sub btninvertir_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btninvertir.Click


txtinvertido.Enabled = True
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
txtinvertido.Text = Strings.StrReverse(txttexto.Text)
End Sub

Private Sub btntitulo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntitulo.Click


txttitulo.Enabled = True
txttitulo.Text = Strings.StrConv(txttexto.Text, VbStrConv.ProperCase)
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


txtprimercarac.Enabled = True
txtprimercarac.Text = Microsoft.VisualBasic.Left(Trim(Me.txttexto.Text), 1)
txtultimocarac.Enabled = True
txtultimocarac.Text = Microsoft.VisualBasic.Right(Trim(Me.txttexto.Text), 1)
txt2a6carac.Enabled = True
txt2a6carac.Text = Microsoft.VisualBasic.Mid(Trim(Me.txttexto.Text), 2, 5)
txtpos1a.Enabled = True
txtpos1a.Text = InStr(Me.txttexto.Text, "a")
txtnummos.Enabled = True
txtnummos.Text = txttexto.Text.Length
End Sub

Private Sub btnsalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsalir.Click


End
End Sub

Private Sub btnnuevo_Click(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

Private Sub btnlimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlimpiar.Click


ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
txttexto.Clear() : txtminusculas.Clear() : txtminusculas.Enabled = False : txtmayusculas.Clear()
txtmayusculas.Enabled = False : txtinvertido.Clear() txtinvertido.Enabled = False : txtnummos.Clear()
txtnummos.Enabled = False : txtpos1a.Clear() txtpos1a.Enabled = False txtprimercarac.Clear()
txtprimercarac.Enabled = False txtultimocarac.Clear() txtultimocarac.Enabled = False txttitulo.Clear()
txttitulo.Enabled = False txt2a6carac.Clear() txt2a6carac.Enabled = False txtnummos.Clear()
txtnummos.Enabled = False
End Sub
Private Sub txttexto_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txttexto.TextChanged
txtminusculas.Clear()
txtminusculas.Enabled = False
txtmayusculas.Clear()
txtmayusculas.Enabled = False
txtinvertido.Clear()
txtinvertido.Enabled = False
txtnummos.Clear()
txtnummos.Enabled = False
txtpos1a.Enabled = False
txtprimercarac.Clear()
txtprimercarac.Enabled = False
txtultimocarac.Clear()
txtultimocarac.Enabled = False
txttitulo.Clear()
txttitulo.Enabled = False
txt2a6carac.Clear()
txt2a6carac.Enabled = False
txtnummos.Clear()
txtnummos.Enabled = False
End Sub
End Class
EL CONTROL CHECKBOX
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Este control permite indicar dentro de una aplicación si algo es verdad o falso mediante una casilla de verificación que tiene este control.

Public Class Form1


Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click
calcular()
NumericUpDown
End Sub
Private Sub calcular()
Decimalplaces 2
Dim deuda, descuento, total As Decimal
Increment 10
'deuda = Decimal.Parse(nuddeuda.Value)
Maximun 10000
deuda = nuddeuda.Value
Minimun 1
If chkdescuento.Checked = True Then
descuento = deuda * 10 / 100
Else
descuento = 0
End If
total = deuda - descuento
lbldescuento.Text = descuento.ToString("###,##0.00#")
lbltotal.Text = total.ToString("###,##0.00#")
End Sub
End Class

EL CONTROL RADIOBUTTON
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Este control permite seleccionar dentro de una aplicación sólo una de un grupo de Opciones. Cada opción disponible para el usuario
en un control radiobutton y cada Grupo de opciones deben estar dentro de un control GroupBox.

Public Class Form2


Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click
Dim pension, descuento, pago As Decimal
'pregunta el nivel de la matricula
If rbinicial.Checked = True Then
pension = 80
ElseIf rbprimaria.Checked = True Then
If rbmañana.Checked = True Then
pension = 100
ElseIf rbtarde.Checked = True Then
pension = 120
ElseIf rbnoche.Checked = True Then
pension = 90
Else
MsgBox("seleccione el turno", MsgBoxStyle.Critical, "por favor")
End If
ElseIf rbsecundaria.Checked = True Then
If rbmañana.Checked = True Then
pension = 160
ElseIf rbtarde.Checked = True Then
pension = 140
ElseIf rbnoche.Checked = True Then
pension = 110
Else
MsgBox("seleccione el turno", MsgBoxStyle.Critical, "por favor")
End If
Else
MsgBox("seleccione el Nivel", MsgBoxStyle.Critical, "por favor")
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET
Exit Sub
End If
If chkdescuento.Checked = True Then
descuento = pension * 20 / 100
Else
descuento = 0
End If
pago = pension - descuento
lblpension.Text = pension.ToString("###,##0.00")
lbldescuento.Text = descuento.ToString("###,##0.00")
lblpago.Text = pago.ToString("###,##0.00")
End Sub
Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnuevo.Click
txtnombres.Clear() : txtapellidos.Clear() : rbinicial.Checked = False : rbprimaria.Checked = False
rbsecundaria.Checked = False : rbmañana.Checked = False : rbtarde.Checked = False : rbnoche.Checked = False
chkdescuento.Checked = False : lblpension.Text = "" : lbldescuento.Text = "" : lblpago.Text = "" : txtnombres.Focus()
End Sub
Private Sub btnsalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsalir.Click
Close()
End Sub
End Class
ESCUELA DE CAPACITACION Y PERFECCIONAMIENTO
DE LA FUERZA AEREA DEL PERU

VISUAL BASIC.NET

Vous aimerez peut-être aussi