473,385 Members | 1,400 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,385 software developers and data experts.

Changing a word in a .txt document with VB.net

Hello, does anybody out there know how to change a single word in a text document. Right now I'm using VB.net to read a word in a text document (it's the only word in there), I would like to be able to change that word using visual basic. Any help will be greatly appreciated.
Apr 21 '08 #1
6 1187
Hello, does anybody out there know how to change a single word in a text document. Right now I'm using VB.net to read a word in a text document (it's the only word in there), I would like to be able to change that word using visual basic. Any help will be greatly appreciated.


Hi

Please submit what you have written so far

regards
Apr 23 '08 #2
Hi

Please submit what you have written so far

regards
The code that i'm using to read the word is
Expand|Select|Wrap|Line Numbers
  1. My.Computer.FileSystem.ReadAllText(file path)
. I have nothing written yet for changing the word. I really don't know how to go about doing that part.
Apr 23 '08 #3
jamesd0142
469 256MB
I wud:...

1. Read the whole file
2. process it in vb
3. truncate the file
4. write the new data back to the file
Apr 23 '08 #4
ShadowLocke
115 100+
Maybe this will help:

http://bytes.com/forum/thread788846-save+text.html
Apr 23 '08 #5
Thanks for you help but for some reason I just can't figure it out. This is the code i have so far:

Expand|Select|Wrap|Line Numbers
  1. my.computer.filesystem.readalltext("I:\msctc moorhead archive\word.txt")
This is reading the text document that contains the word "test"

How would I go about changing that word using textboxes in VB.net.
Apr 23 '08 #6
I have gotten the code figured out. This is what it wound up being:

Expand|Select|Wrap|Line Numbers
  1. Dim text1 As String = txtOldP.Text
  2.             Dim text2 As String = txtNewP1.Text
  3.             Dim pword As String = My.Computer.FileSystem.ReadAllText("I:\MSCTC Moorhead Archive\word.txt", System.Text.ASCIIEncoding.ASCII)
  4.             My.Computer.FileSystem.WriteAllText("I:\MSCTC Moorhead Archive\word.txt", pword.Replace(txtOldP.Text, txtNewP1.Text), False)
Thanks to those who helped.
Apr 24 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Billy | last post by:
Hello, I'm having a problem dynamically changing the color of a table background. I'm not sure exactly how to word this, but I'll give an example. I have a function called greentored(propname)...
5
by: aqualizard | last post by:
I have searched and searched and searched... Can someone please tell me how (or "if" it is even possible) to change selected text in a textarea? Specifically, say a user has highlighted "ppl"...
5
by: Bart Schelkens | last post by:
Hi, does anyone know of a way to change a word-document into a pdf-file while uploading the file to the website? We've created these word-documents and we changed them into pdf-files before...
0
by: Bob Smith | last post by:
I have existing word documents that we need to have the data document reflect whether we're running in development, test or production. The data header is longer than 255 characters, so I cannot...
7
by: Dave | last post by:
Apologies for the newbie question. I have created a vb.net program for my company that is designed to work with Word Templates (about forty of them that we commonly use) that are selected by the...
3
by: Niyazi | last post by:
Hi, Its like a I am searching alot but still not found or satisfy what I found it. My question is that I had SQL server that contains some data. I also have a application folder call...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
6
by: BlackMustard | last post by:
hi, i'm using the following code to modify a standard word document and save it to disk with a new file name. Sub CreateQuote()...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.