As users begin to understand an application and use it to its full
potential they often times need to print content for easier reading or
permanent record. Fortunately Visual Basic 6 printing is not only easy
but very advanced. One of the simplest ways to do printing is by using
the PrintForm method which Visual Basic provides for us. This VB6
printing tutorial explains exactly what this method is and how you can
use it in the applications you develop.
The PrintForm method sends
an image of the current form to the default printer.
The sample
application prints the image of the form shown below without the command
buttons:
The code
for this application is quite sparse (as it does not actually perform any
calculations).
The Form_Load event contains code to center the form on the screen and to format the Date and
Time labels:
Private Sub Form_Load()
'center the form:
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
'display date & time
lblDate.Caption = Format$(Date,
"m/d/yyyy")
lblTime.Caption = Format$(Time, "h:nn
AM/PM")
End Sub
The Click
event for the Print button (cmdPrint_Click) hides the two command
buttons (by setting their Visible properties to False), issues
the PrintForm statement, then makes the buttons visible again:
Private Sub cmdPrint_Click()
cmdPrint.Visible = False
cmdExit.Visible = False
PrintForm
cmdPrint.Visible = True
cmdExit.Visible = True
End Sub
The Click
event for the Exit button (cmdExit_Click) ends the program by issuing
the End command.
Private Sub cmdExit_Click()
End
End Sub
Supaya Ga Bingung Download Di Bawah Ini
Download
the project files for this sample application Download Now
0 comments:
Post a Comment