|
-
Mar 16th, 2000, 04:47 AM
#1
Thread Starter
Addicted Member
hello, how do you print a solid line to the printer? before I could use chr(196) and it would line up and be a solid line in QB, but now in VB it shows up as dashes. although I am using the same font (courier new). Also, if I know the page can hold say 100 lines, how do I get vb to tell me when it is on say line 75 without having to use a counter for each line printed? Is there a formula to get the width of each line and use the twips of the page or something? Im very new to VB, as much information as possible is appreciated, thanks. Also if there are any printing object tutorials anywhere please let me know.
Thai
-
Mar 16th, 2000, 05:34 AM
#2
Frenzied Member
you shouldn't really use text to print graphics, that's a throwback from the days of well, Quick Basic when graphics methods wern't very good in memory was expensive so putting bitmaps onto the printer was out.
There is a line method on the printer object to do this, in fact the printer object has very similar graphics methods to the picturebox object, try putting a big picturebox on your form and in your form load event write the following 4 lines of code
Code:
Picture1.top=0
Picture1.left=0
Pictue1.width=printer.width
picture1.height=printer.height
set the forms windowstateproperty to maximized and maximize it in the IDE (ie maximize the form while you're not running it.)
place 3 commandbuttons to the far right of the maximized form and code them
Code:
Private Sub Command1_Click()
Picture1.Top = Picture1.Top - 200
End Sub
Private Sub Command2_Click()
Picture1.Top = Picture1.Top + 200
End Sub
Private Sub Command3_Click()
Printer.EndDoc
Picture1.Cls
End Sub
Private Sub Command4_Click()
Printer.KillDoc
Picture1.Cls
End Sub
Oh yeah and set picture1s autoredraw property to true.
then add your own command buttons and use them for various drawing methods, on both the printer object and the picture box.
Here's what my command buttons do
Command 1 moves the picturebox up
command 2 moves it down
Command3 prints the picturebox and clears the picturebox
Command 4 clears the printer and the picturebox.
This will let you see your graphics methods drawn ass you do them and give you a good environment to experiment in.
Experimenting is the key to VB, if you make 10 wild guesses, crash your machine twice and learn one thing then your still making progress, if you make 10 wild guesses crash your machine 6 times and learn 2 things your really on your way.
hope this helps
-
Mar 16th, 2000, 05:48 AM
#3
Thread Starter
Addicted Member
cool.
thanks for the help, but what is the point of moving the picture box up and down? what does that have to do with the printer? and you said your command3 prints the picture box but i dont see anywhere in the code that does that. just a bit confused, thanks for helping, I really appreciate it.
Thai
-
Mar 16th, 2000, 06:16 AM
#4
Hyperactive Member
Hi, there.
To print a line you have to use Line method of Printer object. Check VB help, there is an example. But the syntax is:
Printer.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]
Larisa
-
Mar 16th, 2000, 08:46 PM
#5
Frenzied Member
The Up and down buttons were there in case the picture box was taller than your screen, which it may not have been, you probably have a big screen. the command 3 button prints the document with the linethe printer's print method is actualy for putting text on the printer object, in the same way as a picture box's print method. in case you need to know the actual metods to print something rather than just draw on the printer object are
Code:
Printer.NewPage 'saves the page you were working on to
'memory and starts a new page.
Printer.EndDoc 'Prints all the pages on the printer object
'and clears them from memory
Printer.KillDoc 'Cancels all the pages on the printer object
hope this helps
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
|