473,809 Members | 2,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1857
Try using a System.IO.Strea mWriter, like so:

-------------------------------------------------------------
Dim sw as System.IO.Strea mWriter;

sw = new System.IO.Strea mWriter("output .txt")

sw.WriteLine("A dd this to file.")
sw.WriteLine("A lso add this.")
sw.WriteLine("F inally, 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/vbconProcessing Files.asp>

- or -

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

..NET Framework Class Library -- 'StreamWriter' Class
<URL:http://msdn.microsoft. com/library/en-us/cpref/html/frlrfsystemiost reamwriterclass topic.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******** ******@TK2MSFTN GP09.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.a sp>
.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
1825
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 data-type) in a SQL DB need to be written to an ASP.NET page. The BLOB is actually wrapped by a class written in C#, BlobObj, which can return a byte-array containing the image-bytes. I can successfully write the image to the page using the...
5
2821
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 labels, datagrids, datalists... Also, I know you can output directly using Response.Write(). But this places the output at the beginning of the file. How can you output the text at a specific place in the HTML code? An example would be when...
4
1649
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 I handle the error is stopping process and send an error message to the screen Try ....... Catch err As Exception MsgBox(err.Message) End Try
3
517
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 output: header('Content-Type: text/xml'); Then I should be able to use the ordinary output mechanisms of literals outside of php tags, and "echo" and "print" inside php tags. This post is not about the caching issues which I am aware of. Can
4
10519
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 doesn't seem to write to the screen in the way I would expect. The output is:
5
2554
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. Any ideals or sample will be greatly appreciated.
3
3245
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 flashcards.txt and then gets the categories from there. Anyhow, I understand how to do this, and there is nothing wrong with my syntax, because it compiles properly, but whenever it runs, it just starts outputting a bunch of random text, although I did...
12
13433
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 & "VAR:" & AddTabs(1) & Format(rsVar!, "currency") strOutput = strOutput & Chr(10) & Chr(10) strOutput = strOutput & "Position Value:" & AddTabs(1) & Format(rsVar!, "currency") & Chr(10) strOutput = strOutput & "Position Risk:" & AddTabs(1) &...
3
3065
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 possible? Thanks, Ellie
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.