473,508 Members | 2,434 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting/Removing lines on Text File in VB

17 New Member
Hi there,

i just want to know the syntax on how
to remove line on text file using
vb...

pls help me.

tnx,
arjel
Apr 2 '08 #1
1 1272
shweta123
692 Recognized Expert Contributor
Hi,

This forum is for posting the questions related to asp . So if you want to post your question regarding VB you have to post it in the respected forum.

The functionality that you require can be done using following lines of code :

Expand|Select|Wrap|Line Numbers
  1. Private Function DeleteLines(ByVal from_name As String, _
  2.     ByVal to_name As String, ByVal target As String) As Long
  3. Dim strlen As Integer
  4. Dim from_file As Integer
  5. Dim to_file As Integer
  6. Dim one_line As String
  7. Dim deleted As Integer
  8.  
  9.     ' Open the input file.
  10.     from_file = FreeFile
  11.     Open from_name For Input As from_file
  12.  
  13.     ' Open the output file.
  14.     to_file = FreeFile
  15.     Open to_name For Output As to_file
  16.  
  17.     ' Copy the file skipping lines containing the
  18.     ' target.
  19.     deleted = 0
  20.     Do While Not EOF(from_file)
  21.         Line Input #from_file, one_line
  22.         If InStr(one_line, target) = 0 Then
  23.             Print #to_file, one_line
  24.         Else
  25.             deleted = deleted + 1
  26.         End If
  27.     Loop
  28.  
  29.     ' Close the files.
  30.     Close from_file
  31.     Close to_file
  32.  
  33.     DeleteLines = deleted
  34. End Function     
  35.  


Hi there,

i just want to know the syntax on how
to remove line on text file using
vb...

pls help me.

tnx,
arjel
Apr 2 '08 #2

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

Similar topics

20
12955
by: Hanzo | last post by:
I'm iterating over a vector of base class pointers and deleting those which meet a certain criteria...i'm using pretty text-book code for the particular delete/erasure (it's straight out of Myers'...
3
3022
by: Stephen | last post by:
I've got a datagrid with a remove button and I would like to add some code in the code behind page so as whenthe button is clicked the corresponding row in the datagrid is removed. The Datagrid is...
3
1396
by: Thaynann | last post by:
is there a way to delete a block of text i have started by looking for the speicific line of text that starts the block by looking for teh index of it...but i cannot figure out out to remove...
6
4542
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
2
1703
by: SiouxieQ | last post by:
Hi there, I'm using the code below to try to delete a name from a list of names in a file. Unfortunately it doesn't quite do what I want it to. Instead of looking for the name in the...
1
1484
by: derik | last post by:
I hav a text file with N number of lines . i am able to read the file till the end .. in between many lines are starting with #. these lines starting with # are to be omitted. pleast help me in...
13
2430
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or...
9
2384
by: helraizer1 | last post by:
ChatPad The layout so far is pretty amateur but it'll improve. I spent an 1h30/2h or so in this tonight. The concept of ChatPad is basically a dynamic image acting as a shoutbox. <?php ...
8
2204
by: Horacius ReX | last post by:
Hi, I need to write a program which reads an external text file. Each time it reads, then it needs to delete some lines, for instance from second line to 55th line. The file is really big, so...
0
1458
by: aadsaca | last post by:
Deleting/Removing lines on Text File in VB -------------------------------------------------------------------------------- Hi there, i just want to know the syntax on how to remove line on...
0
7118
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
7323
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
7379
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...
0
7493
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
5625
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
4706
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
3192
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
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.