Output to csv question
Output to csv question
Output to csv question
Output to csv question
Output to csv question
Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question
Output to csv question Output to csv question
Output to csv question
Go Back  Xtreme Visual Basic Talk > > > Output to csv question


Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2010, 03:48 PM
sanderson sanderson is offline
Junior Contributor
 
Join Date: Feb 2006
Location: Minnesota, USA
Posts: 217
Default Output to csv question


In the code below:

This works: outFile.WriteLine("1, 2, 3")
This does not work: outFile.WriteLine(Chr(34) & a & ", " & b & ", " & c & Chr(34))


Any thoughts would be great. Trust it is simple.

Thanks


Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(csvFile, True)

For i As Integer = 1 To Val(cboGetNextPNs.Text)
Dim a As String = (((Val(txtLastPNum.Text) + i).ToString))
Dim b As String = txtUserName.Text
Dim c As String = txtDate.Text
outFile.WriteLine("1, 2, 3")
outFile.WriteLine(Chr(34) & a & ", " & b & ", " & c & Chr(34))
Next

outFile.Close()
Reply With Quote
  #2  
Old 11-06-2010, 11:58 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

In the line outFile.WriteLine("1, 2, 3") the Quotes are telling the compiler that this is a string and if you look at the file in Notepad the output will be 1, 2, 3 without quotes.
In the Line outFile.WriteLine(Chr(34) & a & ", " & b & ", " & c & Chr(34)) the CHR(34) is being translated to a quote character as a part of the string and will result in an output to the file of "a, b, c".

I think the solution you are looking for would be just to remove the CHR(34).
Code:
outFile.WriteLine(a & ", " & b & ", " & c)
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Output to csv question
Output to csv question
Output to csv question Output to csv question
Output to csv question
Output to csv question
Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question Output to csv question
Output to csv question
Output to csv question
 
Output to csv question
Output to csv question
 
-->