0% found this document useful (0 votes)
16 views2 pages

Examen Final - Ciclo 1

This document contains code for a student grade tracking application. It includes subroutines to clean fields, enable/disable fields, add a new student grade record, delete a student record, and handle button click events for initializing the form, adding a record, deleting a record, and closing the form. Fields are validated on adding to ensure required data is entered and the student does not already exist. When adding or deleting a record, the row numbers on the grade display grid are renumbered sequentially.

Uploaded by

Denis DH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Examen Final - Ciclo 1

This document contains code for a student grade tracking application. It includes subroutines to clean fields, enable/disable fields, add a new student grade record, delete a student record, and handle button click events for initializing the form, adding a record, deleting a record, and closing the form. Fields are validated on adding to ensure required data is entered and the student does not already exist. When adding or deleting a record, the row numbers on the grade display grid are renumbered sequentially.

Uploaded by

Denis DH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub limpiar()

txtalu.Text = ""
cmbasig.SelectedIndex = -1
txtn1.Text = ""
txtn2.Text = ""
txtalu.Focus()
End Sub
Sub habilitar(x As Boolean)
txtalu.Enabled = x
cmbasig.Enabled = x
txtn1.Enabled = x
txtn2.Enabled = x
End Sub
Sub pas()
txtn1.Focus()
End Sub
Sub agregar()
Dim alu, asig As String
Dim n1, n2, pro As Double
Dim i, f As Integer
Dim enalu As Boolean

alu = txtalu.Text
asig = cmbasig.SelectedItem
n1 = Val(txtn1.Text)
n2 = Val(txtn2.Text)

If (alu = "") Then


MsgBox("INGRESE ALUMNO")
txtalu.Focus()
Return
End If
If (asig = "" Or cmbasig.SelectedIndex = -1) Then
MsgBox("SELECIONE UNA ASIGNATURA")
Return
End If
If (n1 < 0 Or txtn1.Text = "") Then
MsgBox("INGRESE LA NOTA 1")
txtn1.Text = ""
txtn1.Focus()
Return
End If
If (n2 < 0 Or txtn2.Text = "") Then
MsgBox("INGRESE LA NOTA 2")
txtn2.Text = ""
txtn2.Focus()
Return
End If

enalu = False
For i = 0 To dgvcuadro.RowCount - 1 Step +1
If (Trim(alu) = Trim(dgvcuadro.Item(1, i).Value)) Then
enalu = True
End If
Next
If (enalu = True) Then
MsgBox("ALUMNO YA EXISTE EN LA PLANTILLA")
Call limpiar()
Else
pro = (n1 + n2) / 2
dgvcuadro.Rows.Add()
f = dgvcuadro.RowCount - 1
dgvcuadro.Item(0, f).Value = f + 1
dgvcuadro.Item(1, f).Value = alu
dgvcuadro.Item(2, f).Value = asig
dgvcuadro.Item(3, f).Value = pro.ToString
dgvcuadro.CurrentCell.Selected = False
End If
End Sub
Sub eliminar()
Dim f, i As Integer
If (dgvcuadro.RowCount = 0) Then
MsgBox("NO HAY FINAL")
Return
End If
If (dgvcuadro.CurrentCell.Selected = False) Then
MsgBox("SELECCIONE ALUMNO A ELIMINAR")
Return
End If
dgvcuadro.Rows.Remove(dgvcuadro.CurrentRow)
For i = 0 To dgvcuadro.RowCount - 1
dgvcuadro.Item(0, i).Value = i + 1
dgvcuadro.CurrentCell.Selected = False
Next
End Sub

Private Sub BTNNUEVO_Click(sender As Object, e As EventArgs) Handles BTNNUEVO.Click


Call habilitar(True)
Call limpiar()
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load


Call habilitar(False)
End Sub

Private Sub cmbasig_SelectedIndexChanged(sender As Object, e As EventArgs) Handles.


Call pas()
End Sub

Private Sub BTNAGREGAR_Click(sender As Object, e As EventArgs) Handles BTNAGREGAR.Click


Call agregar()
End Sub

Private Sub BTNELIMINAR_Click(sender As Object, e As EventArgs) Handles BTNELIMINAR.Click


Call eliminar()
End Sub

Private Sub BTNSALIR_Click(sender As Object, e As EventArgs) Handles BTNSALIR.Click


Close()
End Sub
End Class

You might also like