Este programa almacena datos de dferentes personas (alumnos) y los guarda en una posicion de memoria, necesito que cuando yo elimine a una persona los datos que se proporcionan tienen que desaparecer por completo, por ejemplo:
1.-Luis
2.-Eduardo
3.-Carlos
4.-Martín
Eliminando a la carlos:
1.-Luis
2.-Eduardo
4.-Martín
Creo que quedaria más claro si les muestro el codigo:
Código
Option Compare Text Public Class frmAlumnos Dim alumnos(4, 8) As String Dim i, t, pos As Byte Dim sexo As String Private Sub btnEliminar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminar.Click 'QUIERO ESTE CODIGO POR FAVOoOoR!!!!!! End Sub Private Sub frmAlumnos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DomainUpDown1.Items.Add("Computación e informatica") Me.DomainUpDown1.Items.Add("Secretariado ejecutivo") Me.DomainUpDown1.Items.Add("Contabilidad") Me.DomainUpDown1.Items.Add("Electricidad") Me.DomainUpDown1.Items.Add("Electronica") Me.DomainUpDown1.Items.Add("Construcción civil") Me.NumericUpDown1.Minimum = 0 : Me.NumericUpDown1.Maximum = 6 Me.NumericUpDown1.ReadOnly = True HabilitaControles(False) : HabilitaBotones(True) End Sub Private Sub limpiar() Dim micontrol As Object For Each micontrol In Me.Controls If TypeOf micontrol Is TextBox Then micontrol.text = "" If TypeOf micontrol Is RadioButton Then micontrol.checked = False If TypeOf micontrol Is DomainUpDown Then _ micontrol.text = "Seleccione una especialidad" If TypeOf micontrol Is NumericUpDown Then micontrol.Value = 1 Next End Sub Private Sub HabilitaControles(ByVal Estado As Boolean) Dim micontrol As Object For Each micontrol In Me.Controls If TypeOf micontrol Is TextBox Then micontrol.enabled = Estado If TypeOf micontrol Is RadioButton Then micontrol.enabled = Estado If TypeOf micontrol Is DomainUpDown Then micontrol.enabled = Estado If TypeOf micontrol Is NumericUpDown Then micontrol.enabled = Estado Next End Sub Private Sub HabilitaBotones(ByVal sw As Boolean) btnNuevo.Enabled = sw btnGuardar.Enabled = Not sw btnEditar.Enabled = sw btnCancelar.Enabled = Not sw btnEliminar.Enabled = sw btnBuscar.Enabled = sw btnSalir.Enabled = sw End Sub Private Sub RbtnMasculino_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RbtnMasculino.CheckedChanged Select Case sender.name Case "rbtMasculino" sexo = "Masculino" Case Else sexo = "Femenino" End Select End Sub Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click If i = 5 Then MsgBox("ya no se puede agregar más alumnos...") btnPrimero.PerformClick() Else limpiar() txtCodigo.Text = Format(i + 1, "00000") HabilitaControles(True) HabilitaBotones(False) End If End Sub Private Sub btnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuardar.Click If txtApellidos.Text = "" Or txtNombres.Text = "" Then MsgBox("debe ingresar nombres y apellidos", MsgBoxStyle.Critical, "Error") Exit Sub End If alumnos(i, 0) = txtCodigo.Text alumnos(i, 1) = txtApellidos.Text alumnos(i, 2) = txtNombres.Text alumnos(i, 3) = txtDireccion.Text alumnos(i, 4) = sexo alumnos(i, 5) = txtTelefono.Text alumnos(i, 6) = DomainUpDown1.SelectedItem alumnos(i, 7) = NumericUpDown1.Value alumnos(i, 8) = txtEmail.Text t = i i += 1 btnPrimero.PerformClick() HabilitaControles(False) HabilitaBotones(True) End Sub Private Sub btnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditar.Click Me.HabilitaControles(True) Me.txtApellidos.Focus() HabilitaBotones(False) End Sub Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click HabilitaBotones(True) btnPrimero.PerformClick() End Sub Private Sub btnBuscar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBuscar.Click Dim codi As String Dim x As Integer codi = InputBox("Ingrese codigo del alumno a buscar") For x = 0 To i - 1 If codi = alumnos(x, 0) Then pos = x mostrardatos() Exit Sub End If Next MsgBox("Código no existe", MsgBoxStyle.Critical, "Error") End Sub Private Sub mostrardatos() txtCodigo.Text = alumnos(pos, 0) txtApellidos.Text = alumnos(pos, 1) txtNombres.Text = alumnos(pos, 2) txtDireccion.Text = alumnos(pos, 3) If alumnos(pos, 4) = "masculino" Then RbtnMasculino.Checked = True Else RbtnFemenino.Checked = True End If txtTelefono.Text = alumnos(pos, 5) DomainUpDown1.SelectedItem = alumnos(pos, 6) NumericUpDown1.Value = alumnos(pos, 7) txtEmail.Text = alumnos(pos, 8) End Sub Private Sub btnPrimero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrimero.Click pos = 0 mostrardatos() End Sub Private Sub btnUltimo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUltimo.Click pos = t mostrardatos() End Sub Private Sub btnAnterior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnterior.Click If pos > 0 Then pos = pos - 1 mostrardatos() End If End Sub Private Sub btnSiguiente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSiguiente.Click If pos < t Then pos = pos + 1 mostrardatos() End If End Sub Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click Me.Close() End Sub Private Sub btnMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click frmMain.Show() Me.Hide() End Sub End Class
Pueden ver el programa aqui:
http://www.jlponce.co.cc/descargas/GUIA%20N3%20NET1%202009.pdf
1.4 CREACIÓN DEL FORMULARIO REGISTRO DE ALUMNOS (FRMALUMNOS.VB)
Gracias por su ayuda!!!!
Salu2!
Salu2!