Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: corlo en 21 Marzo 2015, 13:40 pm



Título: vb consultar por fecha archivo secuencial
Publicado por: corlo en 21 Marzo 2015, 13:40 pm
Hola soy corlo

tengo un problema a la hora de consultar por fecha en archivo secuencial, me lee todo el fichero, solo tiene que leer por fecha.
Guardar los datos lo hace bien





Código:

Este formulario es el de grabar datos lo hace perfecto.

Dim fecha As String
Dim nombre As String
Dim apellido As String
Dim producto As String
Dim cantidad As Integer
Dim precio As Integer
Dim total As Integer
Dim archivo As String

Private Sub Command1_Click()
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text2.SetFocus
End Sub

Private Sub Command2_Click()
Dim i As Integer
fecha = Text1.Text
nombre = Text2.Text
apellido = Text3.Text
producto = Text4.Text
cantidad = Text5.Text
precio = Text6.Text
total = Val(Text5.Text) * Val(Text6.Text)
Text7.Text = Val(Text5.Text) * Val(Text6.Text)
archivo = App.Path & "\ventas.txt"
Open archivo For Append As #1
Write #1, fecha, nombre, apellido, producto, cantidad, precio, total
For i = 0 To List1.ListCount - 1

        Print #1, List1.List(i)
        Next i
Close #1

End Sub



Este formulario es el de consula

Dim fe As String
Dim nom As String
Dim apel As String
Dim prod As String
Dim cant As Integer
Dim prec As Integer
Dim tot As Integer
Dim archivo As String
Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub
Private Sub Command2_Click()
Text1.Text = ""
List1.Clear
Text1.SetFocus
End Sub


Private Sub Command3_Click()
List1.Clear
List2.Clear
Dim k As Integer
If Text1.Text = "" Then Exit Sub
fe = Format(Text1.Text, Date)
Text1.Text = fe
Text2.Text = nom
Text3.Text = apel
Text4.Text = prod
Text5.Text = cant
Text6.Text = prec
Text7.Text = tot
archivo = App.Path & "\ventas.txt"
Open archivo For Input As #1
If fe = Date Then
While Not EOF(1)
Input #1, fe, nom, apel, prod, cant, prec, tot
List1.AddItem fe & "        " & nom & "       " & apel & "      " & prod & "       " & cant & "      " & prec & "        " & tot

Wend
End If
Close #1

End Sub


Gracias