PC Review


Reply
Thread Tools Rate Thread

A case of virtual beer in exchnage for print info!

 
 
StrandElectric
Guest
Posts: n/a
 
      23rd Jan 2011
Hi all

No-one has yet got back to me indicating how in vb.net I can address the
printer properly and print nicely formatted columns of information as I
could with vb6. Having made considerable headway with vb.net, and being
persuaded that it is a very flexible system with many options, I am sure it
must be possible (but possibly undocumented?). I do not want to print a
copy of the form on the screen. I want to print variables by name in the
horizontal position that I choose, preferably simply.

Like this pseudo code:


With Print to Printer
at tab1, MyVariableName
at tab20, MyVariableNet
at tab30, MyVariableGST
at tab40, MyVariableTotal
Linecount = Linecount +1
End With

If linecount >50 then
Lincount =0
NextPage
End If

(I've posted actual vb6 code earlier)

Also, it would be nice to access the printer dialogue box to check which of
my printers I wish to use (failing that I'd go for the default printer). I
definitely want to be able to code portrait or landscape according to the
(financial report) I want to print, like this psedo code at the start of
each report.

Like this pseudo code

Choose Printer.Orientation = Portrait

Any takers? Needing less than 10,000 lines of code please (only kidding
this last bit...)


 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      24th Jan 2011
StrandElectric explained :
> Hi all
>
> No-one has yet got back to me indicating how in vb.net I can address the
> printer properly and print nicely formatted columns of information as I could
> with vb6. Having made considerable headway with vb.net, and being persuaded
> that it is a very flexible system with many options, I am sure it must be
> possible (but possibly undocumented?). I do not want to print a copy of the
> form on the screen. I want to print variables by name in the horizontal
> position that I choose, preferably simply.
>
> Like this pseudo code:
>
>
> With Print to Printer
> at tab1, MyVariableName
> at tab20, MyVariableNet
> at tab30, MyVariableGST
> at tab40, MyVariableTotal
> Linecount = Linecount +1
> End With
>
> If linecount >50 then
> Lincount =0
> NextPage
> End If
>
> (I've posted actual vb6 code earlier)
>
> Also, it would be nice to access the printer dialogue box to check which of
> my printers I wish to use (failing that I'd go for the default printer). I
> definitely want to be able to code portrait or landscape according to the
> (financial report) I want to print, like this psedo code at the start of each
> report.
>
> Like this pseudo code
>
> Choose Printer.Orientation = Portrait
>
> Any takers? Needing less than 10,000 lines of code please (only kidding this
> last bit...)


I thought the vb power pack had some sort of printer thing similar to
VB6? Not sure though.

This may sound funny, but, I've never really done much printing in
either vb.net or even vb.classic So, I can't really advise you on
this much.

Did find this article that SEEMS, though I haven't really tried it, to
cover printing in VB.NET:

http://www.dreamincode.net/forums/to...ting-in-vbnet/

At least the basics

--
Tom Shelton


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      24th Jan 2011
Am 24.01.2011 06:01, schrieb Tom Shelton:
> http://www.dreamincode.net/forums/to...ting-in-vbnet/
>
> At least the basics


It looks promising at first sight, but then I read the word "class"
and "Inherits" which won't be considered simple enough. ;-) Not
to talk about "constructors" etc......



--
Armin
 
Reply With Quote
 
StrandElectric
Guest
Posts: n/a
 
      24th Jan 2011

"Tom Shelton" <(E-Mail Removed)> wrote in message
news:ihj13j$jaa$(E-Mail Removed)...
> StrandElectric explained :
>> Hi all
>>
>> No-one has yet got back to me indicating how in vb.net I can address the
>> printer properly and print nicely formatted columns of information as I
>> could with vb6. Having made considerable headway with vb.net, and being
>> persuaded that it is a very flexible system with many options, I am sure
>> it must be possible (but possibly undocumented?). I do not want to print
>> a copy of the form on the screen. I want to print variables by name in
>> the horizontal position that I choose, preferably simply.
>>
>> Like this pseudo code:
>>
>>
>> With Print to Printer
>> at tab1, MyVariableName
>> at tab20, MyVariableNet
>> at tab30, MyVariableGST
>> at tab40, MyVariableTotal
>> Linecount = Linecount +1
>> End With
>>
>> If linecount >50 then
>> Lincount =0
>> NextPage
>> End If
>>
>> (I've posted actual vb6 code earlier)
>>
>> Also, it would be nice to access the printer dialogue box to check which
>> of my printers I wish to use (failing that I'd go for the default
>> printer). I definitely want to be able to code portrait or landscape
>> according to the (financial report) I want to print, like this psedo code
>> at the start of each report.
>>
>> Like this pseudo code
>>
>> Choose Printer.Orientation = Portrait
>>
>> Any takers? Needing less than 10,000 lines of code please (only kidding
>> this last bit...)

>
> I thought the vb power pack had some sort of printer thing similar to VB6?
> Not sure though.
>
> This may sound funny, but, I've never really done much printing in either
> vb.net or even vb.classic So, I can't really advise you on this much.
>
> Did find this article that SEEMS, though I haven't really tried it, to
> cover printing in VB.NET:
>
> http://www.dreamincode.net/forums/to...ting-in-vbnet/
>
> At least the basics
>
> --
> Tom Shelton
>

Well Tom, I strugggled with that reference. I understood the Imports
commands but very little else, and certainly not the code that began with
#Region and used the three single quotes '''. Are those valid starts to a
line? Altogether far too long and also abstract.

It is difficult to imagine anyone in the real world neglecting printing in a
so-called serious tool that will be used in eg financial packages... And
putting it in the 'next framework' is no answer because that means any
application using it won't work in previous frameworks and can't be
presented as a universal exe file that anyone can use.

I've looked for it but can't find the syntax to use for bringing in vb6-like
printing. Can someone tell me again?



 
Reply With Quote
 
Dennis
Guest
Posts: n/a
 
      24th Jan 2011
On Sun, 23 Jan 2011 22:01:29 -0700, Tom Shelton
<(E-Mail Removed)> wrote:

>This may sound funny, but, I've never really done much printing in
>either vb.net or even vb.classic So, I can't really advise you on
>this much.


I had a customer who wanted to be able to print a DataGridView. I found
a C# class online that did the job.

Other than that, I haven't had the need to do any printing DIRECTLY from
..Net. What I do instead is either write my columnar output to a CSV file
(and open it in the default spreadsheet program), or emit HTML (and open
it in the default browser). I find this approach better than sending
data directly to a printer.

--

Dennis
 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      24th Jan 2011
StrandElectric explained :
> "Tom Shelton" <(E-Mail Removed)> wrote in message
> news:ihj13j$jaa$(E-Mail Removed)...
>> StrandElectric explained :
>>> Hi all
>>>
>>> No-one has yet got back to me indicating how in vb.net I can address the
>>> printer properly and print nicely formatted columns of information as I
>>> could with vb6. Having made considerable headway with vb.net, and being
>>> persuaded that it is a very flexible system with many options, I am sure
>>> it must be possible (but possibly undocumented?). I do not want to print
>>> a copy of the form on the screen. I want to print variables by name in the
>>> horizontal position that I choose, preferably simply.
>>>
>>> Like this pseudo code:
>>>
>>>
>>> With Print to Printer
>>> at tab1, MyVariableName
>>> at tab20, MyVariableNet
>>> at tab30, MyVariableGST
>>> at tab40, MyVariableTotal
>>> Linecount = Linecount +1
>>> End With
>>>
>>> If linecount >50 then
>>> Lincount =0
>>> NextPage
>>> End If
>>>
>>> (I've posted actual vb6 code earlier)
>>>
>>> Also, it would be nice to access the printer dialogue box to check which
>>> of my printers I wish to use (failing that I'd go for the default
>>> printer). I definitely want to be able to code portrait or landscape
>>> according to the (financial report) I want to print, like this psedo code
>>> at the start of each report.
>>>
>>> Like this pseudo code
>>>
>>> Choose Printer.Orientation = Portrait
>>>
>>> Any takers? Needing less than 10,000 lines of code please (only kidding
>>> this last bit...)

>>
>> I thought the vb power pack had some sort of printer thing similar to VB6?
>> Not sure though.
>>
>> This may sound funny, but, I've never really done much printing in either
>> vb.net or even vb.classic So, I can't really advise you on this much.
>>
>> Did find this article that SEEMS, though I haven't really tried it, to
>> cover printing in VB.NET:
>>
>> http://www.dreamincode.net/forums/to...ting-in-vbnet/
>>
>> At least the basics
>>
>> -- Tom Shelton
>>

> Well Tom, I strugggled with that reference. I understood the Imports commands
> but very little else, and certainly not the code that began with #Region and
> used the three single quotes '''. Are those valid starts to a line?
> Altogether far too long and also abstract.
>


The three ' are xml comments. They are used to generate documentation
from the code comments.

The #Region stuff is so that you can have collapsable sections in your
code. The don't do anything with your code.

As for, using the stuff in the powerpack, it should be install it, add
the reference, use the import statement and write code.


> It is difficult to imagine anyone in the real world neglecting printing in a
> so-called serious tool that will be used in eg financial packages...


Why do you say that? I've done lots of serious applications, but
printing was never a requirement. Even when I have done stuff that
needed to generate documents, I either generated PDF or XPS documents
and let the user print them from the viewer - no need for me to write
any printing code.

> And
> putting it in the 'next framework' is no answer because that means any
> application using it won't work in previous frameworks and can't be presented
> as a universal exe file that anyone can use.
>


I don't know what you mean by that? Printing is in the .NET framework.
Has been all along... I just haven't had a reason to use it that
much.

--
Tom Shelton


 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      24th Jan 2011
Dennis was thinking very hard :
> On Sun, 23 Jan 2011 22:01:29 -0700, Tom Shelton
> <(E-Mail Removed)> wrote:
>
>> This may sound funny, but, I've never really done much printing in
>> either vb.net or even vb.classic So, I can't really advise you on
>> this much.

>
> I had a customer who wanted to be able to print a DataGridView. I found
> a C# class online that did the job.
>
> Other than that, I haven't had the need to do any printing DIRECTLY from
> .Net. What I do instead is either write my columnar output to a CSV file
> (and open it in the default spreadsheet program), or emit HTML (and open
> it in the default browser). I find this approach better than sending
> data directly to a printer.


For formated stuff, I've generally used stuff like ITextSharp to
generate PDF's or used the frameworks support for XPS

--
Tom Shelton


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      24th Jan 2011
Am 24.01.2011 19:44, schrieb StrandElectric:
> I've looked for it but can't find the syntax to use for bringing in vb6-like
> printing. Can someone tell me again?


There is no "vb6-like printing" in .Net. It's up to you now to learn some
basics before trying to understand things that required prior knowledge.
I know that you don't accept this, but I can only tell you the truth.


--
Armin
 
Reply With Quote
 
Jason Keats
Guest
Posts: n/a
 
      24th Jan 2011
Armin Zingler wrote:
> Am 24.01.2011 19:44, schrieb StrandElectric:
>> I've looked for it but can't find the syntax to use for bringing in vb6-like
>> printing. Can someone tell me again?

>
> There is no "vb6-like printing" in .Net. It's up to you now to learn some
> basics before trying to understand things that required prior knowledge.
> I know that you don't accept this, but I can only tell you the truth.



There certainly IS VB6-like printing available in .NET.

Just add a reference to: Microsoft.VisualBasic.PowerPacks.Vs

Then put
Imports Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Imports System.Drawing

at the top of your code page, then try something like...

Private Sub PrintSample()

Dim col() As Integer

ReDim col(0 To 3)
col(0) = 1000
col(1) = 3000
col(2) = 5000
col(3) = 7000

Dim p As New Printer

p.PrintAction = Printing.PrintAction.PrintToPrinter 'in
System.Drawing namespace

p.ScaleMode = vbTwips
p.PaperSize = vbPRPSA4

'p.Font = New Font("Arial", 20, FontStyle.Bold Or FontStyle.Italic)
p.Font = New Font("Arial", 10, FontStyle.Regular)

p.CurrentY = 1000
p.CurrentX = 500
p.Print("Page 1")

p.Font = New Font("Arial", 20, FontStyle.Bold)

p.CurrentY = 2000
p.CurrentX = col(0)
p.Print("Zero")

p.CurrentY = 2000
p.CurrentX = col(1)
p.Print("One")

p.CurrentY = 2000
p.CurrentX = col(2)
p.Print("Two")

p.CurrentY = 2000
p.CurrentX = col(3)
p.Print("Three")

p.NewPage()

'Page 2...

p.Font = New Font("Arial", 10, FontStyle.Regular)

p.CurrentY = 1000
p.CurrentX = 500
p.Print("Page 2")

p.Font = New Font("Arial", 20, FontStyle.Italic)

p.CurrentY = 2000

p.CurrentX = col(0)
p.Write("Zero")

p.CurrentX = col(1)
p.Write("One")

p.CurrentX = col(2)
p.Write("Two")

p.CurrentX = col(3)
p.Write("Three")

p.EndDoc()

End Sub

Note that the semi-colon is no longer available to prevent line-feeds.

You will notice the first page uses Print, while the second page uses
Write (much simpler).
 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      24th Jan 2011
Am 24.01.2011 23:49, schrieb Jason Keats:
>> There is no "vb6-like printing" in .Net. It's up to you now to learn some
>> basics before trying to understand things that required prior knowledge.
>> I know that you don't accept this, but I can only tell you the truth.

>
>
> There certainly IS VB6-like printing available in .NET.
>
> Just add a reference to: Microsoft.VisualBasic.PowerPacks.Vs


Tom mentioned it already in his 1st reply, but it doesn't seem
to be appropriate for Mr. Strand or he accidently overlooked
the suggestion.

--
Armin
 
Reply With Quote
 
 
 
Reply

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to obtain detailed info in case of an exception Helmut Giese Microsoft C# .NET 7 17th Feb 2010 12:51 PM
How do I change from upper case to lower case in an already print. =?Utf-8?B?UHV6emxlZA==?= Microsoft Word Document Management 3 27th Jun 2005 08:47 PM
having a problem using HP WebJetAdmin to install print ques to virtual print server Glenn L Microsoft Windows 2000 Printing 1 18th Jan 2005 03:50 AM
need more info on virtual memory =?Utf-8?B?dHJveQ==?= Windows XP Help 1 9th Oct 2004 05:00 PM
CPU/Case Temperature etal Bios Info Jeffrey Windows XP Hardware 2 12th Dec 2003 06:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 AM.