Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


What is the print command in VB6?

Posted on 2003-02-22
Medium Priority
Last Modified: 2008-01-09
I just started programming with VB6 and I've made some basic applications so far.  I was wondering, what is the most basic command to print the screan of an application?  Is there some type of print screen command I can assign to a button?  Thanks a lot!
Question by:echobravo316

Accepted Solution

Frog357 earned 200 total points
ID: 8001402
PrintForm Method

Sends a bit-by-bit image of a Form object to the printer.

PrintForm prints all visible objects andbitmaps of the Form object.

If you wanted to use this in a command button named Command1, the code would look like so:

Private Sub Command1_Click()
End Sub


Expert Comment

ID: 8001411
How about this.

Private sub Command1_Click()
Call Form1.PrintForm
end sub

Author Comment

ID: 8001465
Thankyou very much!  Worked like a charm.

Expert Comment

ID: 8001467
you can type:

? "Hello World!"

in your main form

private sub Form_Load()
  ? "Hello World!"
end sub

? = print, so when you press enter it will just change to print

private sub Form_Load()
  print "Hello World!"
end sub

It will just print straight out onto your main form in the top left corner.

alternatively you can print to the debug screen with:

private sub Form_Load()
  debug.print "Hello World!"
end sub

Best way of displaying something quickly and easily is to create a new text box on the screen, then print out to that (if you want more than 1 line be sure to enable multiline in the properties)

private sub Form_Load()
  Text1.Text = "Hello World!" & vbCrLf & "Second Line!"
end sub

Hope that helps you.

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question