Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003
This is the forum to discuss the Wrox book Professional VB.NET 2003 by Bill Evjen, Billy Hollis, Rockford Lhotka, Tim McCarthy, Jonathan Pinnock, Rama Ramachandran, Bill Sheldon; ISBN: 9780764559921
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 4th, 2004, 05:53 PM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Print problem in chapter 7

I am having a problem with my print testing in Chapter 7. The Text runs off the page on the right. I end up with a left margin and a top margin of 1.25 inches; however, the last 2 to 3 characters are ending up in the unprintable area on the right, ie. truncated.
   I am teaching myself to program via books such as yours. Unfortunately my Visual Studio 2003 hasn't arrived and I am trying to use the Visual Basic 2005 Express I downloaded in the interim. I have been able to work around any differences that affect your lesson except the installer section in Chapter 6 which doesn't appear to be provided with the Express version.
   Is my problem a 2005 problem or do you have a solution to this? I tried to run your copy that I downloaded and it performed the same as mine. I am using Windows XP Home on this machine if that is relevant. Any input would be helpful as I am eager to work on some applications of my own once I learn the code to apply. thank you


  #2 (permalink)  
Old August 12th, 2004, 06:01 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Kathy,

I apologize for taking so long to back to you on this.

I tried printing a large text document using the code from the book and I ran into the same problem that you described. However, since you are using Visual Basic 2005 Express, your printing problems can be corrected with very little code and effort on your part.

Visual Basic 2005 introduced the My namespace which provides a set of base classes that provides quick and easy access to the information that you as a Visual Basic .Net developer are most likely to need. The Computer class is one of these and provides access to the Printers class which provides methods to print documents with a minimal amount of code.

Using the example below, you should be able to print your document from the text box on your form and get the results that you desire.

    Private Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        'Printing using the My namespace
        With My.Computer.Printers.DefaultPrinter
            .WriteLine(txtFile.Text)
            .Print()
        End With
    End Sub

I hope this helps.

Thearon
  #3 (permalink)  
Old August 12th, 2004, 01:56 PM
Authorized User
 
Join Date: Jul 2004
Location: Bristol, , United Kingdom.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Thearon,

Just out of curiosity, although I didn't experience this problem (for 2 reasons 1) I only had a small text file, and 2) I'm too cheap to actually print it out ) I was wondering what the solution might be for us non VS 2005 users?

If I remember back to that chapter there was some code going on that got the height of the font and then used that to work out how many rows you could fit on each page etc, could a similar approach be used for getting the characters across the page? ie, page width / font width = characters across the page.

This does feel a bit messy, as I'd feel the need to then add code to not chop words in half, so count across, if its in the middle of a word - roll back - find the space - start the next line - start from that word..

Seems a bit of over kill?

Interested to hear anyone's thoughts on this - I'll go and find a bigger text file now and try the example again and see if I get the same - I'm intrigued :)


Regards

Rob
  #4 (permalink)  
Old August 13th, 2004, 05:35 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Location: Fuquay Varina, NC, USA.
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Rob,

I'm going to take the easy route on this one and point you to Microsoft for a good example. Follow this url http://msdn.microsoft.com/vbasic/downloads/samples/ and click on the link 'Download 101 Code Samples for Visual Basic .NET 2003' In there you will find a real good example on printing called 'VB.NET - Windows Forms - Simple Printing'.

Thearon
  #5 (permalink)  
Old August 14th, 2004, 04:51 AM
Authorized User
 
Join Date: Jul 2004
Location: Bristol, , United Kingdom.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Thearon,

Many thanks for the URL - will check it out now :)


Regards

Rob
  #6 (permalink)  
Old April 17th, 2008, 07:57 AM
Registered User
 
Join Date: Apr 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to create a custom page for printing (with=300,height is depend on lines are printed.).It's a bill print. Print page should be stoped just ofter finishing last line. Help with code in vb 6

 


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox problem print preview vs. print jenisageek Access 5 May 2nd, 2008 01:54 PM
print problem annie_stwg ASP.NET 2.0 Basics 0 September 18th, 2006 01:19 AM
Print Problem xanderxvr Classic ASP Professional 4 January 28th, 2005 08:05 PM
print problem madhukp Classic ASP Basics 2 August 21st, 2004 12:39 AM



All times are GMT -4. The time now is 09:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.