Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 11th, 2006, 03:02 PM
Registered User
 
Join Date: Jun 2006
Location: Richardton, ND, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing in VB 2005

Printing seems to be more difficult in VB 2005 than in VB6. In VB6 I made a module that I used in several programs, it would pass information directly to the print spooler:

prntxt(Data$,Font,Size,Attribute,xLoc,yLoc) were supplied, line after line until the page was complete, and then an end document command sent it to the printer, and the document would print at that time.

These new naming conventions, and the print.document object seem to be a little over my head, but this is the protocol that I need for the projects that I build.

Can anybody point me to a resource that will help me to use the printer.

Thanks,

Elias

Reply With Quote
  #2 (permalink)  
Old July 25th, 2006, 10:05 AM
Registered User
 
Join Date: Jun 2006
Location: Oldbury, West Midlands, United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

May I suggest you look at the help files for "Walkthrough: Creating a ReportViewer Report". This will allow you to access any database and generate a report.

Reply With Quote
  #3 (permalink)  
Old August 27th, 2006, 11:40 PM
Registered User
 
Join Date: Aug 2006
Location: Madill, OK, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I could not find report template under Project ->Add New Item. Any ideas?
Thanks
Cal


Cal
Reply With Quote
  #4 (permalink)  
Old August 29th, 2006, 11:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Hi Elias,

Compact it may not be and it does seem like too much work but
printing in VB2005 is much niftier.

Read this article
http://msdn2.microsoft.com/en-us/library/9s96f6ft.aspx

You can get a printing sample at this link
http://msdn2.microsoft.com/en-us/library/54z247f9.aspx

Regards
Ankur
Reply With Quote
  #5 (permalink)  
Old January 17th, 2008, 09:34 AM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to fdagroup
Default

Hi, I am developing a report to be printed with PrintDocument class.The problem is some parts of this report are iterated and some not.In fact report consist of three sections.The top and buttom sections are always the same but middle section is being produced from Database.The problem is how to print more than one page, I tried to use HasMorePages but somehow I think I am doing something wrong.



I need to :

1-Print top and buttom sections more than one time if the data in middle section won't fit in its specified area.

2-Be able to access each new page, if possible.That way I can repeat itereated sections and write down the continued middle section.

3-Control the behaviour of HasMorePages in order to print middle section succefully.



Since this development is company-based the code I am gonna attach is protected.It cannot be used , distributed and altered under any circumstances.I am using the following code.






Code Block

While (intLastPrintedCell < strText.GetUpperBound(0))

e.HasMorePages = True

If Not intLastPrintedCell > 0 Then

Dim intDistance As Integer = 0

For i As Integer = strText.GetLowerBound(0) To strText.GetUpperBound(0)

If intDistance <= intSplit2Distance Then

text = strText(i)

If chkShowTextInBox.Checked = True Then

e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))

End If

rec.X = rea("FLEFT")

rec.Y = rea("FTOP") + intSplit1Distance + intDistance

rec.Height = rea("FHEIGHT")

rec.Width = rea("FWIDTH")

e.Graphics.DrawString(text, printFont, brsh, rec, frmt)

intDistance = intDistance + rec.Height + intFieldDistance

'e.HasMorePages = False

intLastPrintedCell = i

Else

'intLastPrintedCell = i

Exit For

'

End If

Next

Else

Dim intDistance As Integer = 0

For i As Integer = intLastPrintedCell To strText.GetUpperBound(0)

If intDistance < intSplit2Distance Then

text = strText(i)

If chkShowTextInBox.Checked = True Then

e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))

End If

rec.X = rea("FLEFT")

rec.Y = rea("FTOP") + intSplit1Distance + intDistance

rec.Height = rea("FHEIGHT")

rec.Width = rea("FWIDTH")

e.Graphics.DrawString(text, printFont, brsh, rec, frmt)

intDistance = intDistance + rec.Height + intFieldDistance

'e.HasMorePages = False

intLastPrintedCell = i

Else

'e.HasMorePages = True

'intLastPrintedCell = i + 1

'

End If

Next

End If

End While

e.HasMorePages = False





I'd apperciate any help.If you have more information about the code contact me directly.



Remember!This code snippet is protected by international laws.


Reply With Quote
  #6 (permalink)  
Old January 24th, 2008, 11:45 AM
Registered User
 
Join Date: Jan 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to fdagroup
Default

Hey everyone, me again.Does anyone know how to print to a file? I mean like after finished working with PrintPageEventArgs graphics, save that out put to a file.

Reply With Quote
  #7 (permalink)  
Old February 19th, 2008, 11:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Here is a hint, just search around a bit on PrintToFile and how to use it :)

Regards
Ankur
Reply With Quote
  #8 (permalink)  
Old February 19th, 2008, 11:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

As an aside, if you were printing in VB6 you would assign this flag to Printer class's PrintAction property. VB 2005 is backward compatible for most purposes and if it aint for some, you always have VB6 namespace at your disposal.

Regards
Ankur
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Running a VB 2005 exe file on a system without VB dilionyi Pro Visual Basic 2005 3 September 21st, 2009 07:37 PM
reg conn to sql server 2005 from vb.net 2005.. veda SQL Server 2005 2 July 1st, 2008 12:16 AM
Worked on ASP 2005 but new to VB 2005 akhilhp Visual Basic 2005 Basics 0 May 18th, 2007 12:37 AM
MS VB 2005 vs. MS VB 2005 Express NevadaBob Visual Basic 2005 Basics 2 January 24th, 2006 06:36 PM



All times are GMT -4. The time now is 07:28 AM.


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