470,647 Members | 1,171 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Re: How to write a text file?

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
fileText = fileText.Remove(i, 1)
fileText = fileText.Insert(i,"exelocation_TextChanged")

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

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
0 675

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by John Flynn | last post: by
1 post views Thread by Magix | last post: by
1 post views Thread by Jim Heimer | last post: by
9 posts views Thread by msuk | last post: by
10 posts views Thread by Mike | last post: by
6 posts views Thread by globalrev | last post: by
1 post views Thread by Korara | last post: by
reply views Thread by warner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.