Usuario
como borrar un registro de un array en VB consola

Pregunta
-
Tengo este codigo:
Imports System.Console
Module Module1
Sub Main()
Try
Dim Opc As Integer = 1
Dim Contador As Integer = 0
Dim TamArray As Integer
WriteLine("Ingrese el tamaño del arreglo")
TamArray = ReadLine()
Dim Nombres(TamArray) As String
Dim Nota1(TamArray) As Double
Dim Nota2(TamArray) As Double
Dim Nota3(TamArray) As Double
Dim Promedio(TamArray) As Double
While ((Opc > 0) And (Opc < 6))
WriteLine("Registro de notas estudiantil")
WriteLine("------------------------------------------------------")
WriteLine("1. Insertar Registro")
WriteLine("2. Editar Registro")
WriteLine("3. Buscar Registro")
WriteLine("4. Eliminar Registro")
WriteLine("5. Salir")
WriteLine("------------------------------------------------------")
Opc = ReadLine()
'Writeline("--------------------------------------------------------)
Select Case Opc
Case Is = 1
If (Contador < TamArray) Then
WriteLine("Ingrese Nombre")
Nombres(Contador) = ReadLine()
WriteLine("Ingrese Nota 1")
Nota1(Contador) = ReadLine()
WriteLine("Ingrese Nota 2")
Nota2(Contador) = ReadLine()
WriteLine("Ingrese Nota 3")
Nota3(Contador) = ReadLine()
Dim NotaFinal As Double
NotaFinal = (Nota1(Contador) + Nota2(Contador) + Nota3(Contador)) / 3
Promedio(Contador) = NotaFinal
Contador += 1
Else
WriteLine("Registro lleno")
Write("Presione INTRO para continuar")
ReadLine()
End If
Case Is = 2
Dim editar As Integer
Dim prom As Double
Dim indice As Integer
WriteLine("Ingrese el Id del estudiante a editar")
indice = ReadLine()
WriteLine("Seleccione el dato del registro a editar")
WriteLine("------------------------------------------")
WriteLine("1. Nombre")
WriteLine("2. Nota 1")
WriteLine("3. Nota 2")
WriteLine("4. Nota 3")
WriteLine("5. Editar todo")
editar = ReadLine()
If (editar = 1) Then
WriteLine("Ingrese el nuevo nombre")
Nombres(indice) = ReadLine()
ElseIf (editar = 2) Then
WriteLine("Ingrese la nueva nota")
Nota1(indice) = ReadLine()
prom = (Nota1(indice) + Nota2(indice) + Nota3(indice)) / 3
Promedio(indice) = prom
ElseIf (editar = 3) Then
WriteLine("Ingrese la nueva nota")
Nota2(indice) = ReadLine()
prom = (Nota1(indice) + Nota2(indice) + Nota3(indice)) / 3
Promedio(indice) = prom
ElseIf (editar = 4) Then
WriteLine("Ingrese la nueva nota")
Nota3(indice) = ReadLine()
prom = (Nota1(indice) + Nota2(indice) + Nota3(indice)) / 3
Promedio(indice) = prom
ElseIf (editar = 5) Then
WriteLine("Ingrese el nuevo nombre")
Nombres(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota1(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota2(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota3(indice) = ReadLine()
prom = (Nota1(indice) + Nota2(indice) + Nota3(indice)) / 3
Promedio(indice) = prom
Else
WriteLine("Opcion no valida")
WriteLine("presione INTRO para continuar")
ReadLine()
End If
Case Is = 3
Dim indice As Integer
WriteLine("Ingrese el Id a buscar")
indice = ReadLine()
If (indice <= TamArray) Then
WriteLine("-------------------------------------------------------")
WriteLine("Nombre: " & Nombres(indice))
WriteLine("Nota 1: " & Nota1(indice))
WriteLine("Nota 2: " & Nota2(indice))
WriteLine("Nota 3: " & Nota3(indice))
WriteLine("Promedio Final: " & Promedio(indice))
WriteLine("-------------------------------------------------------")
ReadLine()
Else
WriteLine("Id no encontrado")
Write("Presione INTRO para continuar")
ReadLine()
End If
Case Is = 4
Dim borrar As Integer
Dim prom As Double
Dim indice As Integer
WriteLine("Ingrese el Id del estudiante a borrar")
indice = ReadLine()
WriteLine("Seleccione el dato del registro a borrar")
WriteLine("------------------------------------------")
WriteLine("1. Borrar todo")
borrar = ReadLine()
If (borrar = 1) Then
WriteLine("Ingrese el nuevo nombre")
Nombres(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota1(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota2(indice) = ReadLine()
WriteLine("Ingrese la nueva nota")
Nota3(indice) = ReadLine()
prom = (Nota1(indice) + Nota2(indice) + Nota3(indice)) / 3
Promedio(indice) = prom
Else
WriteLine("Opcion no valida")
WriteLine("presione INTRO para continuar")
ReadLine()
End If
Case Is = 5
End
Exit While
End Select
End While
Catch Errores As Exception
WriteLine("Origen: " & Errores.Source)
WriteLine("Mensaje:" & Errores.Message)
WriteLine("Antecedente de ejecucion:" & Errores.StackTrace)
WriteLine("Texto completo: " & Errores.ToString)
Finally
Write("Pulse INTRO para continuar")
ReadLine()
End Try
End Sub
End Module
.
.
.
en el caso 4 no se que hacer para que borre un registro de un estudiante, su nombre y sus notas y promedio.
Todas las respuestas
-
Hola
Con respecto a tu consulta, puedes hacer lo siguiente:
Nota1.Delete
TamArray.Delete
Gracias por usar los foros de MSDN.
Pablo Rubio_____
Por favor recuerde "Marcar como respuesta" las respuestas que hayan resuelto su problema, es una forma común de reconocer a aquellos que han ayudado, y hace que sea más fácil para los otros visitantes encontrar la solución más tarde.
Microsoft ofrece este servicio de forma gratuita, con la finalidad de ayudar a los usuarios y la ampliación de la base de datos de conocimientos relacionados con los productos y tecnologías de Microsoft.
Este contenido es proporcionado "tal cual" y no implica ninguna responsabilidad de parte de Microsoft.