Solved

printing a form in visual basic 6

Posted on 2007-03-18
5
1,801 Views
Last Modified: 2013-11-26
hello,
i am currently working in visual basic 6 and have developed a database project. Now i want to print a form (information entered by the user in a form) HOW can we print that?
waiting for reply, thanx in anticipation
fa

0
Comment
Question by:fatimao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Accepted Solution

by:
cx323 earned 25 total points
ID: 18744930
Private Sub Command1_Click()
On Error Resume Next
Me.PrintForm
End Sub
0
 
LVL 15

Assisted Solution

by:cquinn
cquinn earned 25 total points
ID: 18748985
Add this to a module, then call the Printscreen() subroutine - it will scale the print to fit the paper

Option Explicit

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const VK_SNAPSHOT As Byte = &H2C

Function Printit(ByVal hDC_Dest, ByVal DestX, ByVal DestY, ByVal DestDevWidth, ByVal DestDevHeight) As Integer
    Dim lHeight As Long
    Clipboard.Clear
    Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
    DoEvents
    lHeight = (Printer.ScaleWidth / Screen.Width) * Screen.Height
    Printer.PaintPicture Clipboard.GetData, 0, 0, Printer.ScaleWidth, lHeight
    Printit = True
End Function

Sub Printscreen()
     
'Dump the current screen to the default printer
Dim r As Integer
DoEvents
' routine to print correctly.
 Printer.ScaleMode = 3

 ' Change MousePointer to an hourglass.
 Screen.MousePointer = vbHourglass

 ' Initialize the printer.
 Printer.Print ""

 ' Copy the image of the screen to the printer.
 r = Printit(Printer.hDC, 0, 0, Printer.ScaleWidth, Printer.ScaleHeight)
 

 ' Display an error if the return value from PrintWindow is zero.
 If Not r Then
    MsgBox "Unable to print the form", vbCritical + vbOKOnly, "Screen Print Failed"
 Else
    Printer.EndDoc
 End If

 Screen.MousePointer = vbDefault
End Sub

0
 

Author Comment

by:fatimao
ID: 18765671
thanks alot for all the help both the methods do work ... but i want to only want to print the information entered by user in grid and text boxes, the printscreen method and me.print() prints the whole form along with the buttons and other controls ...
please further help in this regard

thanx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help Creating PowerShell Script 5 80
get the ALL CAPITAL words from a cell 4 32
Problem to macro 5 18
SQL query joining 6 tables in asp.net 4 22
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
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…

737 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