Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Sequential Access Files


For this project, I have to store records of candy prices in candy.txt, s far I've bene using it jsut like

Name
Price
Name
Price

in that format. Now the time comes to display in nicely in a list box, and I'm not sure how to do that, because its a "edit record" screen, so I figred I'd make a 2D array:


Code:
Open "candy.txt" For Input As #1
i = 0
Do While Not EOF(1)
Line Input #1, Variable
i = i + 1
Loop
i = (i / 2) - 1
Dim Candies(1, i)
Close #1

Now the problem is apparently I can't have non-constants when dimming an array. Any suggestions on another way of doing this? (Im open to total change of how to edit it, too)




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
More Sequential Access Files
Is there any way to read from a specified line #, or edit a specified line #?

Sequential Access Files
Is it possible to read from a file and print the information in a report format, similar to a chart?

Sequential Access Files
Does anyone know how to check to see if a file is already open.

I have a file in a loop but when it executes the loop the second time it says FILE ALREAY OPEN.
I had originally fixed this with a boolean but I don't want to do that.

I need something like

IF File#1.AlreadyOpen Then
''''''
END IF

Can someone help?

Sequential Access Files
I am coding an application that will read the file from a .dat file, then it loads the contents to a Combo Box but once the contents are loaded into the combo box i want to be able to click in any of the records and automatically send that record ( the name of the record) to a text box.


Can anybody help?

Sequential Access Files
I am just learning VB, and I have started to learn now how to read and write sequential access files. The following is my code for part of my program, and I can't quite figure out what is wrong.


Code:
Private Sub Command5_Click()
Open "C:WINDOWSDesktopBrett's StuffVisual Basic ProgramsRandom Number GameHigh Scores.txt" For Output As #FileName
Print #FileName, HighScore1
Print #FileName, HighScore2
Print #FileName, HighScore3
Print #FileName, HighScoreName1
Print #FileName, HighScoreName2
Print #FileName, HighScoreName3
Close #FileName
End Sub

Private Sub Command6_Click()
Open "C:WINDOWSDesktopBrett's StuffVisual Basic ProgramsRandom Number GameHigh Scores.txt" For Input As #FileName
Line Input #FileName, HighScore1
Line Input #FileName, HighScore2
Line Input #FileName, HighScore3
Line Input #FileName, HighScoreName1
Line Input #FileName, HighScoreName1
Line Input #FileName, HighScoreName1
Close #FileName
End Sub


The former subroutine works fine - the appropriate variable names appear in High Scores.txt. However, when I click on Command6 to load them, I get a "Type Mismatch" error. Any ideas on what I did wrong?

Sequential Access Files
I know how to use sequential access files and everything. When I open a file for output (e.g. Open "c:coords.txt" For Output As #1) and write to the file (Write #1, intExample) quotes are placed around the data that I put into the file. Does anyone know how to do this without the quotes? Thanks.

Help With Sequential Access Files
Create an application that read a series of numbers from a sequential access file. Each series is separated by a 0. The program should then calculate the average of each series of numbers and an average of all averages. Display your answers in a label on the form.



Test your program thoroughly!

Data File:
10 15 20 20 0 1 2 3 4 5 6 7 8 0 10 20 30 40 50 60 09 9 9 9 99 9 9 9 0 5 8 9 5 3 80 2 23 65 0 Will someone please help me with this assignment I am literally stuck, it is already late, and I don't understand it. Would someone please just walk me through it at least, or get me going on it? I appreciate any help you can give me, thank you so much.

Sequential Access Files
I am trying to create an application that will calculate both the total number of items sold and the total number sold by item. The application should also allow the user to print the interface.

For coding the calculate total option, i need to calculate the total number sold for all the items in the .dat file. I also need to display an appropriate message along with the total in a lbl control. (For example, "the total number sold is 300"...)

For coding the calculate by item option, i need to calculate the total sold from the .dat file for only the item the user selects in the list box. (For example, the user selects ABC11, only show total for that item.) Also display a message("the total number for item ABC11 is :")

Here is what i have so far for the entire form: However, it does not work correctly. _________________________________________________________
Private Sub mnuStatisticsItem_Click()
Const conMsg As String = "The total number sold for item ... is: "
Dim strItem1 As String, sngCItemSold As Single
Open "a:/lc5.dat" For Input As #1
Do While Not EOF(1)
Input #1, strItem1, sngCItemSold
Select Case strItem1
Case "ABC21"
lblTotal.Caption = Val(strItem1) + sngCItemSold
Case "BDE23"
lblTotal.Caption = Val(strItem1) + sngCItemSold
Case "VFE54"
lblTotal.Caption = Val(strItem1) + sngCItemSold
End Select
Loop
Close #1
End Sub

Private Sub mnuStatisticsTotal_Click()
Const conMsg As String = "The Total Number Sold is: "
Dim sngTItemSold As Single, sngCItemSold As Single, strItem1 As String
Open "a:lc5.dat" For Input As #1
Do While Not EOF(1)
Input #1, strItem1, sngTItemSold
lblTotal.Caption = conMsg & Val(strItem1) + sngTItemSold
Loop
Close #1






Genny Steele

Sequential Access Files
Hello. I am trying to complete a problem and I am stuck. I have a menu with two choices: Calculate Total and Calculate by Item. When I click the Cal. Total button it is supposed to calculate the total number sold for all of the items in my dat. file which I put below:

"BDX22",100
"ABC11",150
"BDX22",250
"CVA33",100
"ABC11",300

When I click the cal. by item button, it is supposed to calculate the total sold from the dat. file for only the item the user chooses in the list box.

Could someone please look at my code below and help me out. I can not figure out what I need to do to get my program right. I would really appreciate it and reward with high points. Thank you.

Private Sub mnuStatisticsItem_Click()
'declaring variables
Const conMsg2 As String = "The total number sold for item "
Dim intTotal2 As Integer
Dim strPS1 As String, strPS2 As String
'open the data file
Open "C:VBDATA1071-4Tut06lc5.dat" For Input As #1
'start loop
Do While Not EOF(1)
Input #1, strPS1, strPS2 'reads records from dat. file
'accumulate totals
intTotal2 = intTotal2 + strPS2
'ending the loop and closing the file
Loop
Close #1
lblTotal.Caption = conMsg2 & strPS2


End Sub

Private Sub mnuStatisticsTotal_Click()
'declaring variables
Const conMsg1 As String = "The total number sold is "
Dim intTotal As Integer
Dim strPS1 As String, strPS2 As String
'open the data file
Open "C:VBDATA1071-4Tut06lc5.dat" For Input As #1
'start loop
Do While Not EOF(1)
Input #1, strPS1, strPS2 'reads records from dat. file
'accumulate totals
intTotal = intTotal + Val(strPS2)
'ending the loop and closing the file
Loop
Close #1
lblTotal.Caption = conMsg1 & strPS2

End Sub

Random Or Sequential-access Files?
Well, I am in the long process of making a chat program and I have a server and a client. The server will have a list of all the registered users and certain info about them, such as: name, password, ip, local host name, etc. Every time that someone new registers I want the info to be added to the end of the file. And when I start the server, I want to load all the info onto a list. But here is where I am stuck. Should I use random-access files or sequential-access files? With random access, I could just load each record and put it in the list with the split command and what not, but when I load each record and I make my For loop, what number do I go to, how do I know how many records there are in the file? Thanks for any help...

Opening Files (Not For Sequential Access)
Hello,

Recently we have ventured into a project that will require us to open an acrobat file for the user to read.

I know how to open the acrobat.exe file with the Shell function, and I could sendkeys to it to open the file that I want, but I am wandering if there is a way to open a file in one motion, or at least a better way.

Thanks for the help,

Mike Lyter

Sequential Access Files: Reading/search Coding
I am working on an employee program. I have a txt file to include the employees but when i do a search it comes back as nothing found. I did a debug and when the case comes to [example] name it go directly to the next case. Why is my file not being displayed in the fields?? Please help. Here is the code. The txt file has for example: "mikey Mouse"; "walt Disney";"207-785-8585"; "12"


VB Code:
Private Sub cmdSearch_Click()Dim strQuery As String, strSearch As String Do While (strQuery <> "NAME") And (strQuery <> "ADDRESS") And (strQuery <> "PHONE") And (strQuery <> "NUMBER")strQuery = UCase(InputBox("What do you want to search on Name, Address, Phone or Number?"))LoopstrQuery = UCase(InputBox("ENTER " & strQuery & "OF EMPLOYEE TO SEARCH FOR:"))strSearch = strQuerySelect Case strQuery    Case "NAME"    Open strFName For Input As #1 'opens file with employees listed        Do While Not EOF(1)        Input #1, strEmpName, strAddress, strPhone, intEmployeeNumber 'reads record on file            If strSearch = strEmpName Then            lblName.Caption = strEmpName            lblAddress.Caption = strAddress            lblPhone.Caption = strPhone            lblNumber.Caption = intEmployeeNumber            End If        Loop    Case "ADDRESS"        Open strFName For Input As #1        Do While Not EOF(1)        Input #1, strEmpName, strAddress, strPhone, intEmployeeNumber            If strSearch = strAddress Then            lblName.Caption = strEmpName            lblAddress.Caption = strAddress            lblPhone.Caption = strPhone            lblNumber.Caption = intEmployeeNumber            End If        Loop    Case "PHONE"        Open strFName For Input As #1        Do While Not EOF(1)        Input #1, strEmpName, strAddress, strPhone, intEmployeeNumber            If strSearch = strPhone Then            lblName.Caption = strEmpName            lblAddress.Caption = strAddress            lblPhone.Caption = strPhone            lblNumber.Caption = intEmployeeNumber            End If        Loop    Case "NUMBER"        Open strFName For Input As #1        Do While Not EOF(1)        Input #1, strEmpName, strAddress, strPhone, intEmployeeNumber            If Val(strSearch) = intEmployeeNumber Then            lblName.Caption = strEmpName            lblAddress.Caption = strAddress            lblPhone.Caption = strPhone            lblNumber.Caption = intEmployeeNumber            End If        Loop    End Select    If lblName.Caption = "" Then        lblName.Caption = "None Found"    Close #1    End IfEnd Sub

Reading/Writing Large Sequential Access Files - Error
OK here's the gist:

My colleague has written some code that reads from two files, makes a few comparisons, and writes to one of three new files.

The problem is file size; when the program is reading files under a meg, there's no problem. When the file size increases, however, Access (yes, it's VBA; no VB available at client) stops responding.

The really odd behavior is that Access is halting while printing/writing a variable name; i.e. it gets through X characters in the variable name and quits responding.

We've duplicated the error on two machines with different specifications, and it hangs in the same place.

Any ideas? Are there known issues with writing/reading large files?

Sequential Files Help
is there a way to not have an extra line of blankness under what you just printed into a sequential file?

Sequential Files
I have to do an assignment that requires me to make a form and put the info gathered into two sequential files. I am clueless as to what this even is. Is there a tutorial that will expain what the whole process is?

Sequential Files
Is there a special way to open a sequential file if the file isn't located on your hard, but on the web?

I tried the Open "actual address here" For Input As #1

and it gave me "Path Not Found"

How do I load a sequential file stored on the web?

Sequential Files
Is there a way to make a program figure out how many items are in a sequential file?

Need Help With Sequential Files
I need a program that is used to store data produced by a trucking fleet. The program is used to enter truck number, miles driven, and gallons of fuel . The trucking company runs this program weekly, but the data is only analyzed quarterly. The program should open the file in Append mode so that the data will be added to the end of an existing file. If the file does not exist, it should be created. I need to use the Open dialog box because the company may want to access the data with a spreadsheet program, the file format would be CSV. If any one could help me with this I would be much in your debt!!!!!!!

Thanks,
Jason


P.S. The visual basic version i am using is 6.0

Sequential Files
Hello

I'm working on a project that requires us to read one name off a sequential file. My idea is to type a last name into an input box and then to display it on the screen in all the right fields. The problem is that I have a dountil eof loop going and it keeps looping past the Last name I typed in. I tried debugging tool and it showed me that it is looping past the name I tried. What am I doing wrong?

Sequential Files
I need help with my program please. A department store has a file containing all sales transacted for a year. Each record contains a customer's name, zip code, and amount of the sale. The file is ordered first by zip code and then by name. I need to get my program to display the total sales for each customer, the total sales for each zip code, and the total sales for the store. For instance, if the first six records of the file are
"Adams, John", 10023, 34.50
"Adams, John", 10023, 60.00
"Jones, Bob", 10023, 62.45
"Green, Mary", 12345, 54.00
"Howard, Sue", 12345, 79.25
"Smith, George", 20001, 25.10

then i have to output it in a picture box that should look like this:
Customer Total Sales
Adams, John $94.50
Jones, Bob $62.45
Total Sales of zip cpde 10023: $156.95
Green, Mary $54.00
'And also the total of all sales listed here'

This also needs 3 arrays to store customer name, zip, and sales. Then sort all of these three. And must print out in a picture box like the information starting at 8-9 lines from the bottom. Id appreciate any help. I have some code but it doesnt sort and my form is not right, I think, and my picture box prints out the information the wrong way instead of single lines (and the names come out double instead of adding the same persons many sales). Anyone help me?

<P ID="edit"><FONT SIZE=-1><EM>Edited by mickey2000 on 03/07/01 08:32 PM (server time).</EM></FONT></P>

Sequential Files
Im kind of confused with this program. A department store has a file containing all sales transacted for a year. Each record contains a customer's name, zip code, and amount of the sale. The file is ordered first by zip code and then by name. I need to get my program to display the total sales for each customer, the total sales for each zip code, and the total sales for the store. For instance, if the first six records of the file are
"Adams, John", 10023, 34.50
"Adams, John", 10023, 60.00
"Jones, Bob", 10023, 62.45
"Green, Mary", 12345, 54.00
"Howard, Sue", 12345, 79.25
"Smith, George", 20001, 25.10

then i have to output it in a picture box that should look like this:
Customer Total Sales
Adams, John $94.50
Jones, Bob $62.45
Total Sales of zip cpde 10023: $156.95
Green, Mary $54.00

Can anyone help me get this code going. Because I am not good with sequential files and would like to learn to code with them the correct way. Also woulld I like only have one command button only? I would appreciate all the help. Thanks to anyone who can. :-)

Sequential Files
I have a problem with looping the input of a sequenstial file but it wont work.

I want it to go through the file printing off the different bits of data until the file is finished. It only prints off the first set of data. It wont go onto the next set.

Can anyone help.

The system is a dating agency system where male and female information is entered and then those that match are saved into a file. Files.txt then I want it to print each couple on the click of the "Next Couple" button, The code is below:
Private Sub Command8_Click()
Open _
"U:ProgrammingCouples.txt" _
For Input As #5
Input #5, b
Input #5, c
Input #5, d
Input #5, x
Input #5, y
Input #5, z

Do While Not EOF(5)
Print "Next Match: "
Print b; " and "; x
Picture1.Picture = LoadPicture(z)
Picture2.Picture = LoadPicture(d)
Loop

Close #5

End Sub
[/code]



Thanks in advance.


Bean.

Sequential Files
Hiya All

What I'm trying to do is select an item from a list box (that has been read in from a sequential file, then into an array) search array for this item then write it to a new file named orders.txt.

The code i've come up with so far writes to the file but it's writing the item above what i've selected in the listbox.

Private Sub cmdOrder_Click()

Dim strOrdersFile As String

strOrdersFile = App.Path & "Orders.txt"

'create orders file
Open strOrdersFile For Append As #3

'Write information in data structure to file
Write #3, recSuppDetails(lstSupplierOrderData.ListIndex).strName, _
recSuppDetails(lstSupplierOrderData.ListIndex).strSerialNumber

Close #3

End Sub

Cheers for any help this is really doing my head in

Sequential Files
I need to give a user the choice of searching a txt file for a country begining with the letter they type into an input box, or allowing them to search all countries if the inputbox is blank.
Below is the code to open the file and read teh contents. This code works but I need to add the Like operator to meet whats required.

Code:
Dim objStreamReader As System.IO.StreamReader
Dim strCountry As String

Dim strSearchFor As String
strSearchFor = InputBox("Search beginning with a letter, or leave blank to search for all", "Search For Country")

Dim blnSearch As Boolean 'do I need a bool here?
blnSearch = (strCountry Like strSearchFor)

With dlgOpenFileDialog
.filter = "text(*.txt) |*.txt"
.FileName = "Countries.txt"
.InitialDirectory = Application.StartupPath & ("..")
.ShowDialog()
End With

Sequential Files And Sql
How do i write a vb program so it can read data from a text file, then insert the data into my table within SQL.??

Eg. Some field names are recordID,accountno,date i need the vb program to read this data then insert it into my table.

help?!!
Thanks in advance
G

Using Sequential Files
Beginner at VB and trying to create a VB program that I can use to store my students names and grades. I need to know how to update a sequentail file after the file has been created. I know how to output, input, and append but cannot figure out how to update the data. How would you add a grade for example to the students file. Need to see example code.

Sequential Files
I need help with my program please. A department store has a file containing all sales transacted for a year. Each record contains a customer's name, zip code, and amount of the sale. The file is ordered first by zip code and then by name. I need to get my program to display the total sales for each customer, the total sales for each zip code, and the total sales for the store. For instance, if the first six records of the file are
"Adams, John", 10023, 34.50
"Adams, John", 10023, 60.00
"Jones, Bob", 10023, 62.45
"Green, Mary", 12345, 54.00
"Howard, Sue", 12345, 79.25
"Smith, George", 20001, 25.10

then i have to output it in a picture box that should look like this:
Customer Total Sales
Adams, John $94.50
Jones, Bob $62.45
Total Sales of zip cpde 10023: $156.95
Green, Mary $54.00
'And also the total of all sales listed here'

This also needs 3 arrays to store customer name, zip, and sales. Then sort all of these three. And must print out in a picture box like the information starting at 8-9 lines from the bottom. Id appreciate any help. I have some code but it doesnt sort and my form is not right, I think, and my picture box prints out the information the wrong way instead of single lines (and the names come out double instead of adding the same persons many sales). Anyone help me? Im in trouble and so confused now.

Sequential Files
how do i write to the end of a sequential file every time i write to it?

Cheers
Nick.

Sequential Files
I need a little help with coding out a project. I have it running fine all kinds of whistles and bells except for one thing. I can not get my menu save and open buttons to work. I need to save data from a list box to a file then load it back when i restart the project. Any ideas out there?
Thanks,
Kelly

Sequential Files
Sequential files ...?

Sequential Files
Hiya All

What I'm trying to do is select an item from a list box (that has been read in from a sequential file, then into an array) search array for this item then write it to a new file named orders.txt.

The code i've come up with so far writes to the file but it's writing the item above what i've selected in the listbox.

Private Sub cmdOrder_Click()

Dim strOrdersFile As String

strOrdersFile = App.Path & "Orders.txt"

'create orders file
Open strOrdersFile For Append As #3

'Write information in data structure to file
Write #3, recSuppDetails(lstSupplierOrderData.ListIndex).strName, _
recSuppDetails(lstSupplierOrderData.ListIndex).strSerialNumber

Close #3

End Sub

Cheers for any help this is really doing my head in

Sequential Files
i am trying to update feilds in a sequential file it i get a file is already open error when i try to open the new file for output.
can someone help me, here is my code so far:

Code:Dim intOldFile As Integer
    Dim intNewFile As Integer
    Dim strName2 As String
    Dim strAge2 As String
    Dim strProvince2 As String
    
    intOldFile = FreeFile
    intNewFile = FreeFile
    
    Open App.Path & "customerData.txt" For Input As #intOldFile
    
    'opens new file
    Open App.Path & "DataTemp.txt" For Output As #intNewFile
    
        
    Do While Not EOF(intOldFile)
        'read record from orig file
        Input #intOldFile, strName2, strAge2, strProvince2
        
        If strName2 = txtName.Text And strAge2 = txtAge.Text And strProvince2 = cboProvince.Text Then
            Write #intNewFile, strName2, strAge2, strProvince2
        'ElseIf Not strName2 = txtName.Text And Not strAge2 = txtAge.Text And Not strProvince = cboProvince.Text Then
        ' Write #intNewFile, strName2, strAge2, strProvince2
        End If
    Loop
    
    'closes files
    Close #intOldFile
    Close #intNewFile
    
    Kill App.Path & "customerData.txt"
    Name App.Path & "DataTemp.txt" As App.Path & "cusomterData.txt"

Need Help With Sequential Files
I need to know how to do 2 things for a class assigment, but I dont have the book that we are using: "Introduction to programing using vb.net by Schneider" so I am very lost. These are the programs I need to write:

1.Write a program to create a sequential file called COWBOY4.txt containing all the information in the file COWBOY.txt except for the data Holster, 2.00.

COWBOY.TXT
Colt Peacemaker 12.20
Holster 2.00
Levi Strauss Jeans 1.35
Saddle 40.00
Stetson 10.00

2.Write a program to allow additional items and prices to be input by the user and added to the end of the file COWBOY.txt. Include a method to terminate the process.

If anyone could point me to some tutorials that would give me the ability to write these 2 or (even better) if you could give me an example I would be very greatefull.

Sequential Files Problem
hello all i am trying to do is update a field in a sequential file, which is comma delimited. my code does not work because i don't know how to check and update the field here is my code so far.


Code:
Private Sub UpdateFile()
Dim intOldFile As Integer
Dim intNewFile As Integer
Dim strName2 As String
Dim strAge2 As String
Dim strProvince2 As String

intOldFile = FreeFile

Open App.Path & "customerData.txt" For Input As #intOldFile

intNewFile = FreeFile
'opens new file
Open App.Path & "DataTemp.txt" For Output As #intNewFile


Do While Not EOF(intOldFile)
'read record from orig file
Input #intOldFile, strName2, strAge2, strProvince2

If strName2 = txtName.Text And strAge2 = txtAge.Text And strProvince2 = cboProvince.Text Then
Write #intNewFile, strName2, strAge2, strProvince2
'ElseIf Not strName2 = txtName.Text And Not strAge2 = txtAge.Text And Not strProvince = cboProvince.Text Then
' Write #intNewFile, strName2, strAge2, strProvince2
End If
Loop

'closes files
Close #intOldFile
Close #intNewFile

Kill App.Path & "customerData.txt"
Name App.Path & "DataTemp.txt" As App.Path & "customerData.txt"

End Sub

Saving Sequential Files
I have a small assignment for my Visual Basic course and I don't understand on how to save files from an array to a sequential file.

External Sequential Files
Hi,

A small question really. I just need to know if it is possible to delete a specified line (the last line in fact) from an external sequential file.

Any help appreciated

Merging 2 Sequential Files
sorry an error in previous thread
Hello

Pl Help me with this simple solution
I want to merge two files How can i do it ?


VB Code:
OPEN "ADD.DAT" FOR INPUT AS#1DO UNTIL EOF(1)i% =i% + 1if i% > ubound(Names$) then redim preserve Names$(1 to i%)if i% > ubound(goals$) then redim preserve add$(1 to i%) INPUT #1, Name$(i%), add$(i%)LOOPCLOSE #1


Which displays
"Ronaldo","Brazil"
"David","UK"
"Pele","Brazil"
"Mardona","Argentina"
"Doanald","SA"
"Schnider","Germany"



VB Code:
OPEN "Goals.Dat" FOR INPUT AS#1DO UNTIL EOF(1)s$=s%+1if s% > ubound(Names$) then redim preserve Names$(1 to s%)if s% > ubound(goals$) then redim preserve goals$(1 to s%)INPUT #1, Names$(s%), goals$(s%)LOOPCLOSE #1


Which displays
"Ronaldo","10"
"David","4"
"Doanald","3"
"Schnider","2"

I want to merge above two files and get the result as
"Ronaldo","Brazil","10"
"David","UK","4"
"Pele","Brazil",""
"Mardona","Argentina",""
"Doanald","SA","3"
"Schnider","Germany","2"

Pl Help

Regards

Samyo





i

Merging 2 Sequential Files
Hello

Pl Help me with this simple solution
I want to merge two files How can i do it ?


VB Code:
OPEN "ADD.DAT" FOR INPUT AS#1DO UNTIL EOF(1)i% =i% + 1if i% > ubound(Names$) then redim preserve Names$(1 to i%)if i% > ubound(goals$) then redim preserve add$(1 to i%) INPUT #1, Name$(i%), add$(i%)LOOPCLOSE #1


Which displays
"Ronaldo","Brazil"
"David","UK"
"Pele","Brazil"
"Mardona","Argentina"
"Doanald","SA"
"Schnider","Germany"



VB Code:
OPEN "Goals.Dat" FOR INPUT AS#1DO UNTIL EOF(1)s$=s%+1if s% > ubound(Names$) then redim preserve Names$(1 to s%)if s% > ubound(goals$) then redim preserve goals$(1 to s%)INPUT #1, Names$(i%), goals$(i%)LOOPCLOSE #1


Which displays
"Ronaldo","10"
"David","4"
"Doanald","3"
"Schnider","2"

I want to merge above two files and get the result as
"Ronaldo","Brazil","10"
"David","UK","4"
"Pele","Brazil",""
"Mardona","Argentina",""
"Doanald","SA","3"
"Schnider","Germany","2"

Pl Help

Regards

Samyo





i% = 0

for i% = 0 to ubound(Name$)
FullGreeting$(i%) = Greeting$(i%) & ", " & Name$(i%)
next i

Sequential Files Problem
I'm currently studying for exams and came across this question:


Quote:




Code a procedure to accept details from a user relating to an unknown number of employee entries. Each time a specified number of new employees are added, their details are appended to the existing employees details, which are stored in a sequential file, called "EMPLOYEE.txt".
The required Employee details relate to Employee Name, Employee Number, Salary and Age. Furthermore, these details are required to be displayed to the user on request.






Now I've always used Random Access files for anything to do with this, and I know Sequential files are a pain to use for records. I've tried a lot of things, but when reading in the file I get every employee's name, salary and age filling into the combo box im using to select the particular employee. When I use the Line Input statement it fills with "Name", "Salary", "Age".

I'm really stumped as to how to go about this. Any ideas?

Regards,
jayl.

Can Anyone Help With This..?(sequential Files/Appending)
Hi ......
I've asked this question in alot of Forums but as yet no one can answer it...?

I would be really grateful for any help........

My program writes a txt file(timer.txt)with details of Date,Time...etc,problem is that if you make the file 'Output' it writes the line of info which I want:

03/05/02, 19:59:25,TEST, 5

But the file has to be sequential so that everytime the machine shuts down the info is written to this file then next time a second line is added with the new info and so on.

ie.
01/05/02, 19:59:25,TEST, 23
02/05/02, 19:59:25,TEST, 15
03/05/02, 19:59:25,TEST, 50
etc......


I've tried the 'Append' but this makes the file write a line of info every 4 seconds because the writefile call is in with the timer code, if you call writefile before the 'timer code ' it works but you dont get the last bit of data (seconds) in the data file.

This is what happens if you use 'Append' it repeats info, this is not what I need!
ie.
03/05/02,21:25:19,TEST, 0
03/05/02,21:25:20,TEST,1
03/05/02,21:25:20,TEST,1
03/05/02,21:25:20,TEST,2
03/05/02,21:25:21,TEST,2
03/05/02,21:25:21,TEST,2
03/05/02,21:25:21,TEST,2
etc......

Here's the base of the troublesum code:


' Timer
Private Sub Timer1_Timer()

TotalTenthSeconds = TotalTenthSeconds + 2.5
TotalSeconds = Int(TotalTenthSeconds / 10)
Seconds = TotalSeconds Mod 60
Minutes = Int(TotalSeconds / 60) Mod 60
Hours = Int(TotalSeconds / 3600)
AllSeconds = TotalSeconds

' update the label
label1 = Format((Hours), "0") & ":" & Format(((Minutes) Mod 60), "00") & ":" & Format(((Seconds) Mod 60), "00")


'write time to the txt file.......
Call WriteFile("c:TIMER.txt", ReadFile("c:TIMER.txt"))

End Sub


'File Handling Reading

Public Function ReadFile(FileName As String) As String

Dim i As Integer
i = FreeFile

On Error GoTo ErrorTrap

Open FileName For Input As #i
ReadFile = Input(LOF(i), i)
Close #i

Exit Function

ErrorTrap:

ReadFile = ""

End Function



'File Handling Writing

Public Sub WriteFile(FileName As String, ip As String)


Dim i As Integer

i = FreeFile

ip = Winsock1.LocalIP

'you can change from Append to Output here

Open FileName For Append As #i

Print #i, Format(Now, "dd/mm/yy,") & Format(Now, "hh:mm:ss,"); sGetComputerName; ","; ip; ","; AllSeconds;
Close #i


End Sub
.......................................................

Help! Please..............

Sequential Files...ouch
Learning Newbie and am soooo stuck....

Scenario:
(2) sequential files (2) multi select listboxes
use additem/removeitem between both listboxes

Problem:
at form close i need to replace sequential files with modified
listboxes

without going into all the gory details...i can't make it work
any help would be so appreciated...

Reading Sequential Files
I need help.

I can get the length of a sequential file with the LOF function.

As I read the file field by field, is there a fuction that will tell me either how many bytes I've read, or how many bytes are left to be read?

Thanks so much.

Sequential Files???? Clearing HELP!!
i have to clear my file of the month that i select. ready for the next months data input how do i do this. i know how to use the input statement but not the output statement.?? i need help for this is a report assignment. thanks kanga

Read From Sequential Files
we have an input file how do we read certain columns and lines of text out of this ???

Opening Sequential Files
I have a sequential text file, Clients.txt, and when my form loads I would
like the first record only to be displayed - that's if it exists! Initially
Clients.txt is blank. Well I 'm getting error messages when the below code
is triggered for an empty file.



Private Sub Form_Load()

Dim Firstrec As Boolean



Firstrec = False



FileName = App.Path & "Clients.txt"

Open FileName For Input As #1



Do While Not (EOF(1) Or (Firstrec = True))

Call ReadCLientRec

Call DisplayClientRec

Firstrec = True

Loop



Close #1

End Sub



What's up with this VB6 code and is there an easier approach? Any help
would be appreciated

Thanks

Geoff

Sequential Text Files?
Hey Guys,

ok i have a simple interface, Text Boxes named as follows:

txtName
txtAddress1
txtAddress2
txtAddress3
txtPostcode

and

cmdAdd

i want to be able to input details click add and this will add the text to a sequential text file. how do i start?

Searching Sequential Text Files
Hey im doing a project where i get 4 pieces of data from and individual and then write it to a file.

First it gets thier name, then age, then the location of there picture on the hard drive, then a brief description. It writes all this to the same line

I want some code that when a button is pressed it asks for a criteria to search for and then searches the details of each person for that word, when the word is found it will display the name and age of that person.

cheers

List Boxes And Sequential Files
Can someone please help--I'm desperate!

I have a program due tomorrow. We are to have 2 list boxes. One that pulls inventory from a text file. The text file contains the product description, upc code, and price. When the user clicks on it, it should shift to the "Shopping Cart" list box and the price is supposed to be added to a running total. I've got the lists populating correctly using the text file info, but can't seem to get the price to isolate for the item so I can keep a running total. Does anyone have any idea how to do this?

Thanks so much!
sslucas

Keeping Sequential Files In A MDB File
I have been keeping some simple Ascii text in a sequential file using the old style Open and Print # commands, but would now like to keep this in the actual MDB files so it is all in one place and easier to backup. It is simple things like what you typically find in a INI file. Since each line is not really a record, I am not sure where to begin. I am familiar with defining the table name, fields and indexes with normal tables. In essence it is a simple 1 dimensional array of 50 elements. Would you define 50 fields and only have 1 record in it or what?

Any suggestions would be appreciated.

Mickey

Copyright © 2005-08 www.BigResource.com, All rights reserved