?
Solved

Printing Contents of a Frame etc. using visual basic 6.

Posted on 2004-10-16
9
Medium Priority
?
564 Views
Last Modified: 2013-11-25
Hello, i am making a program that requirs to print a sort of invoice thing you could call it.  and i need to print out the invoice.  I have all the details in seperat lables all on one frame and was how you print the frame or/and the contents of the frame if it is even possible.  Or is there a better way of printing, i dont know much about printing with visual basic so any suggestions would be greatly appersiated.

Thanx

Gary
0
Comment
Question by:Gary_4500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 12

Accepted Solution

by:
Bob Lamberson earned 80 total points
ID: 12330903
Hi Gary_4500,
Since you will eventually want to include data with your invoice, you would be better off creating the invoice as a DataReport.
Right click on the project in the Project Explorer and select DataReport and it will add a template for you to work from, which will allow you to programmatically add data and print the report.

Bob
0
 

Author Comment

by:Gary_4500
ID: 12333110
Yeah but i have no idea how data reports work or even where to start with them?
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 12333305
> Right click on the project in the Project Explorer and select DataReport
> and it will add a template for you to work from
Check the help file and if you have specific questions, post them.
Bob
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Gary_4500
ID: 12333439
I can add it and all that, but when i run it it says invalid data source.  i looked on the  microsoft web site and it says you have to add all this data enviroment (which i dont have or cant find).  and i cant look at the help files cause i dont have the msdn disc.
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 12334565
Gary_4500,
You will need the OCT2001 MSDN file to be able to access the vb6 help files. You will need this as you are learning how to use vb. I was unable to find a download source for the file and I would recommend that you post a question asking if anyone knows a source for that file.
Bob
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12345955
Printing an invoice really simply would just require invoking the PrintForm method of an invoice form:

     frmInvoice.Printform

but it's by far the prettiest.

Last time i needed to print an invoice, I outputted it to a text file, using some HTML formatting I knew, and printed it from a browser control, e.g.:

     Type Item
              Number as Long
              Name as String
              Quantity as Integer
              UnitPrice as Currency
     End Type

     Dim arrItems(1 To 5) as Item
     Dim curSubtotal as Currency
     Dim sngTax as Single

     sngTax = 0.175             '<--- UK SALES TAX/VAT MULTIPLIER (17.5%)

     Open App.Path & "\Invoices\" & lngInvoiceNo & ".htm" for Output as #1

              Print #1, "<HTML>"
              Print #1, "<HEAD><TITLE>Invoice #" & lngInvoiceNo & "</TITLE></HEAD>"
              Print #1, "<BODY>"
              Print #1, "<TABLE>
              Print #1, "<TR><TD>Customer Name:</TD><TD>" & strCustomerName & "</TD></TR>"
              Print #1, "<TR><TD>Customer Address:</TD><TD>" & strCustomerAddress1 & "<BR>" & _
                                                                                                 strCustomerAddress2 & "<BR>" & _
                                                                                                 strCustomerTown & "<BR> & _
                                                                                                 strCustomerCounty & "<BR> & _
                                                                                                 strCustomerPostCode & "</TD></TR>
              '...YOUR HEADER FIELDS
             
              Print #1, "</TABLE>"
              Print #1, "<HR>"
              Print #1, "<TABLE>"
              Print #1, "<TR><TD>No</TD><TD>Desc</TD><TD>Unit</TD><TD>Qty</TD><TD>Total</TD></TR>
             
              For i = LBound(arrItems) to UBound(arrItems)

                    Print #1, "<TR><TD>" & arrItems(i).Number & "</TD>" & _
                                          "<TD>" & arrItems(i).Name & "</TD>" & _
                                          "<TD>" & arrItems(i).UnitPrice & "</TD>" & _
                                          "<TD>" & arrItems(i).Quantity & "</TD> " & _
                                          "<TD>" & arrItems(i).Quantity * arrItems(i).UnitPrice & "</TD></TR>"

                    curSubtotal = curSubtotal + (arrItems(i).Quantity * arrItems(i).UnitPrice)

              Next i

              Print #1, "<TR><TD colspan=4>Subtotal:</TD><TD>" & curSubtotal & "</TD></TR>"
              Print #1, "<TR><TD colspan=4>Tax:</TD><TD>" & curSubtotal * sngTax & "</TD></TR>"
              Print #1, "<TR><TD colspan=4>Total:</TD<TD>" & curSubtotal+(curSubtotal*sngTax) & "</TD></TR>"

              Print #1, "</TABLE>"
              Print #1, "</BODY>"
              Print #1, "</HTML>"

      Close #1

      WebBrowser1.Navigate(App.Path & "\Invoices\" & lngInvoiceNo & ".htm")
                                                                                'SHOW THE GENERATED INVOICE
     
      WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0
                                                                                'PRINT THE CONTENTS OF THE BROWSER OBJECT

You'd have to change the variables, etc, to match your data, but this was the simplest method I found (so long as you know a little HTML).

HTH

J.
0
 
LVL 12

Expert Comment

by:Bob Lamberson
ID: 12529674
Gary - did you get your question answered or is there anything we can help with?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question