Working With Text Files
Hello,
First of all let me say sorry for asking such a lot here. Basically my VB skills are very rusty as I haven't had to touch it for a year or two. Now that I am getting back into it I am finding it a little difficult.
In the source code provided, I was wondering if someone could help me add a few features I have been trying to get right. I am not asking you complete the program to the ground (well I guess pretty close), but to get the major parts done. You don't really have to code it in, just point me in the right direction.
Here's what I want:
cmdSearch: Search the text file until it finds a line with jobnum.text in it. If it does, load the line into an array, and put [0] (job number?) into job jumber text (or leave it here from search). [1] into lblposessor. [2] into lbllastupdated. [3] lblcomments.
cmdUpdate: Search the text file until it finds a line with newjobnumber.text in it. Once it does, write job number, currently in posession of and comments IN THE SAME FORMAT that could be read from the 'search' button.
If it cannot find a line with newjobnumber.text in it, it creates a new line.
------
Can anyone help me out?
Thanks guys, I know this might be a pain. Perhaps I will get back into VB
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Working With Text Files
Hi,
How can I check if a text file I need (as a config file to my application) is empty?
THX
Tzachi
Working With Text Files
Hi,
I have written some code that takes information from a form and places it into a text file, the code looks something like this:
open filename for Append as #1
Write #1 String1, String2, String3, CurrentTime
Close #1
This gives me a text file that looks something like this:
"102", "1123", "1.2", "34", "06:16"
"304", "1204", "1.6", "38", "06:34"
"406", "1034", "1.1", "56", "06:57"
As you can see this has a time on it so this is my 'current' file. When the job is finished I am able to extract the information I want. For example if this was the line starting with 304 I can take all the information I need and then work out the rate with the current time against the time saved in the file. Using the same method as above I put all this into a 'complete' file. What I would like to do is to remove this line completly from the current file although I cannot find out how to do it.
Any help would be much appreciated.
Also does anyone know how I would go about sorting a text file numerically?
Thanks
Craig
Working With Text Files
Well i am working in txt files..
when i open the program it opens the file .. and when i search in the file for specific line.. its ok for the first time..
while searching next time it gives me error End of File
how to move pointer to Begin of file without closing and opening it again...
Thanks
Working With Text Files
basically I need to search thru multiple text files and display the all the files that the name appeared in...
for example... if I was to search for "Brian Dooley" I'd want it to look into the text files and display in another part of the program all the txt files(not full paths just file name) that that "Brian Dooley" appeared in..
the text files would be formated simular to below..... if anyone can help get me started in the right direction... I'd be very grateful
file1.txt
1,Brian Dooley
2,Rabbit
8,Joy Roy
file2.txt
1,Run
3,Jump
5,Brian Dooley
Working With Text Files
Yeah, Yeah.. I know. But it's my only option at this point...
Anyway. I am creating a text file using print # statements in vb6.0
My question is.. is there anyway to format the file page properities (i.e., margin size, orientation) in code??
Working With Text Files
Well i am working in txt files..
when i open the program it opens the file .. and when i search in the file for specific line.. its ok for the first time..
while searching next time it gives me error End of File
how to move pointer to Begin of file without closing and opening it again...
Thanks
Working With Text Files
any expert can give me any tutorials for working with large text file with better way
any sample or tutorials?
Help Working With Text Within Files
Hey everyone I have a .txt docuement I have it setup so that it will take text from one file and pull what i want to another file but on the first text file i want it to go through and find all text but look for spaces more then 2 lines of spaces if there is more then 2 line space delete the spaces because the paragraphs are spread all through the text file with hugh space gapes i am wanting to elminiate those and put txt in seperate text file. Can someone give me some examples thanks.
Robb
Working With Text Files!?!?!?!?!
i am writing a program which involves reading certain information from a text file, i can read the whole file but the problem im having is reading information from a particular line in the file!
for example,
how would i read ONLY line 3's text from a file which has 30 lines in total. or am i thinking of the wrong way of doing it?
any ideas!!
Working With Text Files!
I've been trying to get this all night!!!
Here's what I'm trying to do, but it's kinda complicated to explain to try to stay with me!
On a form, I have 2 labels and a text box. I want to use a text file and in it, it a list of about 100 things with 2 things - A street name and a number. Someone told me I can put the street name in "" and then the number after it with a space. Well I want to make it so it displays the street "in the" in the 1st label, and the user has to type in the number for the street in the text box. If they match, then the 2nd label says yes, else, it tells the user the right number. Now my problem is that I don't know how to load the text file and tell VB to load the name in the "" into the label. Then to see if the number and name matches...
Does anyone know a way of doing this?
I'll take ANY suggestions!
Thanks a lot!
-Emo
Working With Text Files
I am reading data from a flat file, and uploading it to the database. How can I delete a row in the flat file once it's been read & uploaded?
Thanks,
Francine
Working With Text Files
Hi guys
i am working on project. I am stucked in the text files.. while searching in text file its ok for the first time... next time when it starts searching it hangs up and that is because of End of File. what is the line of code to move the pointer to Begin of File??????
Working With Text Files
Hi,
I have written some code that takes information from a form and places it into a text file, the code looks something like this:
open filename for Append as #1
Write #1 String1, String2, String3, CurrentTime
Close #1
This gives me a text file that looks something like this:
"102", "1123", "1.2", "34", "06:16"
"304", "1204", "1.6", "38", "06:34"
"406", "1034", "1.1", "56", "06:57"
As you can see this has a time on it so this is my 'current' file. When the job is finished I am able to extract the information I want. For example if this was the line starting with 304 I can take all the information I need and then work out the rate with the current time against the time saved in the file. Using the same method as above I put all this into a 'complete' file. What I would like to do is to remove this line completly from the current file although I cannot find out how to do it.
Any help would be much appreciated.
Also does anyone know how I would go about sorting a text file numerically?
Thanks
Craig
Working With Text Files...
The issue I am having is based on a text file. I can open it, read it and find a certain line within the file. I would then like to edit/modify that specific line The issue I keep running into is.. If I open the file to read it doesn't let me change.. if I open it to write it doesn't let me read..?? You would think that the ability to do both might be helpful. I can't beileve that something as easy as this could be overlooked, so I know I am just mising it.
Here is the code I am working with so you can better understand my problem.. Thanks in adavce for all your help.
Rich
Code::Sub btnPreviewClick(Sender)
Dim sFile, sPath, oNewFile, sRead, oInbound
Dim sMess, sTest, X
sMess = MemMessage.Text
sPath = "C:Documents and SettingsRichMy DocumentsCorpMess.tip"
X = 0
'Reading existing file
Set sRead = CreateObject("Scripting.FileSystemObject")
If sRead.FileExists(sPath) Then
set oInbound = sRead.OpenTextFile(sPath, 1)
Do While oInbound.AtEndOfStream <> True
sTest = oInbound.ReadLine
If instr(1, sTest, "Tip1=") > 0 Then
' Modify this existing line within the file
' oInbound.WriteLine ("Tip1=" & sMess) <-- THIS IS CAUSING ME AN ERROR BASED ON FILE MODE
End If
Loop
End If
oInbound.Close
Set sRead = Nothing
Edited by - Reaton on 7/30/2004 9:08:02 AM
Working With Text Files
I was instructed to read from a text file in VB and have no idea how to start it. Any suggestions would be helpful?
I have VB 6 and .NET and am trying to take the file and insert items into Access.
Working With Changing Text Files.
Quick background:
There is this game that outputs alot of otherwise unaccessable information to a debug.log file, it's just a simple text file that can be viewed even in the ever complex notepad. The file is added (appended, whatever) to as the game runs. After the game is done the file is still intact, but will be completly erased and will start fresh next time the program is run.
What I want to create is a program that will run in the background and check the file and parse (seperate, not sure if that term is proper?) out useful information that I can do as I please with. More specificly, I want to create a program that will keep statistics on the players and what they do.
I'm shaky on file access, or I could probably figure it out on my own. I will figure out something, but I hoped someone could point me to a quick solution.
What I'm thinking is simply watch the file and the line count (can you do this?) and process any new lines that are added to the end (appended).
A 2nd method (maybe more complex?): Watch and see when the program that adds to the debug.log file stops running, then have the program process the whole thing in one swipe and be done.
Just want a few tips. Thanks.
PS - Sorry if this has been asked. I tried a few searches, but I may choose different wording that what the other person who asked the same thing used.
Working With Text Files - Resolved
[ Code Removed ]
Basic rundown of the above code. I have an application which, when executed, checks two textfiles, CustomNamex.txt and Customx.txt. It uses the CustomNamex.txt contents to make up a dropdown menu of filenames. Clicking these will call up an edit window with two textfields - one contains the contents of CustomNamex.txt and the other contains the contents of Customx.txt.
This program will allow a user to store custom messages for say, posting the same thing regularly on a forum. CustomNamex.txt will hold the name of their file, and Customx.txt would be the message they want to store under this name.
Anyway, when you save changes to a file, it "corrupts" the filename, because the next time you check the dropdown menu, it has two boxes after the filename. This is caused, I think, by
Quote:
a.Writeline (text)
When you save changes to a file, it adds the line to the file, and then moves down a line. When the application is loaded again, two boxes appear after the name, which I think are the carriage return characters, because if you manually alter the text file and bring the cursor back up to the end of the contents and save the changes and run the application again, the boxes do not appear after the name, in the dropdown menu.
Can anyone help me and stop this happening? My users are frustrated at this and I do not know how to stop it. - Resolved
Newbie Working With Text Files... Ty
Everyone here has been great with my questions to date so I'll take another crack at it..
I am looking to write to a text file however, I would like to find a specific marker within that file such as..
"<<START>> "
then edit the line in question. I can find all the documentation on Writing a new line, with both Print and Write methods can't seem to find an edit line command so I can go to line number or skipline(#) to getwhere I need within the text file.
Any hints..??
Thanks Again
Rich
Edited by - Reaton on 8/2/2004 4:51:29 PM
Working With Multiple Text Files
I have a "Net Send" application that production operators use to send pre-formatted messages to the technical support staff or Inventory Control. These messages also write to a log file which can be edited from a "Log Viewer" in the applcation. Once the users have corrected the problem stated in the message, they append the log to reflect what was done. On a daily basis these users will print the log out & clear the screen so that the next day the log they view will be empty. Management wants a log that reflect these changes, but is only cleared weekly or monthly. I have this working sort of. My log viewer opens the "Editable" log & the user appends it & saves it. When the user saves it also writes to the other file. The problem is when it is appended there is a line only with the number "1" in between the saves
10/31/03 10:45AM Order Change Needed on Order Number 123456789 ------------ Changed 11:05am KM
1
10/31/03 10:45AM Order Change Needed on Order Number 123456789 ------------ Changed 11:05am KM
what causes this? Or maybe the question is what is the best way to work with multiple text files?
Working With Very Large Flat Text Files - Best Way??
A new project I'm working on requires me to compare the data between two flat text files. They are not delimited. I do have the layout however so I know what data means what.
One file has over 50,000 rows and the other has about 4,200. I have to compare one field in the smaller file and then find the corresponding entry in the larger file.
First I tried to use the Open statement and I just read line by line and then opened the other file and just tried to match the data. That worked however it was not very fast. Took many hours.
So then I thought that I would load that data from both files into recordsets and then start to compare. That took about 4 1/2 hours just to create the first record set.
So now I am thinking the problem is that the data is not technically in a "database" and if it was in a database then it would be much faster.
So I opened up Access and just loaded the data into the database. Took a while to tell it what field started/ended where but once that was done it took only a few seconds to load the larger file.
So what I would like to do at this point is to create a connection to an Access database and then load the sequential files into two separate tables in Access. I think this would be possible to do from within VB 6? But this is something I have never done before. I have created Access database and loaded databefore but never done it with a sequential text file as the source.
Once I can get the two files loaded into those two tables then I would create two recordsets and compare the data that way producing a new table with my output. At that point I can provide a report for them to print out.
Anyone have any ideas how I can load these files into access?
I want to can either define the fields first in Access or VB. I have the table structure already layed out while I was trying it out just by using text file manipulation. I also the two table structures already in Access with no data in the tables. Either way would be fine.
On another board someone said "Why bother putting it into Access at all if you don't need it there". That's a good question. Technically speaking I do not need the Access file but I figure that it would be quicker in the long run. The text files will come out once a month. Once loaded into the Access DB and manipulated they will not need those text files again. But I do not specifically need them - is it possible to just use Text files? Won't I run out of memory? Won't it just take far too long? Opinions?
Any ideas?
Reading Text Files And Working With The Data
I am fairly new to VB and have been given a task at work, which most of my colleagues cant help me with - can anyone help please.
I am reading two txt files :-
File one consists of 70 codes eg.
ABD
DFG
DFT
....etc
File two consists of 100 numeric codes eg.
123456
456774
345677
384587
What I need to do is read 90 other files, the 90 files are txt files structured as
ABD, 123456, etc, etc, etc,
DBD, 398484, etc, etc, etc
and identify those which have a matching first and second subscripts - this I have done successfully using collections.
but I also need to identify those records where only the second subscript matches file two
how do I do a check to see if something doesnt exist in a collection ?
While Not EOF(1)
Input #1, code
GNCodes.Add "GotIT", code
Wend
Close #1
Open App.Path & "QCode.txt" For Input As 1
While Not EOF(1)
Input #1, code
HACodes.Add "GotIT", code
Wend
Close #1
While Not EOF(1)
Input #1, qcode, Seniorgp, Juniorgp, Postcode, sex, Band, Noband
If (HACodes(qcode) = "GotIT") Then
If (GNCodes(Seniorgp) = "GotIT") Then
Write #2, qcode, Seniorgp, Juniorgp, Postcode, sex, Band, Noband
End If
End If
sorry if this is confusing, but its difficult to explain in a few lines.
Thanks in anticipation
Wave Files And Vista. Some Working And Some Not Working. Strange.
Hello everybody,
I have an application with embedded in the ressource file wave files. I use PlaySound to play them. This works perfectly up to Windows Xp.
Recently I have a friend testing the application on Vista. Certain files are not playing, and others are.
Any ideas why some would play and some wouldn't? It seems very strange.
Here is the code. It works for some wave files and not others
VB Code:
Call PlaySound("MY_EMBEDDED_WAVE_FILE", App.hInstance, SND_RESOURCE Or SND_NOWAIT Or SND_NODEFAULT Or SND_ASYNC)
Help Files Not Working
After installing Visual basic 6.0 professional I try to got to help throught the main screen "help" then index, search ... but an error message appears:
"The MSDN collection does not exist. Please reinstall MSDN"
I have reinstalled all of visual basic but the same thing comes up
Can anyone help with getting the files or any alternatives because i'm incredebly new to VB and have no idea how to do the simplest things
thanks alot
Working With XML Files
Prior to sending my actual question is there any way to attach XML and XLS files with my thread. It would be alot easier to illustrate my problem if you could see the actual files.
Working With Files
Good Morning all, if ur in england!
im just wondrin if there is any way in which you can associate files to a program. e.g. When you create a new Microsoft Word document, it says
MyDocument.doc
Microsoft Word Document
is there any way of doing this with my own app?
cheers
Working With Files
Hey Guys , all right?
At this moment a need to creat a vb aplication, how i can select files, rename and copy in a specific directory. I didnt know function and sintaxex for do it. please help me about it
Thanks a lot,
Amauri Pimenta Junior
Working With INI Files
Does VB6 have any simple way for writing and reading application settings to and from INI files?
(I see no reason to constantly access the registry, and INI files are quicker to edit manually.)
Working With Files
Hi!
Code:
Dim FilePath as String
FilePath = "TheFile.dat"
Open FilePath For Input As #1
Input #1, ECG.Data 'it's a string
that's the code of storing string data in to a variable,
but the file is too big to be put in a string variable, so I want to do this:
Code:
ECG.Data = mid(Input (#1),start,100)'i know this is not going to work
how do i do that
Working With Files
I am working at an application where i build a function tha do that.
open a file and read each line until EOF.
My problem is that when in the file it is "," character VB6 knows that there it is the end of line but it is not.
The code is next:
open x.txt for input as #1
while not eof(1)
line input #1,ch
wend
close #1
Working With Three Different Files Using VB 6
new to VB, and need to create a file that can be updated by using transaction and update files. what codes should be used to incorporate following three conditions: addition, correction, and deletion.
Working With Files
Hi all,
I want to open a text file for reading some characters.
What is the simpliest way to achieve this in VB6 ?
thx.
Working With Pst Files
um .. just want to know how i can do some things with pst files
1. create a new pst file
2. create a folder in the new pst file
3. copy objects between the existing and the new pst
4. get the file name of a store from the store id
thanks in advance
Kris Bennett
Working With Txt Files
Hey everyone got a question for ya I am wanting to be able to hit a button and have it go through about 70 txt files and copy and paste the information in those text files and put into 1 text file with a space or so gap between is this a easy task and what do I need to do to get started? Thanks
Robb
Working With Txt Files
Hey everyone got a question for ya I am wanting to be able to hit a button and have it go through about 70 txt files and copy and paste the information in those text files and put into 1 text file with a space or so gap between is this a easy task and what do I need to do to get started? Thanks
Robb
Working With MP3 Files
How can I edit ID3 V2 information of MP3 files?
With your tip "Working With MP3 files" the class
file edits only ID3 V1.0 data, but also the comment
field of ID3 V2. Still it doesn't make changes to
other ID3 V2 fields. How can I decide which ID3
version fields to replace?
And what about tracknumbers?
Thanks.
Working With Files
Hi Guys! I was wondering if anyone could point me to a tutorial or some way to find out how to work with files/directories. I need to 1. Check if a directory exists 2. see if there are files inside 3. count the files 4. grab the newest one and disply it (photo) and 5. move the files (cut) to another folder when done
Probobly easy stuff but i just need a hand getting started. Any takers?
Thanks in advance!!
Working With Files
Hiya World,
Anybody know any links to info on using VB with files such as .CSV or .XLS.
Cheers,
Monkey
----x----
Working With Txt Files.
Before I explain my problem, this is a sample of the text file I need to get the information out of.
[
111301,061259,www.vbworld.com,http,123.45.43,8080
102302,120012,www.vbforums.com,http,123.45.43,8080
]
This would basically go on for about 200 lines in the text file, each bit of information being separated by a comma.
I need to take the first bit of information, 111301, and put that into a(1), where a is a string array. Then I need 061259 in b(1), and www.vbworld.com in c(1), etc...and the next line of information going into a(2), b(2), c(2), etc...
Does anybody know a good idea on how this can be accomplished? If i'm not clear enough, just leave a message and I'll try to clarify.
Thanks.
Working With Files! : )
Well, I've always opened files for Output, Append, or Input which I'm pretty sure by now means I'm working with ASCII only because I'm trying to write WAV files (as well as jpgs, gifs, and other binary types) and what I know right now doesn't cut it.
But what I'm really trying to accomplish is something similar to the .pak file type (used in Half-Life, Quake 2, etc). Since a LONG time ago, nobody answered me about using .pak files, I'm now trying to make my own way to write and easily retrieve files from a "pak" file that has many files (ASCII and Binary).
Ummm... so, ya... help?
Working Wth Files
Alright I made myself an mp3 player runs a lot faster then media player cause it has so much less options takes up a ton less space and let alone i like it better. Just one problem. If you have mp3s on your comp and you double click on them it starts up media player or winamp. Well if media player or winamp is running it and you double click on it it will not open up a new winamp or media player but instead the old existing one will start to play the new song. How in the world can this be done? I am getting my project to open the mp3 on load like this:
Code:
Private Sub Form_Load()
Me.Show
Label1.Caption = Command
If Label1.Caption <> "" Then
mp1.Open Label1.Caption
Dim strFile As String
strFile = Command
Label4.Caption = Mid(strFile, InStrRev(strFile, "") + 1)
Label4.Caption = Left(Label4.Caption, Len(Label4.Caption) - 4)
End If
mode = GetSetting("KOM", "MP3 Player Single", "mode", Default)
If mode = 0 Then
Label3.Caption = ""
ElseIf mode = 1 Then
Label3.Caption = "Repeat"
End If
End Sub
Some of that coding is not nessary for you to see but I figured I would show you the whole form load. Is there a special command for this or I have no idea. I will stop rambling on. Sorry. Thanks!!
VB And Working With Files
I'm just learning VB, I use it a little in excel and with a compiler. I still haven't learned how to move, copy, delete, or get the name of files. A little help working with files would be great.
Thanks,
Shai1
Working With Files
How can i create a VB application that will open a text file to an excel worksheet.
tanx in advance...
Working With WAV Files In VB
I would like to know if anyone knows if it is possible to
programmatically open a WAV file, record from the AUX sound source,
and then detect when the sound source is silent and then close the
WAV file.
Thanks,
Mike
=====
Do not make the mistake of judging another's religion by your own standards of knowledge and truth.
The Urantia Book, Page 1115
Working With Files !!!
Hello everyone !
Im tryin to use a formula wich is loaded from a simple file to a Label named "formula".
Formula type is like : (2 * x) + (2 * y).
In the same form i have puted 2 text boxes. One named x and the other named y. When i press the button Calculate i want to have the result using this formula.
Private Sub Calculate_Click()
result = formula
End Sub
rsult is a Label too.
The result gives me only the formula in string format the way it is without making the calculations.
Can anybody help me on this ???
Working With Files.
Can someone please help me.
I made the mistake of mentioning to my boss that i am learning to program with VB6, so he thought it would be a good idea to give me a project.
I have a file which i beleive to be a Random access file.
The file looks lke this when opened in note pad.
"ABRAHAMS MR. HIGHFIELD, 67 "
"ADAMS MR.R. BALLYHOLME 407 "
"AITKEN MR. SHERNFOLD MEADOW COT 347 "
"AKHMEDOV MR. SOMERTON HOUSE, 77 "
"AL MULLA MRS. 3,THE BYEWAY 404 "
"ALEXANDER MRS. FOX END 330 "
"ALLARD MR. 43,MOUNT PARK ROAD 278 "
"ALLEN MR. S. BEACON HOUSE 299 "
"ALLEN MR.B. WARLEYS 21 "
He wants me to write a program in which the user enters a customer name in a txtbox and presses search, the program then goes through the file until it finds the customer name and the reads the data within that record and takes the address details and displays it in a list box.
I have written some code that displays the whole record when the user enters the customer name. but thats as far as I have got. I just cant work out how to retreive the parts of the record i need.
this is what i have so far
Code:Private Sub CmdSearch_Click()
LstResult.Clear
Dim Lines As String
Open "D:VB6ProgrammingData FilesCUSTOMER.Dat" For Input As #1
Do While Not EOF(1)
Line Input #1, Lines
If InStr(1, Lines, TxtSearch.Text) Then
LstResult.AddItem Lines
End If
Loop
Close #1
If Lines <> "" Then
LstResult.Text = Lines
Else
MsgBox "Nothing Found"
End If
End Sub
Is this at all possible
I need help.
Many Thanks in advance
<Edit> AbbydonKrafts - Added PRE tags around the data to prevent space collapsing </Edit>
Edited by - AbbydonKrafts on 2/22/2007 5:14:59 PM
Working With Files.
Can someone please help me.
I made the mistake of mentioning to my boss that i am learning to program with VB6, so he thought it would be a good idea to give me a project.
I have a file which i beleive to be a Random access file. which i have attached.
He wants me to write a program in which the user enters a customer name in a txtbox and presses search, the program then goes through the file until it finds the customer name and the reads the data within that record and takes the address details and displays it in a list box.
I have written some code that displays the whole record when the user enters the customer name. but thats as far as I have got. I just cant work out how to retreive the parts of the record i need.
this is what i have so far
Code:Private Sub CmdSearch_Click()
LstResult.Clear
Dim Lines As String
Open "D:VB6ProgrammingData FilesCUSTOMER.Dat" For Input As #1
Do While Not EOF(1)
Line Input #1, Lines
If InStr(1, Lines, TxtSearch.Text) Then
LstResult.AddItem Lines
End If
Loop
Close #1
If Lines <> "" Then
LstResult.Text = Lines
Else
MsgBox "Nothing Found"
End If
End Sub
I need help
Please do not double post, check the posting guidelines.
I am looking this thread, a similar post can be found by clicking here
Edited by - rock on 2/21/2007 2:12:30 PM
INI FILES NOT WORKING
Can someone please help me with this project. i am trying to make the setup record in my ini file. but it is not seeming to work. the ini code is in the frm2 ok button.
Working With .Wav Files
I have used playsound command to play a series of wave files.But often the wave(.wav) files get corrupted.I have tried making it read only and still has the same problem.I have not used any api calls.Any ideas?
Code ..Debug ..Go Home
|