|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
saving to CSV file
I have quite a few visual basic programs used for data collection on assembly lines. Usually scanning various barcodes. I have been saving this data directly to disk in a CSV (comma seperated value) file, so it can be imported into Lotus, Excel, Access or whatever else. Have been using a subroutine similar to this:
Private Sub WriteLog() If Dir(sLogFile) = "" Then Open sLogFile For Output As #2 Print #2, "Field1,Field2,Field3,date" Close #2 End If Open sLogFile For Append As #2 Print #2, Field1 & "," & _ Field2 & "," & _ Field3 & "," & _ Format(Now, "mm/dd/yyyy hh:mm:ssa/p") Close #2 End Sub Was wondering if there was a more "elegant" way to save the data. Maybe saving all values to a struct and dumping the whole record at once? I guess if it ain't broke, don't fix it. But this way just seems a little sloppy. |
|
#2
|
|||
|
|||
|
Possible to...
Maybe put it in a RecordSet and save as XML?
Actually, the most I would do is to change '#2' to a freefile... Code:
Dim ff as Integer ff = freefile ' open #ff .. ' More file operations ' close #ff You coulde use the file system object (scrun.dll) (Microsoft Scripting Runtime) Might give better performance - but you'd have to test to find out. Other than that- If it ain't broke, don't fix it =) |
|
#3
|
|||
|
|||
|
I'd leave it alone if everything is working correctly.
If I was starting over I'd probably use the filesystem object.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#4
|
|||
|
|||
|
Quote:
thanks for the input. I'll check out the filesystem object. I make new programs about every week, as the requirements and products change. This last run the output was a 15 column table. Some people reeeeally like thier data haha |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > saving to CSV file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|