hello everybody,
i'm having some problems searching a text file and then deleting the line.
since i used fileopen(), i can use the eof() function to loop through the
file, searching for the specified line. the problem is, once found, i can't
delete it because the filemode is in openmode.input.
is there a way to chance the openmode on the run?(if so, what is it?)
and maybe there is a simpler way to search a text file and deleting the line?
this is the code so far:
<begin code>
Dim foto As String = fotos.Item(posi tionarray)
Dim arrayitem, line As String
FileOpen(4, cpath & albumpath & album, OpenMode.Input)
Do While Not EOF(4)
line = LineInput(4)
If line = foto Then
FileClose(4)
PrintLine(4, "")
MsgBox("deleted line!")
Exit Do
End If
Loop
FileClose(4)
<end code>
any help would be greatly appriciated :)
thanks, 2 2391
In order to delete a line from a text file, you must read lines from
the file and write them to another file, except for the line you want
deleted. Once you complete the other file, you delete the original and
then rename the new one back to the original name.
You could use the replace word to search for the string you want and replace
it with an empty string "" , then over write the original file with the new
data
"angus" <an***@discussi ons.microsoft.c om> wrote in message
news:1A******** *************** ***********@mic rosoft.com... hello everybody,
i'm having some problems searching a text file and then deleting the line. since i used fileopen(), i can use the eof() function to loop through the file, searching for the specified line. the problem is, once found, i can't delete it because the filemode is in openmode.input. is there a way to chance the openmode on the run?(if so, what is it?) and maybe there is a simpler way to search a text file and deleting the line?
this is the code so far: <begin code> Dim foto As String = fotos.Item(posi tionarray) Dim arrayitem, line As String FileOpen(4, cpath & albumpath & album, OpenMode.Input) Do While Not EOF(4) line = LineInput(4) If line = foto Then FileClose(4) PrintLine(4, "") MsgBox("deleted line!") Exit Do End If Loop FileClose(4) <end code> any help would be greatly appriciated :)
thanks, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: flupke |
last post by:
Hi,
i'm having trouble with deleting elements from a list in a for loop
============== test program ==============
el =
print "**** Start ****"
print "List = %s " % el
index = 0
for line in el:
|
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
that text from the file..can anyone help me?
|
by: Roberto Dias |
last post by:
Hi all,
What to do for searching for more than one string occurrence in the
same string (this last are line of a text). I have used getline(), to
get the text lines by means of WHILE loop and find(), to searching.
When find() finds a first occurrence it scape and don't detect
possible other one in the same string.
Here is a fragment:
***************************************************************************
|
by: googleboy |
last post by:
Hi there.
I have defined a class called Item with several (about 30 I think)
different attributes (is that the right word in this context?). An
abbreviated example of the code for this is:
class Item(object):
def __init__(self, height, length, function):
params = locals()
|
by: Mathew Hill |
last post by:
I am a beginner to the more technical aspects of Microsoft Access
(2000) and was wondering if any one can help. I have 3 buttons on a
form which add, delete and search for a record. However, when I click
on the respective buttons absolutely nothing happens! I was wondering
if anyone could help? The code I have is below...
ADDING A RECORD
Private Sub cmdaddstudent_Click()
On Error GoTo Err_cmdaddstudent_Click
| |
by: Paul H |
last post by:
I have a text file that contains the following:
********************
__StartCustomerID_41
Name: Fred Smith
Address: 57 Pew Road
Croydon
|
by: DP |
last post by:
hi,
i've got a form, with a subform in it. i've got a delete button in the
subform. the code i;ve got is;
Private Sub cmdDeleteRecord_Click()
msg = "Are you sure you want to delete this film rental record?"
Style = vbYesNo + vbQuestion + vbDefaultButton2
|
by: TonyJ |
last post by:
Hello!
I supposed to modify some text files. In the file(s) which consist of
different section. In one section you might have
Path = <Installation_path>. The program will then replace the text string
Installation_path with the path that was chosen in the installation
program. An example could be this string <Installation_pathwould be
replaced with this path string C:\Work\PK\Program\Test\
Now to my question is it possible to set the...
|
by: Alexnb |
last post by:
This is similar to my last post, but a little different. Here is what I would
like to do.
Lets say I have a text file. The contents look like this, only there is A
LOT of the same thing.
() A registry mark given by underwriters (as at Lloyd's) to ships in
first-class condition. Inferior grades are indicated by A 2 and A 3.
() The first three letters of the alphabet, used for the whole alphabet.
() In church or chapel style; -- said of...
|
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: 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: 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |