473,466 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

appending text at any point in a file

1 New Member
Hi,

is there a way to insert a string into a specific part of a text file from visual basic 6?

this is the relevant code:
Expand|Select|Wrap|Line Numbers
  1. Open CommonDialog1.FileName For Input As #1  
  2. Do While Not EOF(1)      
  3. Input #1, data      
  4. If InStr(data, Date) Then  
  5. : stringinsertion  
  6. Close #1     
  7. Else      
  8. End If  
  9. Loop  
  10. Close #1
so if an entry from the same date had already been recorded in the text file, would i be able to add a new string next to the date in this file using the "stringinsertion" sub? If so, what code would be required?

Many thanks.
Jul 20 '07 #1
3 1178
Dököll
2,364 Recognized Expert Top Contributor
Hi,

is there a way to insert a string into a specific part of a text file from visual basic 6?

this is the relevant code:
Expand|Select|Wrap|Line Numbers
  1. Open CommonDialog1.FileName For Input As #1  
  2. Do While Not EOF(1)      
  3. Input #1, data      
  4. If InStr(data, Date) Then  
  5. : stringinsertion  
  6. Close #1     
  7. Else      
  8. End If  
  9. Loop  
  10. Close #1
so if an entry from the same date had already been recorded in the text file, would i be able to add a new string next to the date in this file using the "stringinsertion" sub? If so, what code would be required?

Many thanks.
Hello!

You should Open CommonDialog1.FileName For Append As #1 to start yourself off. Input reads the file, you can also use Output As...if you read up about it, you'll see a difference but do record to file nonetheless. For additional help about a point in time to Append, please stay tuned.

You could need either a timer, or counter to be a ble to tell at which point you need to Append. If you look further into this forum you may find something already posted.

Good luck and welcome!
Jul 21 '07 #2
Dököll
2,364 Recognized Expert Top Contributor
You may also look into a Replace command whereby you can insert text into strings...
Jul 21 '07 #3
Killer42
8,435 Recognized Expert Expert
Generally speaking, to modify an existing file you will probably need to write the modified text to a new file, then get rid of the old one. Writing data "in place" can be a real problem, unless the new information is exactly the same number of bytes as the old.
Jul 21 '07 #4

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

Similar topics

1
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I...
2
by: Robizzle | last post by:
I am having problems appending a number to the end of a string. I searched google and google forums and couldn't figure it out .... sorry i'm sure its simple. so I have: $filename =...
1
by: Jonathan Taylor | last post by:
I have a large XML file, that is too large to read in to XmlDocument. I need to append data to this XML file without creating a new file, since I don't want to have two copies of the large file...
16
by: Michael | last post by:
I have a data application in a2k that I need to create two fixed width text files and then combine them to a single file The first file is header information and the second is transaction data. ...
3
by: Mike P | last post by:
Does anybody have a simple example of appending text to a text file? Cheers, Mike *** Sent via Developersdex http://www.developersdex.com ***
1
by: mikemac76 | last post by:
I am trying to build a test harness to practice appending strings to an rtf string. I am doing this to simulate the string I'll be sending over the wire and receiving on the other end of an IM...
3
by: Donald Grove | last post by:
Is it possible to append records to a space delimited text file, using Access 2000?
9
by: al jones | last post by:
Sorry, it's getting late and I'm tired. I'm trying to fill a richtect box with text derived from the array I was asking about earlier (thank you). I'm not sure what I'm seeing - since most of...
3
by: Jim | last post by:
Could anyone please point me towards some code that allows me to add to an existing XML file using the output of an HTML form. I want to add a form on my website so users can input their email...
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
marktang
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,...
0
Oralloy
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,...
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
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.