How to open multiple textfile

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to open multiple textfile

 
0
  #21
Dec 21st, 2006
Hi,

If u have To Display the records, Ordered by Time,
The Simplest way is to Save all the Records in a Temp Table In Database,
Any Database will do .dbf, or .mdb.
Create a table will all the above fields, Save and
Then Query From the TempTable Order By Date/Time.

Any other Coding if u do will take lots of time, to code as well as check.

To make any file Readonly use this code.

SetAttr "C:\MyTextFile.txt", vbReadOnly

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: How to open multiple textfile

 
0
  #22
Dec 22nd, 2006
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Open both files
  2. Open a new file for the merged data
  3. Read a record from each file into Data1 and Data2
  4. Start a loop
  5. If Data1 < Data2 then
  6. output Data1
  7. read a new Data1
  8. else
  9. output Data2
  10. read a new Data2
  11. endif
  12. continue with loop
I will let you figure out what to do when you reach the end of a file. That is something you must consider.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to open multiple textfile

 
0
  #23
Feb 27th, 2007
hello veena,

can you please help me with this problem, i have a .dat file
the contents is like this
00001 2007-02-12 18:13:13
00001 2007-02-12 18:13:23
00001 2007-02-12 18:13:33
12345 2007-03-12 08:00:09
12345 2007-03-12 09:00:00
00001 2007-04-12 09:08:00
00001 2007-04-12 09:11:00
12345 2007-05-12 08:12:23
00001 2007-05-12 10:11:31

then trying to output the file as text files., split the file base on the date created for their filename i.e. 02122007, 03122007, 04122007, 05122007 see my sample code.. i having a hard time with this one again..thanks in advance
Attached Files
File Type: zip DS700WX.zip (9.4 KB, 6 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to open multiple textfile

 
0
  #24
Mar 2nd, 2007
Hi,

Actually, Iam not getting what u want to do here?

Is it that with above data, u want to create 4 different Text files for 4 dates....?


Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to open multiple textfile

 
0
  #25
Mar 2nd, 2007
yes i want to separate all the text files base on the date...thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to open multiple textfile

 
0
  #26
Mar 2nd, 2007
Hi,

Here I have Changed ur Code and Posted:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command2_Click()
  2. '
  3. Dim inFile As Integer
  4. Dim data() As String
  5. Dim fields As Integer
  6. Dim InLine As String
  7. Dim iDate As String
  8. Dim NewFile As Long
  9. Dim NewFileName As String
  10. '
  11. inFile = FreeFile
  12. '***Open "C:\TEXTLOG\1_attlog.dat" For Input As #InFile
  13. Open App.path & "\1_attlog.dat " For Input As #inFile
  14. While Not EOF(inFile)
  15. Line Input #inFile, InLine
  16. data() = Split(InLine)
  17. fields = UBound(data())
  18. iDate = Format(Right(data(0), 10), "MMDDYYYY")
  19. '
  20. NewFileName = "C:\Andoks\" & iDate & ".txt"
  21. NewFile = FreeFile
  22. Open NewFileName For Append As NewFile
  23. Print #NewFile, Format(Right(data(0), 10), "YYYY/MM/DD") & " " & Left(data(1), 8) & "," & " " & "Event:Access," & " " & "Door:1," & " " & "Card No.:" & Format(Left(data(0), 5), "00000") & ","
  24. Close NewFile
  25. '***Print #1, data(0); vbTab; data(1)
  26. Wend
  27. MsgBox "Attendance successfully downloaded ", vbInformation + vbOKOnly, "Record Saved"
  28. Unload Me
  29. Me.Show
  30. Close #inFile
  31. End Sub


I Hope it is clear.

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 8
Reputation: christophertheo is an unknown quantity at this point 
Solved Threads: 0
christophertheo's Avatar
christophertheo christophertheo is offline Offline
Newbie Poster

Re: How to open multiple textfile

 
0
  #27
Sep 25th, 2007
Originally Posted by royaloba View Post
Veena,
thanks, you've solve my 2nd problem, but still my main problem is if i will download all the attendance from the reader it will save only in one file..this is the sample output file... the file name is base on the date i download the file...12052006.txt

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. 2006/12/01 10:53:40, Event:Access, Door:1, Card No.:00011,
  2. 2006/12/01 10:53:49, Event:Access, Door:1, Card No.:00010,
  3. 2006/12/01 11:01:17, Event:Access, Door:1, Card No.:00010,
  4. 2006/12/01 11:01:19, Event:Access, Door:1, Card No.:00011,
  5. 2006/12/01 11:03:03, Event:Access, Door:1, Card No.:00012,
  6. 2006/12/01 11:03:05, Event:Access, Door:1, Card No.:33333,
  7. 2006/12/01 11:03:07, Event:Access, Door:1, Card No.:00123,
  8. 2006/12/01 11:03:09, Event:Access, Door:1, Card No.:01234,
  9. 2006/12/01 11:04:51, Event:Access, Door:1, Card No.:00015,
  10. 2006/12/01 11:05:18, Event:Access, Door:1, Card No.:00016,
  11. 2006/12/01 11:05:56, Event:Access, Door:1, Card No.:00015,
  12. 2006/12/01 11:05:58, Event:Access, Door:1, Card No.:00016,
  13. 2006/12/01 11:06:39, Event:Access, Door:1, Card No.:00015,
  14. 2006/12/02 10:53:40, Event:Access, Door:1, Card No.:00011,
  15. 2006/12/02 10:53:49, Event:Access, Door:1, Card No.:00010,
  16. 2006/12/02 11:01:17, Event:Access, Door:1, Card No.:00010,
  17. 2006/12/02 11:01:19, Event:Access, Door:1, Card No.:00011,
  18. 2006/12/02 11:03:03, Event:Access, Door:1, Card No.:00012,
  19. 2006/12/02 11:03:05, Event:Access, Door:1, Card No.:33333,
  20. 2006/12/02 11:03:07, Event:Access, Door:1, Card No.:00123,
  21. 2006/12/02 11:03:09, Event:Access, Door:1, Card No.:01234,
  22. 2006/12/02 11:04:51, Event:Access, Door:1, Card No.:00015,
  23. 2006/12/02 11:05:18, Event:Access, Door:1, Card No.:00016,
  24. 2006/12/02 11:05:56, Event:Access, Door:1, Card No.:00015,
  25. 2006/12/02 11:05:58, Event:Access, Door:1, Card No.:00016,
  26. 2006/12/02 11:06:39, Event:Access, Door:1, Card No.:00015,
  27. 2006/12/03 10:53:40, Event:Access, Door:1, Card No.:00011,
  28. 2006/12/03 10:53:49, Event:Access, Door:1, Card No.:00010,
  29. 2006/12/03 11:01:17, Event:Access, Door:1, Card No.:00010,
  30. 2006/12/03 11:01:19, Event:Access, Door:1, Card No.:00011,
  31. 2006/12/03 11:03:03, Event:Access, Door:1, Card No.:00012,
  32. 2006/12/03 11:03:05, Event:Access, Door:1, Card No.:33333,
  33. 2006/12/03 11:03:07, Event:Access, Door:1, Card No.:00123,
  34. 2006/12/03 11:03:09, Event:Access, Door:1, Card No.:01234,
  35. 2006/12/03 11:04:51, Event:Access, Door:1, Card No.:00015,
  36. 2006/12/03 11:05:18, Event:Access, Door:1, Card No.:00016,
  37. 2006/12/03 11:05:56, Event:Access, Door:1, Card No.:00015,
  38. 2006/12/03 11:05:58, Event:Access, Door:1, Card No.:00016,
  39. 2006/12/03 11:06:39, Event:Access, Door:1, Card No.:00015,
  40. 2006/12/04 10:53:40, Event:Access, Door:1, Card No.:00011,
  41. 2006/12/04 10:53:49, Event:Access, Door:1, Card No.:00010,
  42. 2006/12/04 11:01:17, Event:Access, Door:1, Card No.:00010,
  43. 2006/12/04 11:01:19, Event:Access, Door:1, Card No.:00011,
  44. 2006/12/04 11:03:03, Event:Access, Door:1, Card No.:00012,
  45. 2006/12/04 11:03:05, Event:Access, Door:1, Card No.:33333,
  46. 2006/12/04 11:03:07, Event:Access, Door:1, Card No.:00123,
  47. 2006/12/04 11:03:09, Event:Access, Door:1, Card No.:01234,
  48. 2006/12/04 11:04:51, Event:Access, Door:1, Card No.:00015,
  49. 2006/12/04 11:05:18, Event:Access, Door:1, Card No.:00016,
  50. 2006/12/04 11:05:56, Event:Access, Door:1, Card No.:00015,
  51. 2006/12/04 11:05:58, Event:Access, Door:1, Card No.:00016,
  52. 2006/12/04 11:06:39, Event:Access, Door:1, Card No.:00015,

it should be separate the file base on there date i.e. 2006/12/01, 2006/12/02, 2006/12/03, 2006/12/04.. then, the file name should be in 12012006, 12022006, 12032006, 12042006...
my code saves them in one file only, that's my main problem...help me please..thanks again..

my code

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim dwEnrollNumber As Long
  2. Dim dwVerifyMode As Long
  3. Dim dwInOutMode As Long
  4. Dim timeStr As String
  5. Dim iDate As Date
  6. Dim i As Long
  7. Dim FN As Long
  8.  
  9. FN = FreeFile
  10. iDate = Date
  11.  
  12. dwEnrollNumber = 1
  13. CZKEM1.ReadAllGLogData 1
  14. i = i = 1
  15. 'Open "C:\TNA\" & Format(Left(timeStr, 10), "mmddyyyy") & ".txt" For Output As #1
  16. While CZKEM1.GetGeneralLogDataStr(1, dwEnrollNumber, dwVerifyMode, dwInOutMode, timeStr)
  17. On Error GoTo Err
  18. Open "C:\TNA\" & Format(iDate, "mmddyyyy") & ".txt" For Append As #FN
  19. 'i = i + 1
  20.  
  21. If dwInOutMode = 0 Then
  22. iInOut = "Event:Access,"
  23. Else
  24. iInOut = "Event:Access,"
  25. End If
  26.  
  27. Print #1, Format(timeStr, "YYYY/MM/DD HH:MM:SS,") & " " & iInOut & " " & "Door:" & dwVerifyMode & "," & " " & "Card No.:" & Format(dwEnrollNumber, "00000") & ","
  28.  
  29. i = i + 1
  30. Wend
  31. MsgBox "Attendance successfully downloaded"
  32. Close #FN
  33.  
  34. Err:
  35. Resume Next

Hi see thatb you have used CZKEM1 in ur coding can u tellme if it is a userdefined class or a vb class and how to use it i hv been sent a sdk kitin which this piece of coding is used however it does not work it just says method or datat member not found
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC