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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Input/Output

Status
Not open for further replies.

jkejke

Programmer
Jan 18, 2001
35
US
just some general help--does anyone know of a good book on this subject--getting ready to start a project where the user will receive diskettes--need to check for two file names (two different formats)--after checking for file name reads file puts data elements into a common table--then will upload to mainframe--and to existing database--only problem is reading diskette--Know it is simple but can not seem to get it togather--

Thanks
 
Doesn't really need a book. The example below reads a file. Look up the bits of it in help, I think there are
examples.

lHnd = FreeFile
Open cDirectory & Left$(cFile, Len(cFile) - 3) & "gda" For Input As #lHnd 'Open data File
Do Until EOF(lHnd)
Line Input #lHnd, temp
If Left$(UCase$(temp), 9) = "[POSTCARD" Then Exit Do
Loop
Close #lHnd
Peter Meachem
peter@accuflight.com
 
You can use the Dir list box example in the VB docs if you just want to know if a file exists, alternately you can open any file, no matter what it is as a binary file. Use "On Error Goto" if it raises an error "file not found" then it doesn't exist. If no error is raised, just close it.

On Error Goto ErrorDoesntExist
Open filename for binary as #1
Close #1
ErrorDoesntExist:
If err <> 0 then msgbox (&quot;Error file does't exist&quot;)
If err = 0 then msgbox(&quot;File exists, OK&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top