473,597 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.in i" )
Dim fileText As String = sr.ReadToEnd()
Dim i As Integer = fileText.IndexO f("action4=\Doc umentation\Kit
\installplaceho lder.html")
fileText = fileText.Remove (i, 1)
fileText = fileText.Insert (i,"exelocation _TextChanged")

On Apr 10, 12:20*pm, "eBob.com" <eBob....@total lybogus.comwrot e:
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(gl obalinf.ExcelFi leName + ".his") * 'for the
output history file

* * * * sw.WriteLine(hi sline)

* * * * 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 779

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

Similar topics

by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to replace the text its reversing eg.
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each time after routine process A, the text file is named "mytext.dat" in following format with "#####" as separator. The maximum entries of them is 5. When reaching the fifth entry, it will delete the very first entry.
by: Jim Heimer | last post by:
Hi, I've been using schema.ini to read an ascii file to a dataset. Would it be possible to write to the ascii file the same way I read from it? In my case, the initial ascii file has two "columns" readable by schema.ini, first name and last name. After the process, I need to write the emplcode to that same file. In schema.ini, Would it be possible to add an additional "column" called emplcode (that does not contain any data in the...
by: msuk | last post by:
All, I have a well form block of XML that is stored in a C# string type and I just simply want to display it in the browser using Response.Write but when I try this I get the following error: The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
by: Mike | last post by:
I have a text file that i need to write multiple lines of data to but one at a time. how can i write more then one line of data to the file? example: i do a search for a file on a server if the file does not exist on the server i write it to text file. then i search for another file and if that does not exist, again write to the text file.
by: Nina | last post by:
Hi there, What is the maximum length that one line can hold in a text file using StreamWriter's Write or WriteLine method? If the string is too long for one line to hold, what will Write or WriteLine do? In order me to retrieve data correctly from the text file later, I have to know the right index. For the following code,if str1's length exceeds one line in text file, how can I get str2's index when reading the text file? Is there...
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through and write the fields into strings of rows, I want to be able to put field1 in row1/column position1, field2 in row1/column position10,.....etc. I've included the basic code to write a string of text. I understand the process of how to write the...
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using System; using System.IO; using System.Diagnostics;
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of text into the next row. so: 1. how do i write to a new line every time i write to the file? 2. if i dont want to write to a new line but just want to insert it
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but got errors of Failed to open file ./outdir/mytestout.txt. Below is the code: #include <stdio.h>
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...
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,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
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,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.