Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
NEWBIE NEEDS HELP PRINTING Posted by DRM887 on 17 Aug 2006 at 4:36 PM
Can someone please tell me how to get this to print. I am using VB6 and I have a print button on my form, but do not know how to make it print.
Many thanks.


Private Sub Command3_Click()
Open "C:\WINDOWS\Desktop\New Folder (2)\DM-ARC.WRI" For Output As #1 ' Open file for output.

Print #1, Spc(35); "DM - ARC" ' Print text to file.
Print #1, Spc(33); "Simple Skid"
Print #1, ' Print blank line to file.
Print #1, "Date:"; " "; Date
Print #1,
Print #1, "Drivers Name:"; Tab(50); "ARC Inspector:" ' Print in two print zones.
Print #1, "Address:"; Tab(50); "Address:"
Print #1, "Phone:"; Tab(50); "Phone:"
Print #1,
Print #1, "Location of Accident:"
Print #1,
Print #1, "Description of accident:"
Print #1,
Print #1,
Print #1,
Print #1, "The vehicle was going at least"; " "; Text4; " "; "mph at the beginning of the skid."
Print #1,
Print #1, Spc(5); Text4; " "; " = Sqr(30 * "; Text1; " * "; Text2; " * "; Text3; ")"
Close #1 ' Close file.
MsgBox "The file is located in the ARC folder on your desktop."

End Sub
Report
Re: NEWBIE NEEDS HELP PRINTING Posted by dokken2 on 18 Aug 2006 at 8:16 AM
: Can someone please tell me how to get this to print. I am using VB6 and I have a print button on my form, but do not know how to make it print.
: Many thanks.
:
:

this has worked useing the 'printer' object-

Private Sub DataPrint()
  Dim i, j As Integer, FS As String
   
  On Error GoTo ErrPrint

  'SET PRINTER PARAMETERS
  Printer.TrackDefault = True
  Printer.FontName = "Courier": FS = "10"     SET FONTNAME,SIZE
  If mnuFont08.Checked = True Then FS = "8"
  If mnuFont10.Checked = True Then FS = "10"
  If mnuFont12.Checked = True Then FS = "12"
  If mnuFont14.Checked = True Then FS = "14"
  If mnuFont16.Checked = True Then FS = "16"
  Printer.FontSize = FS
  
  If PrintOk = False Then Exit Sub   'CANCEL
  
  'PRINT REPORT
  Printer.Print "Contract No.", , Cnum
  Printer.Print "Description:", , Desc
  Printer.Print "Location:", , Location
  Printer.Print "Hammer Model:", , Model
  Printer.Print "Hammer Type", , Htype
  
  Printer.Print "Ram Weight (kips)", Ramwgt
  Printer.Print "BPM start value", BPMstart   '5-12-03
  Printer.Print "BPM end   value", BPMend     '5-12-03
  Printer.Print "Required Bearing (tons)", RBorig
  Printer.Print "Required Batter (ratio)", Ratio
  Printer.Print "Bearing Range (ton)", Init & " - " & Final
  Printer.Print "Date", , Curdate
  Printer.Print vbCr & vbCr
  
  Printer.Print vbCr
  Printer.Print "Prepared by: " & Prepare
  Printer.Print "Date: " & Curdate
  Printer.Print
  Printer.Print "Chief: _________________________    RCE:        _________________________"
  Printer.EndDoc
  
  MsgBox "Results were sent to printer.", vbOKOnly, "Print status"
xit:
  Exit Sub

ErrPrint:
  MsgBox Err.Description, vbExclamation, Err.Number
  Resume xit
End Sub

Report
Re: NEWBIE NEEDS HELP PRINTING Posted by DRM887 on 18 Aug 2006 at 11:55 AM
: : Can someone please tell me how to get this to print. I am using VB6 and I have a print button on my form, but do not know how to make it print.
: : Many thanks.
: :
: :
:
: this has worked useing the 'printer' object-
:
:
: Private Sub DataPrint()
:   Dim i, j As Integer, FS As String
:    
:   On Error GoTo ErrPrint
: 
:   'SET PRINTER PARAMETERS
:   Printer.TrackDefault = True
:   Printer.FontName = "Courier": FS = "10"     SET FONTNAME,SIZE
:   If mnuFont08.Checked = True Then FS = "8"
:   If mnuFont10.Checked = True Then FS = "10"
:   If mnuFont12.Checked = True Then FS = "12"
:   If mnuFont14.Checked = True Then FS = "14"
:   If mnuFont16.Checked = True Then FS = "16"
:   Printer.FontSize = FS
:   
:   If PrintOk = False Then Exit Sub   'CANCEL
:   
:   'PRINT REPORT
:   Printer.Print "Contract No.", , Cnum
:   Printer.Print "Description:", , Desc
:   Printer.Print "Location:", , Location
:   Printer.Print "Hammer Model:", , Model
:   Printer.Print "Hammer Type", , Htype
:   
:   Printer.Print "Ram Weight (kips)", Ramwgt
:   Printer.Print "BPM start value", BPMstart   '5-12-03
:   Printer.Print "BPM end   value", BPMend     '5-12-03
:   Printer.Print "Required Bearing (tons)", RBorig
:   Printer.Print "Required Batter (ratio)", Ratio
:   Printer.Print "Bearing Range (ton)", Init & " - " & Final
:   Printer.Print "Date", , Curdate
:   Printer.Print vbCr & vbCr
:   
:   Printer.Print vbCr
:   Printer.Print "Prepared by: " & Prepare
:   Printer.Print "Date: " & Curdate
:   Printer.Print
:   Printer.Print "Chief: _________________________    RCE:        _________________________"
:   Printer.EndDoc
:   
:   MsgBox "Results were sent to printer.", vbOKOnly, "Print status"
: xit:
:   Exit Sub
: 
: ErrPrint:
:   MsgBox Err.Description, vbExclamation, Err.Number
:   Resume xit
: End Sub
: 

:
Thanks, but I get an "Object variable or With block variable not set" message when I run this. It did say sent to printer but nothing happened.
Report
Re: NEWBIE NEEDS HELP PRINTING Posted by dokken2 on 23 Aug 2006 at 4:42 AM
This message was edited by dokken2 at 2006-8-23 4:43:42

: Thanks, but I get an "Object variable or With block variable not set" message when I run this. It did say sent to printer but nothing happened.
:

probably since there are variables from the program and they are undefined in the excerpt of code. this example should get you started-

  'SET PRINTER PARAMETERS
  Printer.TrackDefault = True
  'SET FONTNAME,SIZE
  Printer.FontName = "Courier"
  Printer.FontSize = "10"
  
  'PRINT
  Printer.Print "send to the printer"
  
  'END OF DOCUMENT
  Printer.EndDoc



Report
Re: NEWBIE NEEDS HELP PRINTING Posted by DRM887 on 23 Aug 2006 at 3:21 PM
: This message was edited by dokken2 at 2006-8-23 4:43:42

: : Thanks, but I get an "Object variable or With block variable not set" message when I run this. It did say sent to printer but nothing happened.
: :
:
: probably since there are variables from the program and they are undefined in the excerpt of code. this example should get you started-
:
:
:   'SET PRINTER PARAMETERS
:   Printer.TrackDefault = True
:   'SET FONTNAME,SIZE
:   Printer.FontName = "Courier"
:   Printer.FontSize = "10"
:   
:   'PRINT
:   Printer.Print "send to the printer"
:   
:   'END OF DOCUMENT
:   Printer.EndDoc
: 

:
That did the trick......thank you very much.....you guys and girls are great.
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.