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

Changing data in text file using VB 6.0

Hello there,

I want to change some data(which is in one line only) of text file using VB 6.0. Which is the best method for it? Another question is I want to delete last two, three lines of text file using VB 6.0. Which method can be best method for it?
Jun 8 '07 #1
4 7818
Dököll
2,364 Expert 2GB
Hello there,

I want to change some data(which is in one line only) of text file using VB 6.0. Which is the best method for it? Another question is I want to delete last two, three lines of text file using VB 6.0. Which method can be best method for it?
Hello there, varsha desai!

Use the replace command to changes things 'round:
Jun 8 '07 #2
Hello there,

I want to change some data(which is in one line only) of text file using VB 6.0. Which is the best method for it? Another question is I want to delete last two, three lines of text file using VB 6.0. Which method can be best method for it?
Hi
This is my first reply
This way is one of old ways that VB6.0 got it from QBasic
I think the easy way is:
Open:
Expand|Select|Wrap|Line Numbers
  1.     Dim s as String
  2.     Open "C:\test.txt" For input As #1
  3.         Input #1, s
  4.     Close #1
Save:
Expand|Select|Wrap|Line Numbers
  1.     Open "C:\test.txt" For output As #1
  2.         Print #1, "Test"
  3.         Write #1, "Test"
  4.     Close #1
Append:
Expand|Select|Wrap|Line Numbers
  1.     Open "C:\test.txt" For Append As #1
  2.         Print #1, "Test"
  3.         Write #1, "Test"
  4.     Close #1
these are for Text file but if you wanna use it for a binary file:
1. use "Binary" instead of "Output" or "Input" or "Append"
2. use "Get" and "Put" instead of "Input" and "Print" or "Write"

.:!M!LDEREMi:.
Jun 8 '07 #3
Hello there, varsha desai!

Use the replace command to changes things 'round:
Hi
If you use RichTextBox there is a command that load the file in the easiest way and also a command for Replacement but if you wanna do it in the best way don't use it. The best way is opening file in Binary mode and get the data from file directly... in this way you won't need ActiveX of rich text box.

Also this way is the best way in VB.NET faster and easier than VB6.
Jun 8 '07 #4
danp129
323 Expert 256MB
If opening more than one file at a time you need to find a free file handle to use

Expand|Select|Wrap|Line Numbers
  1. Dim s as String, lngFile as long
  2. lngFile=FreeFile
  3. Open "C:\test.txt" For input As #lngFile
  4. Input #lngFile, s
  5. Close #lngFile
Jun 8 '07 #5

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

Similar topics

3
by: Cengiz Ulku | last post by:
Hi all, I know now how to change the font name of a RTF file in a RTB control using, for example: RTextBox1.SelFontName = cmbFonts.Text I have a RTF file -created with Word- displayed in a...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
10
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have...
1
by: Wayne | last post by:
I'm using the following code from the Access Web to open a folder. The folder opens in "List" View. Is there an addition that I can make to the code to force the folder to open in "Details" view?...
4
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. ...
5
by: Mark Fox | last post by:
Hello, When you add a new web form in VS.NET it automatically adds the following namespaces at the top: using System; using System.Collections; using System.ComponentModel; using...
4
by: Good Man | last post by:
Hi there I have a database with about 20 or so tables, maybe a few thousand rows in each. I am starting to do more complex things with my insertions etc, and I want to start to use...
7
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value....
1
by: T00ks | last post by:
The Background: I have data stored in an SQL Database, i'm using asp.net and c# to retrieve the data from the database and update the client side asyncronously (sp?). the behind code looks as...
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...
0
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...
0
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
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...
0
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...
0
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...

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.