home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Mother of All Windows Books
/
CD-MOM.iso
/
cd_mom
/
newsletr
/
vbz
/
vbz1-3
/
prntform.bas
< prev
next >
Wrap
BASIC Source File
|
1993-06-25
|
3KB
|
106 lines
Sub PrintFormatted (TheText, Title, TopMargin, LeftMargin, BodyBottomMargin, BottomMargin, BaseFont, BaseFontSize, HeadlineMultiplier)
printer.ScaleMode = 5 'inches
printer.FontName = BaseFont
printer.FontBold = False
PageCount = 1
cr$ = Chr$(13)
nl$ = Chr$(13) + Chr$(10)
TheText = TheText + cr$
'Print a big title
CurSize = printer.FontSize
printer.FontSize = HeadlineMultiplier * CurSize
printer.FontBold = True
printer.CurrentY = TopMargin
printer.CurrentX = LeftMargin
printer.Print Command$ + nl$
printer.FontBold = False
printer.FontSize = CurSize
temp$ = TheText
'Peel off one line at a time from the text from the clipboard
While Len(temp$) > 1
DidAFooter = False
prtstr$ = Left$(temp$, InStr(temp$, cr$) - 1)
rightamount = Len(temp$) - Len(prtstr$) - 2
If rightamount <= 0 Then
temp$ = ""
Else
temp$ = Right$(temp$, rightamount)
End If
'Print each line
printer.CurrentX = LeftMargin
PrintIt prtstr$
ok = DoEvents()
'New Page Routines:
'Would another line put us past the textbody bottom margin?
If printer.CurrentY + printer.TextHeight("J") > printer.ScaleHeight - BodyBottomMargin Then
printer.FontBold = True
printer.CurrentX = LeftMargin
printer.CurrentY = printer.ScaleHeight - (BottomMargin)
printer.Print Title + " - Page " + Format$(PageCount)
printer.FontBold = False
printer.NewPage
printer.CurrentY = TopMargin
PageCount = PageCount + 1
DidAFooter = True
End If
Wend
'You might need a footer for the last page
If DidAFooter = False Then
printer.FontBold = True
printer.CurrentY = printer.ScaleHeight - (BottomMargin)
printer.CurrentX = LeftMargin
printer.Print Title + " - Page " + Format$(PageCount)
printer.FontBold = False
End If
printer.EndDoc
End Sub
Sub PrintIt (txt)
If InStr(txt, "\") Then
For x = 1 To Len(txt)
thechar = Mid$(txt, x, 1)
If thechar <> "\" Then
chunk = chunk + thechar
Else
printer.Print chunk;
chunk = ""
x = x + 1
token = Mid$(txt, x, 1)
Select Case token
Case "b"
printer.FontBold = False
Case "B"
printer.FontBold = True
Case "i"
printer.FontItalic = False
Case "I"
printer.FontItalic = True
Case "U"
printer.FontUnderline = True
Case "u"
printer.FontUnderline = False
End Select
End If
Next
printer.Print chunk
Else
printer.Print txt
End If
End Sub