473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Outputting text to a file

Ok, I'm not sure how I can explain this but here goes.

I have this program that uses a ListView for entries. What I have the
program doing is taking all the items from the listview, and writing them to
an HTML document.

Well what I did in VB6 was get all the info from the listview in a loop
routine and write the HTML into a text box. When that was completed I then
exported all the text from that text box to an html file.

In VB .NET however, I have a problem where (I think, but am not 100% sure)
all the HTML code can't fit into a text box so I can export it to a file.

Is there any way I can open the file and just keep writing lines of text to
the file instead of doing it to a textbox then to a file?

Hope that made sense :\

Thanks in advance,
Ash
Nov 21 '05 #1
5 1812
Try using a System.IO.StreamWriter, like so:

-------------------------------------------------------------
Dim sw as System.IO.StreamWriter;

sw = new System.IO.StreamWriter("output.txt")

sw.WriteLine("Add this to file.")
sw.WriteLine("Also add this.")
sw.WriteLine("Finally, add this as well!")

sw.Close()
-------------------------------------------------------------

"Ash Phillips" wrote:
Ok, I'm not sure how I can explain this but here goes.

I have this program that uses a ListView for entries. What I have the
program doing is taking all the items from the listview, and writing them to
an HTML document.

Well what I did in VB6 was get all the info from the listview in a loop
routine and write the HTML into a text box. When that was completed I then
exported all the text from that text box to an html file.

In VB .NET however, I have a problem where (I think, but am not 100% sure)
all the HTML code can't fit into a text box so I can export it to a file.

Is there any way I can open the file and just keep writing lines of text to
the file instead of doing it to a textbox then to a file?

Hope that made sense :\

Thanks in advance,
Ash

Nov 21 '05 #2
Ash,

I don't see your problem as you do it as now. (Your textbox has than to be
in the multiline status, what is in fact a kind of different approach of the
textbox than the single line because it has vbcrlf at the end of a line)

However I don't see the reason why you bring it first to a textbox.
This should go in the loop direct as well.

And when you change it use than directly that streamwriter as Fabricio shows
you.

I hope this helps?

Cor
Nov 21 '05 #3
Hi Ash,

in VB.NET you can do it identical.
You have to use a loop taking the values inside of listbox and write line
per line into the html file.

Kind Regards,

Jorge Serrano PĂ©rez
MVP VB.NET
"Ash Phillips" wrote:
Ok, I'm not sure how I can explain this but here goes.

I have this program that uses a ListView for entries. What I have the
program doing is taking all the items from the listview, and writing them to
an HTML document.

Well what I did in VB6 was get all the info from the listview in a loop
routine and write the HTML into a text box. When that was completed I then
exported all the text from that text box to an html file.

In VB .NET however, I have a problem where (I think, but am not 100% sure)
all the HTML code can't fit into a text box so I can export it to a file.

Is there any way I can open the file and just keep writing lines of text to
the file instead of doing it to a textbox then to a file?

Hope that made sense :\

Thanks in advance,
Ash

Nov 21 '05 #4
Ash,

"Ash Phillips" <as*@expwin.net> schrieb:
Is there any way I can open the file and just keep writing lines of text
to
the file instead of doing it to a textbox then to a file?


File Access with Visual Basic Run-Time Functions:

Visual Basic Language Concepts -- File Access with Visual Basic Run-Time
Functions
<URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vbconProcessingFiles.asp>

- or -

..NET Framework Class Library -- 'FileStream' Class
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemIOFileStreamClassTopic.asp>

..NET Framework Class Library -- 'StreamWriter' Class
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemiostreamwriterclasstopic.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
wow, thanks everyone for your replies - I appreciate it :)
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Ash,

"Ash Phillips" <as*@expwin.net> schrieb:
Is there any way I can open the file and just keep writing lines of text
to
the file instead of doing it to a textbox then to a file?
File Access with Visual Basic Run-Time Functions:

Visual Basic Language Concepts -- File Access with Visual Basic Run-Time
Functions

<URL:http://msdn.microsoft.com/library/en...rocessingFiles
..asp>
- or -

.NET Framework Class Library -- 'FileStream' Class
<URL:http://msdn.microsoft.com/library/en...ystemIOFileStr
eamClassTopic.asp>
.NET Framework Class Library -- 'StreamWriter' Class
<URL:http://msdn.microsoft.com/library/en...ystemiostreamw
riterclasstopic.asp>
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jonathan | last post by:
I have a client solution that requires data and associated files to be stored with data in a database. As such, I have a situation where JPEG thumbnails/images that are stored as BLOBs (image...
5
by: Andrei Pociu | last post by:
I have a major doubt about outputting text in ASP .NET when using code behind. I know most of the output you gain from a code behind file (.aspx.cs) is outputted to the Webform (.aspx) using...
4
by: JenHu | last post by:
I have a vb.net application, which read the text file line by line and write into SQL server tables. The text file contains the employees' bank account number and all other information. The way...
3
by: runner7 | last post by:
This is a question about outputting pure XML from PHP, such as to a request object in an AJAX application. I would suppose that all I have to do in my script is to add the line before any other...
4
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it...
5
by: phong.lee | last post by:
Hello all, I was wondering if someone can assist me in outputting 6 reports into a pdf file? I created a macro that generates the 6 reports and right now it's saved as a snapshot on my drive. ...
3
by: mohaakilla51 | last post by:
Alright guys, I am working on a flashcard script... Previously I had it so that it onlty had predefined categories. People were complaining, so now I am trying to make it to where it reads...
12
by: billelev | last post by:
This is probably a very easy question to answer: I have been outputting some text to a message box, similar to the following: strOutput = "---" & Chr(10) & Chr(10) strOutput = strOutput &...
3
by: Ellie | last post by:
I have a VB6 program upgraded to vb.net and I need to use the printline function to write to a text file but I need certain characters in bold. Would anyone be able to tell me how to do this, if...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.