VB programming for printing formatted text
VB programming for printing formatted text
(OP)
Can anyone please provide a sample code or hint how to program formatted text printing with fonts specified in VB.
thanx in advance
Narendranath
Narendranath R
narenr@narendranath.itgo.com
http://www.narendranath.itgo.com
Pipeline engineering is made easy with state of the art computer software, visit www.narendranath.itgo.com.
thanx in advance
Narendranath
Narendranath R
narenr@narendranath.itgo.com
http://www.narendranath.itgo.com
Pipeline engineering is made easy with state of the art computer software, visit www.narendranath.itgo.com.





RE: VB programming for printing formatted text
RE: VB programming for printing formatted text
Note: cdOne is the common dialog control...
Private Sub cmdPrint_Click()
Dim i As Integer
Dim count As Integer
Dim searchedFrom As String
Dim searchedTo As String
Dim defaultPrinter As String
'diable the print button
cmdPrint.Enabled = False
searchedFrom = CStr(dtpFrom.Month) + "/" + CStr(dtpFrom.Day) + "/" + CStr(dtpFrom.Year)
searchedTo = CStr(dtpTo.Month) + "/" + CStr(dtpTo.Day) + "/" + CStr(dtpTo.Year)
count = lsvResults.ListItems.count
'have the printer dialog come up and allow the user to pick a default printer
Const ErrCancel = 32755
cdOne.CancelError = True
On Error GoTo errorPrinter
cdOne.Flags = 64
'see the Help on Flags Properties (Print
' Dialog)
cdOne.PrinterDefault = True
cdOne.ShowPrinter
MsgBox "Printing....", vbInformation, "Print"
mouseWait 'show the hourglass to indicate that it may take a while
Printer.FontName = "Arial"
Printer.FontBold = True
Printer.FontSize = 7
'================================
Printer.Print "Printed on: " + Format$(Now, "dddd, mmm dd, yyyy hh:mm AM/PM")
Printer.Print "Search String: " + cmbSearch.Text
If chkDate.Value = vbChecked Then 'then print the date range, otherwise do not
Printer.Print "Date Range: " + searchedFrom + " To " + searchedTo
Else
Printer.Print "Date Range: All Available Alarm Files "
End If
'================================
Printer.FontBold = False
Printer.FontSize = 7.5
'================================
Printer.Print " "
Printer.Print "MM DD YY"
Printer.FontSize = 10
For i = 1 To count
Printer.Print lsvResults.ListItems(i).Text 'this may start at zero and may need to be changed
If i Mod 60 = 0 Then 'start a new page
Printer.Print " "
Printer.Print " "
Printer.Print " Page " + Format(Printer.Page, "#,###")
Printer.NewPage
Printer.FontSize = 7
'================================
Printer.Print "Printed on: " + Format$(Now, "dddd, mmm dd, yyyy hh:mm AM/PM") '+ " Page " + Format(Printer.Page, "#,###")
Printer.Print "Search String: " + cmbSearch.Text
If chkDate.Value = vbChecked Then 'then print the date range, otherwise do not
Printer.Print "Date Range: " + searchedFrom + " To " + searchedTo
Else
Printer.Print "Date Range: All Available Alarm Files "
End If
'================================
Printer.FontBold = False
Printer.FontSize = 7.5
Printer.Print " "
Printer.Print "MM DD YY"
Printer.FontSize = 10
End If
Next i
'================================
Dim numLinesDown As Integer 'the number of lines to drop the page number down
Dim numLinesToAdd As Integer 'number of lines to add to the last page to get the page number in the right spot
numLinesDown = count - (60 * (Printer.Page - 1))
numLinesToAdd = 63 - numLinesDown
For i = 1 To numLinesToAdd - 1
Printer.Print " "
Next i
Printer.Print " Page " + Format(Printer.Page, "#,###")
Printer.EndDoc
mouseUnWait
cmdPrint.Enabled = True
'================================
Exit Sub 'exit to avoid error handler......
errorPrinter:
If Err.Number = ErrCancel Then
Exit Sub
End If
Resume
End Sub
Troy Williams
fenris@hotmail.com
I am a recent Mining Engineering Graduate with an interest in Genetic Algorithms, Engineering and Computers and Programming. I also have an interest in mineral economics
RE: VB programming for printing formatted text
Thanx for the sample code, I had managed to print formatted text,
however I am not very comfortable to print scientific equation very
easily. Normally what I do is first write the output file from the
program and then readline and print. I am still improvising it.
Please visit my website http://www.narendranath.itgo.com/mysoftware.html
and download the "Stokes" program written in VB and advise any comments
or suggestions.
Narendranath R
narenr@narendranath.itgo.com
http://www.narendranath.itgo.com
Pipeline engineering is made easy with state of the art computer software, visit www.narendranath.itgo.com.
RE: VB programming for printing formatted text
You might also try using exotic fonts, they may at least allow you to reproduce some of the mathematical notations..
Good Luck
Troy Williams
fenris@hotmail.com
I am a recent Mining Engineering Graduate with an interest in Genetic Algorithms, Engineering and Computers and Programming. I also have an interest in mineral economics