|
-
Apr 29th, 2002, 01:59 AM
#1
Thread Starter
Junior Member
printer object not working well
I'm trying to print text and lines to printer using printer object, but not successful. The object is declared as below:
Dim DrawObj as Object
Set DrawObj = Printer
But when I try to print to picture object, it works. It is declared as below:
Dim DrawObj as Object
Set DrawObj = Picture1
Why, and how to solve?
-
Apr 29th, 2002, 02:01 AM
#2
-= B u g S l a y e r =-
not successfull ?
as in an error occure (if so what)
as in it prints it all wrong ?
elaborate
-
Apr 29th, 2002, 02:03 AM
#3
Member
i find this hard to explain , so ill give you some sample code for you to look at:
Private Sub Form_Click()
Printer.Scale (0, 0)-(850, 1100)
Printer.Line (100, 100)-(400, 300), , B
Printer.Circle (425, 550), 300
Printer.CurrentX = 100
Printer.CurrentY= 800
Printer.Print "This is some text."
Printer.EndDoc
End Sub
thisp rints a circle and some text on the sheet
use the printer object directly (dont try to put it on a variable)
hope this helps
-
Apr 29th, 2002, 02:03 AM
#4
Thread Starter
Junior Member
Nothing printed on the paper from printer.
No error message.
-
Apr 29th, 2002, 02:06 AM
#5
-= B u g S l a y e r =-
could u show us the sub where u use this object?
also how u pass the object onto the sub?
-
Apr 29th, 2002, 02:07 AM
#6
-= B u g S l a y e r =-
Originally posted by Evo
i find this hard to explain , so ill give you some sample code for you to look at:
Private Sub Form_Click()
Printer.Scale (0, 0)-(850, 1100)
Printer.Line (100, 100)-(400, 300), , B
Printer.Circle (425, 550), 300
Printer.CurrentX = 100
Printer.CurrentY= 800
Printer.Print "This is some text."
Printer.EndDoc
End Sub
thisp rints a circle and some text on the sheet
use the printer object directly (dont try to put it on a variable)
hope this helps
should not be a problem to assign a printer object to a variable... should it ?
-
Apr 29th, 2002, 02:08 AM
#7
Member
i guess not, but , whats the point?
-
Apr 29th, 2002, 02:13 AM
#8
-= B u g S l a y e r =-
if u want to make both print preview and print in the same sub, passing the object u want to print to would be nice I think.
-
Apr 29th, 2002, 02:19 AM
#9
Member
good thinking there peet
-
Apr 29th, 2002, 03:16 AM
#10
-= B u g S l a y e r =-
leeek, sample for u.
this is tested and works just fine.
In order for u to test it, Start a new vb project
add a picturebox and to command buttons to the form
then add this code:
VB Code:
Option Explicit
Private Sub Command1_Click()
'Print to printer
PrintIT Printer
End Sub
Private Sub Command2_Click()
'Print preview to picbox
PrintIT Picture1
End Sub
Private Sub PrintIT(oPrntObj As Object)
'if this is a picbox for preview, clear it first
If TypeOf oPrntObj Is PictureBox Then oPrntObj.Cls
oPrntObj.CurrentX = 500
oPrntObj.CurrentY = 500
oPrntObj.Print "Testing Testing"
'if u sent it to the printer :
If TypeOf oPrntObj Is Printer Then oPrntObj.EndDoc
End Sub
depending on what button u click, it will preview or print.
hope this can get u off in the right direction
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|