Printing a simple report
The printing routine I use in CodeLib is pretty plain, but it still can be
used to show you how to print out data. In printing you may often want
to precisely determine where a print action is to take place, and that
means you would be setting the .CurrentX and .CurrentY properties. If
you simply follow one print statement after another then VB will simply
set the CurrentX and CurrentY values to correspond to normal lines of
print one below the other starting at the left margine of the page.
That's what I do in CodeLib.
Printer.Print "VB Information Center Code Librarian"
Printer.Print
Printer.Print
For i = StartSnippet To EndSnippet
Printer.Print "Title:"; Tab(15); Code(i).title
Printer.Print "Keywords:"; Tab(15); Code(i).keywords
Printer.Print
Printer.Print Code(i).CodeLines
Printer.Print
Printer.Print "=================================================="
Printer.Print
Next i
Printer.EndDoc
Reading sequential text files
I often need to read a sequential text file, either to grab the whole thing
or to take action on a line by line basis. The CodeLib library is a binary
file, but the credits listed in the About form are kept in a sequential
file called "credits.txt". The following code is from the frmAbout load
event and shows two different ways to read in the sequential text file.
Private Sub Form_Load()
Dim tempString As String
ChDir App.Path
Open "credits.txt" For Binary As #1
tempString = Input(LOF(1), #1) 'reads the whole file with a single line of code
Close #1
txtCredits.Text = tempString
'The following code is an alternate way of reading a text file
'reading one line at a time
'Dim temp As String, message As String
'load credits file
'ChDir App.Path
'Open "credits.txt" For Input As #1
'While Not EOF(1)
' Line Input #1, temp
' message = message & vbCrLf & temp
'Wend
'Close #1
'txtCredits.Text = message
To Database or Not?
I plan to release a second version of CodeLib in a few weeks. The second
version will not be a replacement of this one. It will use VB database
capabilities (versus the binary file handling used in this version of CodeLib),
and will be useful in showing how the application of database features can
both be helpful as well as cause problems in writing and releasing an
application.
CodeLib Revision History
- Version 1.8 - 10 June 1999
- Added a simple game under the HELP menu
- Added API code to show how to execture a WAV file (in the game)
- Added code to show how to implement drag & drop (in the game)
- Version 1.7 - 08 May 1999
- Added API code to keep the CodeLib window on top
- Added API code to start the default browser at Gary Beene's VB Information Center
- Version 1.6 - 30 April 1999
- Updated database to include the API references from my tutorial
- Corrected problem with data corrupting during edit
- Version 1.5 - 29 April 1999
- Added option to stop display of splash screen by double-clicking label
- Version 1.4 - 29 April 1999
- Added right-mouse popup menus
- Version 1.3 - 28 April 1999
- Corrected problem with Save/Delete giving error
- Corrected path problem with reading the CodeLib database