Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileOpen, FilePut, etc...

Status
Not open for further replies.

buddyel

MIS
Mar 3, 2002
279
US

I am working on setting up a program to output all variable data to a textfile that is distributed with the project. This is what i have so far..

FileOpen(1, "TextFile1.txt", OpenMode.binary)
FilePut(1, partno)
FileClose(1)

the work order variable is output ok but is overwritten everytime, how do i fix this and how do i output more than one variable at a time. My end goal is to have all this program working with a database, but i figured I better start with a text file and work my way up. If any of you have tips on this or the database option i would greatly appreciate it. Thank you in advance.
 

I receive a "bad file mode" message when i try to use append in place of binary.
 

I still receive the "bad file mode" error on the FILEPUT statement.
 
The bad file mode occurs on the FilePut. I do not know why.
FileOpen(1, "TextFile1.txt", OpenMode.Append, OpenAccess.Write)
FilePut(1,partno)
FileClose(1)

Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
I changed the Fileput to Writeline and it works GREAT!! Now my next step is to make sure a duplicate part number cannot be saved. How do i go about that? I am assuming a loop with a comparison against the existing part numbers, right?


 

Ok, this is what i came up with and it works wonderful. I would appreciate it if anyone can tell me if there is anyway to make it even better...

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Dim ZPART
FileOpen(1, "TextFile1.txt", OpenMode.Input)
Do While Not EOF(1)
Input(1, ZPART)
If PART = ZPART Then
MsgBox("ALREADY ON FILE")
FileClose(1)
Exit Sub
End If
Loop
FileClose(1)
FileOpen(1, "TextFile1.txt", OpenMode.Append)
WriteLine(1, PART, WORK)
FileClose(1)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top