Edit open for random as #1

when editing it does it well on the screen
but it doesn't save the data correctly

example

 Option Explicit

        Private Type molde_agenda
           id As String
           nombre As String * 40
           imagen As String * 250
       End Type

       Dim Datos As molde_agenda
       Dim DatosTemp As molde_agenda
       Dim FileFree As Integer
       Dim FileTemp As Integer
       Dim RegActual As Long
       Dim RegUltimo As Long
       Dim RegActualTemp As Long
       Dim Pos As Integer, p As Integer
       Dim reg As Integer

    Private Sub Command1_Click()

    Call Image_Click
    End Sub

    Private Sub Command2_Click()
    'New
    List1.Clear
    txtNombre = ""
    txtImagen = ""
    Image1.Picture = Nothing
    txtNombre.SetFocus



    Dim c As Integer
     Dim st As String
    st = App.Path & "\Datos.txt"
    FileFree = FreeFile
      Open st For Random As FileFree Len = Len(Datos)
     RegUltimo = LOF(1) / Len(Datos)
    If RegUltimo = 0 Then
      RegUltimo = 1
      End If
       Get #FileFree, RegUltimo, Datos
       c = Val(Datos.id)

             Text1 = c + 1
    RegActual = 1
    Close #FileFree

    End Sub

    Private Sub Command3_Click()
    'Save
    Dim st As String
    Dim g As Integer
    st = App.Path & "\Datos.txt"
    FileFree = FreeFile
      Open st For Random As FileFree Len = Len(Datos)


       Dim Dire As String


    Dire = App.Path & "\imagenes\" & txtImagen





      With Datos
            .id = Text1.Text
           .nombre = txtNombre.Text
           .imagen = txtImagen.Text

       End With

       Put #FileFree, LOF(1) / Len(Datos) + 1, Datos

       List1.AddItem Val(Text1.Text) & vbTab & txtNombre.Text & vbTab & txtImagen.Text
     SavePicture Image1.Picture, Dire
         Close #1

    txtNombre = ""
    txtImagen = ""
    Image1.Picture = Nothing
    txtNombre.SetFocus
    End Sub

    Private Sub Command4_Click()
    'Edit

     Dim item As String
      Dim st As String
    Dim posicion As Integer
    Dim i As Integer
    Dim encontrado As Boolean
    Dim Dire As String



    If List1.ListIndex > -1 Then
        List1.RemoveItem List1.ListIndex
    End If



    item = Text1.Text & vbTab & txtNombre.Text & vbTab & txtImagen.Text
        List1.List(List1.ListIndex) = item


    st = App.Path & "\Datos.txt"
    FileFree = FreeFile
      Open st For Random As FileFree Len = Len(Datos)



    Dire = App.Path & "\imagenes\" & txtImagen

    For i = 1 To LOF(FileFree) \ Len(Datos)
    Get #FileFree, i, Datos
    If Datos.id = Text2.Text Then
    encontrado = True
    posicion = i
    Exit For
    End If
    Next i

    'If encontrado Then
    With Datos
            .id = Text1.Text
           .nombre = txtNombre.Text
           .imagen = txtImagen.Text

       End With
    Put #FileFree, List1.ListIndex + 2, Datos


    SavePicture Image1.Picture, Dire

    'End If
     Close #FileFree
    End Sub

    Private Sub Command6_Click()
    End
    End Sub



    Private Sub Command8_Click()
    'Read



    Dim nombrearch
    Dim encontrado As Boolean
    Dim noreg As Integer
    nombrearch = App.Path & "\Datos.txt"



    Open nombrearch For Random As #1 Len = Len(Datos)
    RegUltimo = LOF(1) / Len(Datos)
    List1.Clear


                For noreg = 1 To RegUltimo

                   Get 1, , Datos



                  If Text2.Text = Datos.id Then

                     List1.AddItem Datos.id & vbTab & Datos.nombre & vbTab & Datos.imagen

                  End If


                Next noreg


      Close #1

    If Text2.Text > Datos.id Or Text2.Text = "" Then MsgBox "The name does not exist, thanks", vbCritical


    End Sub


    Private Sub Form_Load()
    Dim c As Integer
     Dim st As String
    st = App.Path & "\Datos.txt"
    FileFree = FreeFile
      Open st For Random As FileFree Len = Len(Datos)
     RegUltimo = LOF(1) / Len(Datos)
    If RegUltimo = 0 Then
      RegUltimo = 1
      End If
       Get #FileFree, RegUltimo, Datos
       c = Val(Datos.id)

             Text1 = c + 1
    RegActual = 1
    Close #FileFree
    End Sub
    Private Sub Image_Click()




        CommonDialog1.CancelError = False
            CommonDialog1.InitDir = App.Path & "\imagenes\" & txtImagen
                CommonDialog1.ShowOpen

            On Error Resume Next

                Image1.Picture = LoadPicture(CommonDialog1.FileName)


            txtImagen.Text = Dir(CommonDialog1.FileName)


            If Err.Number = 53 Then
    Image1.Picture = LoadPicture("")
    End If


    End Sub



    Private Sub List1_Click()
Dim nombrearch As String
Dim noreg As Integer

  Dim Dire As String


Dire = App.Path & "\imagenes\" & txtImagen.Text

If List1.ListIndex < 0 Then
        MsgBox "Ningn elemento ha sido seleccionado", vbInformation
        Exit Sub
    End If



 Dim Dati() As String
Dati = Split(List1.List(List1.ListIndex), vbTab)
                 Text1.Text = Dati(0)
                 txtNombre.Text = Dati(1)
                 txtImagen.Text = Dati(2)

         Image1.Picture = LoadPicture(App.Path & "\imagenes\" & txtImagen.Text)
End Sub

I put all the code because it does not accept me to send the file

read id in list1 random file

I need to read the id of the datos.txt file

datos.txt file information:

   1       a       dreamstime_3361539.jpg
                                                                                                                                                                                                                                                                      1 b   dreamstime_7231733.jpg
                                                                                                                                                                                                                                                                      2 c   dreamstime_19009914.jpg
                                                                                                                                                                                                                                                                     2  d   dreamstime_66340321.jpg
                                                                                                                                                                                                                                                                     3  r   F100010793.jpg
                                                                                                                                                                                                                                                                     3  t   music-girl-1366-768-5394.jpg
                                                                                                                                                                                                                                                                     3  p   orig_shutterstock_5515123.jpg

when i put the value in text2.text in 1 it has to come out

    1   a   dreamstime_3361539.jpg
                                                                                                                                                                                                                                                                      1 b   dreamstime_7231733.jpg

in list1

when i put the value in text2.text in 2 it has to come out

   2    c   dreamstime_19009914.jpg
                                                                                                                                                                                                                                                                     2  d   dreamstime_66340321.jpg

in list1

when i put the value in text2.text in 3 it has to come out

   3    r   F100010793.jpg
                                                                                                                                                                                                                                                                     3  t   music-girl-1366-768-5394.jpg
                                                                                                                                                                                                                                                                     3  p   orig_shutterstock_5515123.jpg

in list1

thank you

Remove Registry combobox open for random

I'm doing an inventory application in a random file, everything works fine, but I need to delete the record through combobox. I don't know what I'm doing wrong. It loads the data to the textboxes and when deleting the specific record it is not deleted
The program is made in Spanish, I suppose that there is no problem to see the problem of the program, thanks

id list1 open for random

Hi, I'm Arcon.

I have a problem when saving records, it saves a record and when it saves another it overlaps the first record
when reading records with its id it does not read it to me correctly

thank you