Tutorial 6
o Opening a file
§
Open <strPathName> for <mode> as # <fileNumber>
·
StrPathName – absolute or relative path of file to be opened
o “C:\temp\test.txt”
o “test.txt” looks for file
in current directory
o strFileName - string variable that contains fileName
·
mode
o Input – read data from
file
·
If file does not exist VB throws an error
o Use on error to catch
§
ON ERROR GOTO FILERROR
§
:FILERROR
o Output – write data to
file, overwriting current data
o Append – adds data to end
of file
§
File created if it does not exist
o Writing to a sequential
file
§
Write # filenumber , <variable>
o Closing a file
§
Close #filenumber
o EOF function
§
eof(filenumber) – return true if end of file reached on read(nothing
more to read)
o Read a record
§
Input # fileNumber, <variables>
·
Printing
o Printer.print <string
to print>
§
; - hold print position
§
, next tab position
§
examples
·
printer.print “LastName”, 123;
§
spc(#) – adds number of space inside () to print stream
§
tab(10) – moves to print position 10
o printer.font
§
property that controls font type
·
printer.font = “courier new”
o courier new is fixed space
font(monospaced)
·
printer.font = “ms sans serif”
o proportional
o printer.fontsize
§
point size of printer text
Menus
String
Manipulation