By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,368 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,368 IT Pros & Developers. It's quick & easy.

Re: How to write a text file?

P: n/a

Thanks eBob

I'm looking at what i wrote and figured out that I should just change
the line I want to instead of just creating the file from scratch. So
poking around I ended up finding a Search and replace piece and i'm
using that. I'm not sure though if I should keep it as a class or do
I build it right into the form? SO far I'm getting pretty confused in
the UI and how to create something in Visual Studio. Although I
prepared for general confusion when I bought it, I didn't realise how
extremely different from batch/wsh/VBScript/Qbasic/Visual Basic it
would be. I'm looking around for a course now...

===========================
'
' sr = search and replace
'
Dim sr As StreamReader = New StreamReader( "autorun.ini" )
Dim fileText As String = sr.ReadToEnd()
Dim i As Integer = fileText.IndexOf("action4=\Documentation\Kit
\installplaceholder.html")
fileText = fileText.Remove(i, 1)
fileText = fileText.Insert(i,"exelocation_TextChanged")
sr.Close()

On Apr 10, 12:20*pm, "eBob.com" <eBob....@totallybogus.comwrote:
I would have started with Hello World, but to each his own. *But be aware
that the VS IDE can take a little bit of getting used to.

A nice thing about the VS IDE is the built in Help. *I just did a searchfor
"File i/o" and selected "Basic File I/O" from the hits and am looking at a
nice discussion of, well ..., basic file I/O. *(There are many things I
don't care for about the Help facility but it does contain a wealth of
information.)

The SAMS books lack depth, but if your programming experience is really
limited one of their books might be a good place to start.

Here's some code which I abstracted from a working program of mine.

* * * * Dim sw As StreamWriter * * * * * * *'for theoutput history file
* * * * Dim hisline As String * * * * * * * 'line tobe written to the
history file

* * * * sw = New StreamWriter(globalinf.ExcelFileName + ".his") * 'for the
output history file

* * * * sw.WriteLine(hisline)

* * * * sw.Close()

To use it you will also need an "Imports" statement ...

* * * * Imports System.IO

I'd recommend always using these two statements as the first two statements
in your source file:

* * * *Option Explicit On
* * * *Option Strict On

These two statements tell the compiler to catch your dumb errors at compile
time rather than allowing them to cause really confusing errors at run time.
(Although you will still experience really confusing errors at run time.)

Good Luck, *Bob
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.