arcon 51 Light Poster

thanks for everything

arcon 51 Light Poster

because it still works and there are many people who use it, thank you

arcon 51 Light Poster

because it still works and there are many people who use it, thank you

arcon 51 Light Poster

Sorry but you have not given a solution to the issue, because I see that here in this forum people continue to ask about vb6.0

rproffitt commented: You didn't supply the code in the clear. ZIP file? I won't open it and then the problems noted above. +17
arcon 51 Light Poster

I think I can record but I can't read with the option button checkbox
I don't know if I do the recording procedure correctly

arcon 51 Light Poster

the issue to edit is on line 89 to 142

  '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


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

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


    SavePicture Image1.Picture, Dire


     Close #FileFree
    End Sub


The issue is that it does not save the modified data






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

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

for me it is not dead vb 6.0 thanks

rproffitt commented: With so few having VB6 now, you need to move to a current release. Help will be hard to find. +17
arcon 51 Light Poster

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 …
arcon 51 Light Poster

I have managed to read the records but now the error message does not appear the name does not exist

'Read



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


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


            For noreg = 1 To RegUltimo

               Get 1, , Datos

               encontrado = True

              If Text2.Text = Datos.id Then

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

              End If

            Next noreg


  Close #1
Exit Sub
salida:

If Not encontrado Then
MsgBox "The name does not exist, thanks", vbCritical
Close #1
End If
arcon 51 Light Poster
 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
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)
  c = c + 1
         Text1 = c + 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




  For g = 0 To List1.ListCount - 1
  With Datos

       .nombre = List1.List(g) & vbCrLf


   End With

   Put #FileFree, LOF(1) / Len(Datos) + 1, Datos
 Next g
 SavePicture Image1.Picture, Dire
     Close #1
     List1.Clear
txtNombre = ""
txtImagen = ""
Image1.Picture = Nothing
txtNombre.SetFocus
End Sub

Private Sub Command6_Click()
End
End Sub

Private Sub Command7_Click()
'Add

   List1.AddItem Val(Text1.Text) & vbTab & txtNombre.Text & vbTab & txtImagen.Text





End Sub

Private …
arcon 51 Light Poster

What I'm doing is trying to read the id in text2.text and the command8_click button and list by id in list1.
now list all together

rproffitt commented: That's fine but I can't load up your project. Few others can so by not posting the relevant code in the clear with your assessment, you see the issue? +17
arcon 51 Light Poster

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

arcon 51 Light Poster

Hello, the process of deleting a record does it well
the problem is that it does not update the id, which would be inv.id,
I try to add and save inv.id but it adds a repeated item in combo1

arcon 51 Light Poster

now I can delete a record what is missing is to update the id
when a record is deleted, the id should be added to one
so that in the frmnuevoarticulo the id adds plus one

Dim ror As String


    ror = MsgBox("delete record: " + Text1.Text, 3 + 32, "delete")
    If (ror = vbYes) Then




  Dim I As Integer, Count As Integer

Open App.Path & "\inventario\inventario.txt" For Random As 1 Len = Len(inv)

Open App.Path & "\inventario\inventario.temp" For Random As 2 Len = Len(inv)


 With Combo1 'Adresses listbox
 Position = .ListIndex + 1 'marked entry position
 For I = 1 To .ListCount - 1 'I is used for position in random file
 If I <> Position Then
 Get #1, I, inv
 Count = Count + 1
 Put #2, Count, inv
 End If
 Next I
 .RemoveItem (.ListIndex)

 End With
 Close #1 'close orignal file
 Close #2 'close new temporary file




   Kill App.Path & "\inventario\inventario.txt"

   Name App.Path & "\inventario\inventario.temp" As App.Path & "\inventario\inventario.txt"




    End If

Combo1.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text2.SetFocus

thank you

arcon 51 Light Poster

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

arcon 51 Light Poster

I mean this

Dim n As Integer
    Dim v As Integer
    List1.Clear
    n = Val(InputBox("Enter Staff ID:"))
    Open App.Path & "\TESTFILE.txt" For Random As #1 Len = Len(myRecord)
    For v = 1 To n
    Get #1, v, myRecord
    If v = n Then
    List1.AddItem myRecord.ID & " " & myRecord.Name
    End If
    Next v
    Close #1

but it doesn't work
thank you

arcon 51 Light Poster

To read the id=1, how would it be in the command3 button to read?
thank you

arcon 51 Light Poster

I can't make two id entries
id=1
name=a

id=1

name=b

he save it well
but when i enter the id=2

id=2
name=q

id=2
name=w

saves it but is overwritten in record id=1

arcon 51 Light Poster

when I enter a record everything is fine, but
when I enter another record it puts it in the first record

arcon 51 Light Poster

Sep variable as declared

dim Sep as ?
thank you

arcon 51 Light Poster

a question the sep variable how is the variable declared?

arcon 51 Light Poster

it was just a test to read

 List1.Clear
    Dim myRecord As empRecord
    Dim Position, totalRecords, bytesFile, bytesRecord ' Open sample file for random access.
    Open App.Path & "\TESTFILE.txt" For Random As #1 Len = Len(myRecord) 'find out how many records are there in file #1
        bytesFile = LOF(1)
        bytesRecord = Len(myRecord)
        totalRecords = bytesFile / bytesRecord ' read data (randomly)from last to first rec.
        For Position = 1 To totalRecords ' Read the sample file using the Get.
            Get #1, Position, myRecord  ' Read the record' Show the record into the listbox
            List1.AddItem myRecord.ID & " " & myRecord.Name
        Next '
    Close #1    ' Close the active file

thank you

arcon 51 Light Poster

yes but with different data
1 aa, 1 bb, 1 cc, 2 rr, 2 ff, 3 yy, 3 pp, 3 jj

arcon 51 Light Poster

thanks for answering

the problem is that the id is adding the items of list1
and the id has to add one by one

id:1

list1

1 a a
1 b b
1 c c

save button

new button

id=4

I would have to go out id:2

thank you

arcon 51 Light Poster

The problem is that I make the introduction in the id=1
and I add several items in the list1 and I save and then in the new button it adds the items of the list1 id=5
I would have to go out id:2

id:1

list1

1 a a
1 b b
1 c c

save button

new button

id=5

thank you

arcon 51 Light Poster

ok it saves me well now the problem is in making the new button it doesn't add the id counter it stays at one.

thank you

arcon 51 Light Poster

a possible solution as it would be to be able to save various data and read?
thank you

arcon 51 Light Poster

thanks for answering

but i need it with list1

thank you

arcon 51 Light Poster

thanks for answering

but i need it with list1

thank you

arcon 51 Light Poster

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