-
Mar 22nd, 2015, 05:06 PM
#1
Thread Starter
Junior Member
vb consult sequential file by date
hello i am octor
I have a problem when consulted by date sequential file, I read the whole file, simply read by date.
Save data does well
Code:
This form is to store data does well
Dim date As String
Dim name As String
Dim lastname As String
Dim product As String
Dim quantity As Integer
Dim price As Integer
Dim overall As Integer
Dim archive 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
date = Text1.Text
name = Text2.Text
lastname = Text3.Text
product = Text4.Text
quantity = Text5.Text
price = Text6.Text
overall = Val(Text5.Text) * Val(Text6.Text)
Text7.Text = Val(Text5.Text) * Val(Text6.Text)
archive = App.Path & "\stock.txt"
Open archive For Append As #1
Write #1, fecha, name, lastname, product, quantity, price, overall
For i = 0 To List1.ListCount - 1
Print #1, List1.List(i)
Next i
Close #1
End Sub
This form is to consultation
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
archive = App.Path & "\stock.txt"
Open archive 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
thanks you
-
Mar 22nd, 2015, 05:38 PM
#2
Re: vb consult sequential file by date
I really can't tell what your question is here.
-
Mar 22nd, 2015, 05:49 PM
#3
Thread Starter
Junior Member
Re: vb consult sequential file by date
hello i am octor
the question is who reads the entire file there several times and want to read only one time a day
-
Mar 22nd, 2015, 06:12 PM
#4
Thread Starter
Junior Member
Re: vb consult sequential file by date
hello i am octor
There are several dates and
* I want that reads just a date of one day
-
Mar 22nd, 2015, 06:19 PM
#5
Re: vb consult sequential file by date
Sorry but you have not provided enough info.
We have no idea what this file looks like or what "I want that reads just a date of one day " may mean.
In order to get good help you must first start by giving a clear and detailed description of what problem you are facing. In this case that would need to include some sample of what the file looks like in addition to more detail on your question.
-
Mar 22nd, 2015, 06:54 PM
#6
Thread Starter
Junior Member
Re: vb consult sequential file by date
hello i am octor
the stock.txt file is:
"03/14/2015", "e", "e", "e", 2,8,16
"03/14/2015", "d", "d", "d", 2,8,16
"03/14/2015", "c", "c", "c", 2,8,16
"03/15/2015", "a", "a", "a", 2,8,16
"03/15/2015", "b", "b", "b", 12,4,48
for example if I say that out "03/14/2015" you exit
"03/14/2015", "e", "e", "e", 2,8,16
"03/14/2015", "d", "d", "d", 2,8,16
"03/14/2015", "c", "c", "c", 2,8,16
-
Mar 22nd, 2015, 09:14 PM
#7
Re: vb consult sequential file by date
Well that loop at the bottom could have an If statement added to it so that it only adds the items to the list box that matches your date
Code:
While Not EOF(1)
Input #1, fe, nom, apel, prod, cant, prec, tot
If Fe=MyDate Then
List1.AddItem fe & " " & nom & " " & apel & " " & prod & " " & cant & " " & prec & " " & tot
End IF
Wend
Assuming of course that is what you want to do, Hard to be sure when your posts only contain one or two sentences.
-
Mar 23rd, 2015, 03:37 AM
#8
Thread Starter
Junior Member
Re: vb consult sequential file by date
hi i am octor
I put a date and does not come out any results
not know which is the error
-
Mar 23rd, 2015, 03:40 AM
#9
Re: vb consult sequential file by date
In the Input statement the variable "fe" holds the date of current line.
If you want to add only lines with a specific date then you should compare the date in "fe" with the desired date.
Like DataMiser already showed you
Code:
While Not EOF(1)
Input #1, fe, nom, apel, prod, cant, prec, tot
Debug.Print fe, MyDate
If Fe=MyDate Then
List1.AddItem fe & " " & nom & " " & apel & " " & prod & " " & cant & " " & prec & " " & tot
End IF
Wend
-
Mar 23rd, 2015, 06:05 AM
#10
Thread Starter
Junior Member
Re: vb consult sequential file by date
hola soy octor
solucionado
Code:
This form is to consultation
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 = CDate(Text1.Text)
Text1.Text = fe
Text2.Text = nom
Text3.Text = apel
Text4.Text = prod
Text5.Text = cant
Text6.Text = prec
Text7.Text = tot
archive = App.Path & "\stock.txt"
Open archive For Input As #1
While Not EOF(1)
Input #1, fe, nom, apel, prod, cant, prec, tot
If fe = Text1.Text Then
List1.AddItem fe & " " & nom & " " & apel & " " & prod & " " & cant & " " & prec & " " & tot
End If
Wend
End Sub
thank you very much
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|