Click here to Skip to main content
15,879,683 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Remote Debugging in Visual Basic 6.0 Pin
Eddy Vluggen19-May-12 0:51
professionalEddy Vluggen19-May-12 0:51 
QuestionNeed advice on printing reports from Visual Basic Pin
kentuckyjoe16-May-12 15:26
kentuckyjoe16-May-12 15:26 
AnswerRe: Need advice on printing reports from Visual Basic Pin
Dave Kreskowiak17-May-12 2:01
mveDave Kreskowiak17-May-12 2:01 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe17-May-12 15:24
kentuckyjoe17-May-12 15:24 
AnswerRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1123-May-12 8:28
dg6yhw1123-May-12 8:28 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe23-May-12 9:36
kentuckyjoe23-May-12 9:36 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe23-May-12 11:09
kentuckyjoe23-May-12 11:09 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1123-May-12 11:55
dg6yhw1123-May-12 11:55 
I don't use a PrintDocument control either. Just the printer.

Here's a complete sub we currently use

Public Sub PrintMaintenanceRenewalLetters( _
rsIn As ADodb.Recordset, _
PayDOSCustomersIn() As String, _
DoingReminderIn As Boolean, _
Optional StartFromIn As Integer = 1, _
Optional Recs2Print As Integer = 9999, _
Optional CustNumberIn As String = "-X")

Dim CustNoHold As String
Dim LastLine As Single
Dim iCtr As Integer
Dim StateTablesBought As Integer
Dim CDAdder As Currency
Dim ExtPrice As Currency
Dim ExtFreight As Currency
Dim SalesTax As Currency
Dim QtyBought As Long
Dim BkMark As Variant

' Const FED_PART_NO As String = "87FEDST-03"
' Const FED_DESCRIPTION As String = "Tax Table Service Fed + 1 State"
' Const FED_PRICE As Currency = 45#
' Const OLD_FED_PART_NO As String = "87003-04"
Const FREIGHT_CHARGE As Currency = 3.95

LastLine = Printer.Height - 1440

Dim Ctr As Integer
Ctr = 0
CustNoHold = ""
If StartFromIn > 1 Then
Do
If Trim(rsIn![Customer_Number]) <> CustNoHold Then
CustNoHold = Trim(rsIn!Customer_Number)
Ctr = Ctr + 1
End If
rsIn.MoveNext
Loop Until Ctr = StartFromIn
rsIn.MoveNext
CustNoHold = ""

ElseIf CustNumberIn <> "-X" Then

Do
If Not rsIn.EOF Then
rsIn.MoveNext
If rsIn.EOF Then Exit Do
End If
Loop Until (Trim(rsIn![Customer_Number]) = CustNumberIn) Or rsIn.EOF

If rsIn.EOF Then
MsgBox "Customer Number " & CustNumberIn & " not found!", vbCritical + vbOKOnly, "Error"
Exit Sub
End If
CustNoHold = ""
End If

Do

Do
If Trim(rsIn![Customer_Number]) <> CustNoHold Then
If CustNoHold <> "" Then

' Print the CD adder
Printer.FontBold = True
Printer.ForeColor = vbRed
Printer.Print
Printer.CurrentX = DESCRIPTION_LEFT
Printer.Print "____";
Printer.CurrentX = DESCRIPTION_LEFT + 450
Printer.Print "Please send my services on a CD"
Printer.CurrentX = DESCRIPTION_LEFT + 450
Printer.Print "instead of by e-mail."
Printer.CurrentX = DESCRIPTION_LEFT + 450
Printer.Print "I am adding " & Format(CDAdder, "currency") & " to the Total Price."
Printer.ForeColor = vbBlack

' Print the totals
m_TotalFreight = 0
Printer.CurrentY = m_Line1Y
Printer.CurrentX = RightJustify(Format(m_TotalPrice, "currency"), Printer, 10000)
Printer.Print Format(m_TotalPrice, "currency")

If InStr(CustomerLabel.CityStZip, " AZ ") Then
SalesTax = RoundPerIRS(CCur(m_TotalPrice * SALES_TAX_RATE))
Printer.CurrentY = m_Line2Y
Printer.CurrentX = RightJustify(Format(SalesTax, "currency"), Printer, 10000)
Printer.Print Format(SalesTax, "currency")
End If

' Printer.CurrentY = m_Line3Y
' Printer.CurrentX = RightJustify(Format(m_TotalFreight, "currency"), Printer, 10000)
' Printer.Print Format(m_TotalFreight, "currency")
'
Printer.CurrentY = m_Line4Y
Printer.CurrentX = RightJustify(Format(m_TotalPrice + SalesTax + m_TotalFreight, "currency"), Printer, 10000)
Printer.Print Format(m_TotalPrice + SalesTax + m_TotalFreight, "currency")
Printer.FontBold = False

If CustNoHold = CustNumberIn Then
Printer.EndDoc
rsIn.Close
Exit Sub
Else
Printer.NewPage
End If
End If

If LoadCustomerLabel(rsIn!Customer_Number) Then

m_TotalPrice = 0
CDAdder = 0
SalesTax = 0
m_TotalFreight = 0
StateTablesBought = 0
' Print either the IS or PAYROLL order

If DoingReminderIn Then
PrintRenewalReminderOrderForm
Else
PrintRenewalOrderForm
End If

m_Line5Y = 10100


CustNoHold = Trim(rsIn!Customer_Number)

Printer.FontSize = 9
Printer.Font = "Arial"

Printer.CurrentX = LETTER_LEFT_MARGIN
Printer.CurrentY = 5.525 * 1440
Printer.Print CustomerLabel.Name

Printer.CurrentX = LETTER_LEFT_MARGIN
Printer.Print CustomerLabel.Company

Printer.CurrentX = LETTER_LEFT_MARGIN
Printer.Print CustomerLabel.Address; " "; CustomerLabel.Suite

Printer.CurrentX = LETTER_LEFT_MARGIN
Printer.Print CustomerLabel.CityStZip

Printer.CurrentX = LETTER_LEFT_MARGIN
Printer.Print CustomerLabel.Phone

Printer.ForeColor = vbRed
Printer.FontSize = 10
Printer.Font = "Arial"
Printer.CurrentX = LETTER_LEFT_MARGIN
If InStr(CustomerLabel.eMail, ";") Then
Printer.Print Left(CustomerLabel.eMail, InStr(CustomerLabel.eMail, ";") - 1)
Else
Printer.Print CustomerLabel.eMail
End If
Printer.ForeColor = vbBlack


Printer.CurrentY = m_Line5Y

End If

End If

Printer.FontSize = 8

Printer.CurrentX = QTY_LEFT
QtyBought = CLng(rsIn![Qty])


If IsNull(rsIn![Description]) Then
GoTo BadRecord
' MsgBox "Bad record. Item Number " & rsIn!Item_Number & " has no description. Aborting", vbCritical + vbOKOnly
' Printer.EndDoc
' rsIn.Close
' Exit Sub
Else

Printer.Print QtyBought;
Printer.CurrentX = ITEM_NUMBER_LEFT
Printer.Print rsIn!Item_Number;

Printer.CurrentX = DESCRIPTION_LEFT

If Printer.TextWidth(Trim(rsIn![Description])) > 3600 Then
Printer.Print Left(rsIn![Description], 40) & ". . .";
Else
Printer.Print rsIn![Description];
End If
Printer.CurrentX = RightJustify(Format(rsIn![Retail], "currency"), Printer, m_lRgtOfList)
Printer.Print Format(rsIn![Retail], "currency");
ExtPrice = QtyBought * rsIn![Retail]
CDAdder = CDAdder + (QtyBought * CD_FEE)
' ExtFreight = QtyBought * FREIGHT_CHARGE
Printer.CurrentX = RightJustify(Format(ExtPrice, "currency"), Printer, m_lRgtOfDiscount)
Printer.Print Format(ExtPrice, "currency");
' Printer.CurrentX = RightJustify(Format(ExtFreight, "currency"), Printer, m_lRgtOfNet)
Printer.Print 'Format(ExtFreight, "currency")
m_TotalPrice = m_TotalPrice + ExtPrice
' m_TotalFreight = m_TotalFreight + ExtFreight
End If
BadRecord:
rsIn.MoveNext

Loop Until (Printer.CurrentY >= LastLine) Or rsIn.EOF Or g_lTotalRecordsPrinted = Recs2Print

If Not rsIn.EOF Then
Printer.NewPage
Else
m_TotalFreight = 0
' Print the totals
Printer.CurrentY = LastLine - 720
Printer.CurrentX = DESCRIPTION_LEFT
Printer.Print "____";
Printer.CurrentX = DESCRIPTION_LEFT + 450
Printer.Print "Please send my services on a CD instead of by e-mail."
Printer.CurrentX = DESCRIPTION_LEFT + 450
Printer.Print "I am adding " & Format(CDAdder, "currency") & " to the Total Price."

Printer.FontBold = True
Printer.CurrentY = m_Line1Y
Printer.CurrentX = RightJustify(Format(m_TotalPrice, "currency"), Printer, 10000)
Printer.Print Format(m_TotalPrice, "currency")

If InStr(CustomerLabel.CityStZip, " AZ ") Then
SalesTax = RoundPerIRS(CCur(m_TotalPrice * SALES_TAX_RATE))
Printer.CurrentY = m_Line2Y
Printer.CurrentX = RightJustify(Format(SalesTax, "currency"), Printer, 10000)
Printer.Print Format(SalesTax, "currency")
End If

' Printer.CurrentY = m_Line3Y
' Printer.CurrentX = RightJustify(Format(m_TotalFreight, "currency"), Printer, 10000)
' Printer.Print Format(m_TotalFreight, "currency")

Printer.CurrentY = m_Line4Y
Printer.CurrentX = RightJustify(Format(m_TotalPrice + SalesTax + m_TotalFreight, "currency"), Printer, 10000)
Printer.Print Format(m_TotalPrice + SalesTax + m_TotalFreight, "currency")
Printer.FontBold = False
End If
DoEvents
Loop Until rsIn.EOF Or (g_lTotalRecordsPrinted >= Recs2Print)

Printer.EndDoc

rsIn.Close

Note it doesn't use stdfont because I didn't need to change the fonts. In those cases, the printer properties work well.
Murray (not Ben)

GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe23-May-12 14:18
kentuckyjoe23-May-12 14:18 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe23-May-12 14:56
kentuckyjoe23-May-12 14:56 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1124-May-12 6:01
dg6yhw1124-May-12 6:01 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe24-May-12 14:10
kentuckyjoe24-May-12 14:10 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1125-May-12 5:48
dg6yhw1125-May-12 5:48 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe25-May-12 8:22
kentuckyjoe25-May-12 8:22 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1129-May-12 6:14
dg6yhw1129-May-12 6:14 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe29-May-12 16:42
kentuckyjoe29-May-12 16:42 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1130-May-12 5:51
dg6yhw1130-May-12 5:51 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe30-May-12 6:42
kentuckyjoe30-May-12 6:42 
GeneralRe: Need advice on printing reports from Visual Basic Pin
dg6yhw1130-May-12 8:42
dg6yhw1130-May-12 8:42 
GeneralRe: Need advice on printing reports from Visual Basic Pin
kentuckyjoe30-May-12 16:31
kentuckyjoe30-May-12 16:31 
QuestionHow to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir15-May-12 4:04
rusydan.khir15-May-12 4:04 
AnswerRe: How to semd sms more than 160 character in 0ne SMS? Pin
Dave Kreskowiak15-May-12 4:21
mveDave Kreskowiak15-May-12 4:21 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir16-May-12 6:15
rusydan.khir16-May-12 6:15 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
Dave Kreskowiak16-May-12 7:04
mveDave Kreskowiak16-May-12 7:04 
GeneralRe: How to semd sms more than 160 character in 0ne SMS? Pin
rusydan.khir19-May-12 5:04
rusydan.khir19-May-12 5:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.