Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 2nd, 2004, 12:23 PM
Chef Groovy Chef Groovy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 Chef Groovy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old August 2nd, 2004, 01:04 PM
Micah Micah is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 10 Micah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 14 m 29 sec
Reputation Power: 0
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 =)

Reply With Quote
  #3  
Old August 3rd, 2004, 12:54 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 28 m 48 sec
Reputation Power: 180
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

Reply With Quote
  #4  
Old August 3rd, 2004, 05:25 AM
Chef Groovy Chef Groovy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 4 Chef Groovy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
I'd leave it alone if everything is working correctly.

If I was starting over I'd probably use the filesystem object.

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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > saving to CSV file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway