Have VB Create a .csv file

Electronics Computer Programming Q&A
Post Reply
JeffDajos
Posts: 6
Joined: Thu Nov 20, 2003 1:01 am
Location: Detroit
Contact:

Have VB Create a .csv file

Post by JeffDajos »

I built a data logger that I want to be able to download to a PC. Does anyone know the best way to get VB to create a .csv file based on data that comes in through the serial port (using MSComm Control)?<p>I have been able to get it into a file but without any separators.
Jeff
wd5gnr
Posts: 104
Joined: Wed Dec 19, 2001 1:01 am
Contact:

Re: Have VB Create a .csv file

Post by wd5gnr »

A few comments. First, check out this free ActiveX control: http://www.al-williams.com/npdaqax.htm. It is made to work with our Netporter product, but it turns out it is easy to use in many other cases.<p>Once you have your data, it seems like you are going to want to print your data like this:<p>Print #1, a;",";b;",";c<p>(assuming you have variables a, b, c). If they might contain strings, you'd want to quote them with:<p>q=chr(34)
print #1, q;a;q;",";q;b;q;",";q;c;q<p>Something like that?
hp
Posts: 245
Joined: Sat Aug 09, 2003 1:01 am
Location: Friendswood, TX
Contact:

Re: Have VB Create a .csv file

Post by hp »

If you use visual basic's write statement then you can write directly to csv file format.<p>Here is an example:<p>Dim data1 as Integer
Dim data2 as String<p>data1 = 54
data2 = "Serial Ok"<p>Open "file.csv" for Append as #1
Write #1 data1, data2
Close #1<p>
Your file.csv should now contain:
"54","Serial Ok"<p>Harrison<p>[ October 30, 2004: Message edited by: hp ]</p>
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests