Visual Basic.NET - Editar y Eliminar Registros

 
Vista:
sin imagen de perfil

Editar y Eliminar Registros

Publicado por Allen (1 intervención) el 20/11/2014 06:01:27
Buenas, me preguntaba si me podrían ayudar, verán necesito editar y eliminar registros de un archivo .dat (consultar y agregar ya lo tengo), he intentado varios métodos pero siempre me tiran error, dejo el codigo para que vean como lo estoy haciendo (espero y me ayuden en los botones de BElimina y BEdita). Gracias.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Imports System.IO
Public Class Form5
    Dim tem As dPersonal, narchivo%
    Dim ruta As String = "C:\Rockola\Canciones.dat"
 
    Public Structure dPersonal
        <VBFixedString(4)> Dim Clave As String
        <VBFixedString(100)> Dim Cancion As String
        <VBFixedString(60)> Dim Interprete As String
        <VBFixedString(60)> Dim Album As String
        Dim Año As Integer
        <VBFixedString(30)> Dim Genero As String
        <VBFixedString(200)> Dim Ruta As String
    End Structure
 
    Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        narchivo = FreeFile()
        ComboBox1.Items.Clear()
        FileOpen(narchivo, ruta, OpenMode.Random, OpenAccess.Read, , Len(tem))
        Do While Not EOF(narchivo)
            FileGet(narchivo, tem)
            ComboBox1.Items.Add(tem.Clave)
        Loop
        FileClose(narchivo)
    End Sub
 
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Panel1.Visible = True
        BElimina.Visible = True
        narchivo = FreeFile()
        FileOpen(narchivo, ruta, OpenMode.Random, OpenAccess.Read, , Len(tem))
        Do While Not EOF(narchivo)
            FileGet(narchivo, tem)
            If ComboBox1.Text = tem.Clave Then
                TClave.Text = tem.Clave
                TCancion.Text = tem.Cancion
                TArt.Text = tem.Interprete
                TAl.Text = tem.Album
                TAño.Text = tem.Año
                TGen.Text = tem.Genero
                TR.Text = tem.Ruta
            End If
        Loop
        FileClose(narchivo)
    End Sub
 
    Private Sub BElimina_Click(sender As Object, e As EventArgs) Handles BElimina.Click
        MsgBox("Realmente Desea Borrar el Registro?", vbYesNoCancel, "OPCIÓN")
        If vbYes Then
 
 
 
 
 
 
            MsgBox("Registro Eliminado", vbOKOnly)
        Else
            MsgBox("Registro NO Eliminado", vbOKOnly)
        End If
    End Sub
 
    Private Sub BEdita_Click(sender As Object, e As EventArgs) Handles BEdita.Click
 
 
 
 
    End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder