Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 20th, 2003, 04:15 AM
TripLP TripLP is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 9 TripLP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Printing

I have a program that needs to print out tax reciepts from a database and I set it up graphically in a new form the use the printform command but on the machine I'm installing it on the screen area is much smaller and it only prints what fits on the screen... what do i do?

Reply With Quote
  #2  
Old August 20th, 2003, 08:29 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
You either have to make the form fit to the screen (no matter the size of the screen) or print in a different method. Like printing to a file, or using crystal reports (or a reporting tool like that).

Also, your subject title is unacceptable. You can refer to the sticky thread at the top of this forum for more information on how to post a question.

Reply With Quote
  #3  
Old August 20th, 2003, 03:01 PM
TripLP TripLP is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 9 TripLP User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There is no way to make visual basic print a full page of info on a 15inch moniter with 1280x1024 max resolution without using crystal reports then? All right, thanks

Reply With Quote
  #4  
Old October 28th, 2003, 07:34 AM
Alfredo Alfredo is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 2 Alfredo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi i have the same problem, but i donīt understand how can i print the form to a file or crystal reports???

Reply With Quote
  #5  
Old October 28th, 2003, 07:38 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,171 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 37 sec
Reputation Power: 110
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
well.. can you print an HTML encoded string to the monitor? It would at least give you the ability to print out a marked-up text document
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #6  
Old October 28th, 2003, 08:52 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Print with vb:
Two basic possibilities...

1, reference Word and use the word object to load and print the required document

2, use SHELLECECUTE API to call print the document.

If all you want to do is print the doc, I would say option 2 is the easiest way. If you want to do error trapping and other thigns then use #1


example of #2 option...

shellexecute 0,"print","c:\windows\desktop\mydoc.doc","","",SW_SHOW


This method works for anything that can be printed not just Word Docs. As long as Windows knows how to PRINT that is.

Printing with VB

Unsurprisingly, Visual Basic provides us with the Printer and Printers objects, which are available at runtime to all VB apps. The Printers object gives us information about all the available printers installed on the system. The Printer object controls all the output to the active printer and retrieves information such as the printer name.

First of all, lets look at the basic steps involved in printing with VB. First off, we send all the data we want to print using the Print method. For example, if we wanted to print "Hello", we would call

Printer.Print "Hello"

Each time you call the Print method, your output will move to the next line. So,

Printer.Print "Hello"

Printer.Print "Goodbye!"

would appear as

Hello

Goodbye!

on paper.

If you want to output a new page, you simply call the NewPage method:

Printer.NewPage

Once you have finished outputting the data to the printer, you need to call the EndDoc method:

Printer.EndDoc

Windows will then spool your document to the printer.

Setting formatting options

Using the Printer object further, you can also apply formatting to the text you output by setting the Font and its associated FontSize, FontBold, FontItalic, FontStrikeThru and FontUnderline properties. To change the font, simply change the FontName property. For example,

Printer.FontName = "Tahoma"

changes the font to Tahoma. To change the size, just call Printer.FontSize. Most of the other formatting options are just boolean (ie True or False), which makes it even easier to apply formatting. The code below gives a simple demonstration:

With Printer

Printer.Print "Normal Line"

.FontBold = True

Printer.Print "Bold Line"

.FontItalic = True

Printer.Print "Bold and Italic Line"

.FontBold = False

.FontItalic = False

Printer.Print "Second Normal Line"

.EndDoc

End With

[Note] Although I am using a With statement, I still have to write Printer.Print for outputting the text. This is another 'quirk' of VB - the Print statement does not actually belong to the Printer object, or in fact any other object in VB. If you search for Print in the Object Browser (press F2), you won't find it anywhere. Print is in fact a statement that VB interprets on its own, and outputs it according to the object before the Print statement. If you call PictureBox1.Print, it will 'print' the text into the PictureBox control. As such, the Print function behaves just as if it were an object of PictureBox or Printer. However, the designers of VB obviously didn't extend this behavior to With statements. [End Note]

For a full list of font options, go to the Object Browser (F2), and select Printer from the Classes list.

One other thing worth noting regarding formatting... If you are using the RichTextBox control, you don't need to worry about applying all the formatting - there is some code using API calls which does it all for you, including page margins! Click here to see that code.

Setting the alignment of text isn't quite so simple because VB doesn't provide an align property. Instead, we need to work out where the middle of the page is and then take into account the width of the text. Take a look at this code, which prints the page number in the middle of the page:

sMsg = "Page " & Printer.Page ' Print Page number

HWidth = Printer.TextWidth(sMsg) / 2 ' Get one-half width.

HHeight = Printer.TextHeight(sMsg) /2 ' Get one-half height.

Printer.CurrentX = Printer.ScaleWidth / 2 - HWidth

Printer.CurrentY = Printer.ScaleHeight / 2 - HHeight

Printer.Print sMsg

This code uses the CurrentX and CurrentY variables to change the position of where the text is outputted, centers the position, and prints the page number using the Printer's Page property. If you want the text in the middle at the top of the page, simply comment out the Printer.CurrentY line.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Printing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway