Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 31-08-2009
Members
 
Join Date: May 2009
Posts: 45
Printing Text File Direct To Printer

I wan to create an application where user can directly print any text File to printer without detecting the printer driver. When i ask my friend about it, he told me that we can do it by using some code in Visual basic, but he also don't know what are the snippet code for the same , i have also try to find it on internet but was not able to get any code. Does anyone can solve my problem.
Reply With Quote
  #2  
Old 31-08-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Printing Text File Direct To Printer

If you want to use print a text file in Visual Basic then you need to use printer.print command and also add the following code in your programming too.

Code:
Open "lpt2:" For Output As #1

Print #1, "File to print"

Close #1
Reply With Quote
  #3  
Old 31-08-2009
Member
 
Join Date: Jan 2009
Posts: 113
Printing Text File Direct To Printer

You you want to use printer.print command in Visual Basic instead of that i would suggest you to use the below code

Code:
Sub PrintLpt1()
  Dim bf As String
   Dim vbEsc As String
  vbEsc = Chr$(29)
  
  'load string with escape codes
  bf = vbEsc & "A" & vbEsc & "A3H0000V0000" & vbEsc & "Z"
  bf = bf & vbEsc & "A" & vbEsc & "%2" & vbEsc & "H478" & vbEsc & "V105"
  bf = bf & vbEsc & "D302054205215670190"
  bf = bf & vbEsc & "H220" & vbEsc & "V105"
  bf = bf & vbEsc & "D302054205215670190"
  bf = bf & vbEsc & "%0" & vbEsc & "H294" & vbEsc & "V30"
  bf = bf & vbEsc & "FW02H0176"
  bf = bf & vbEsc & "H36" & vbEsc & "V30"
  bf = bf & vbEsc & "FW02H0176"
  bf = bf & vbEsc & "%3" & vbEsc & "H245" & vbEsc & "V42"
  bf = bf & vbEsc & "PS" & vbEsc & "$A,24,24,0" & vbEsc & "$=521567"
  bf = bf & vbEsc & "H501" & vbEsc & "V40"
  bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=521567"
  bf = bf & vbEsc & "%2" & vbEsc & "H470" & vbEsc & "V30"
  bf = bf & vbEsc & "$A,38,32,0" & vbEsc & "$=RM 720.90"
  bf = bf & vbEsc & "H210" & vbEsc & "V30"
  bf = bf & vbEsc & "$A,38,32,0" & vbEsc & "$=RM 1.90"
  bf = bf & vbEsc & "H480" & vbEsc & "V128"
  bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=ABCDEFGHIJKLMNOP"
  bf = bf & vbEsc & "H220" & vbEsc & "V128"
  bf = bf & vbEsc & "$A,24,24,0" & vbEsc & "$=1234567890ABCDEF"
  bf = bf & vbEsc & "Q1"
  bf = bf & vbEsc & "Z"


  Open "lpt1:" For Output As #1

  
  Print #1, bf
  Close #1
  
End Sub
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Printing Text File Direct To Printer"
Thread Thread Starter Forum Replies Last Post
Unable to open printing preferences while printing from Dell Inkjet Photo Printer 720 LaurenBc Portable Devices 2 11-11-2011 06:54 PM
HP Officejet 7410 Printer via direct ethernet Bon-hwa Portable Devices 5 04-09-2010 06:12 AM
Excel workbook is not stored in printer while printing an entire book in private area of printer Sabastiaan Windows Software 5 16-03-2010 04:51 AM
help on turbo c++ printing text file mstpin Software Development 4 23-07-2009 10:18 AM
scheduled printing of a text file using batch files or schtasks Gadgetman Windows XP Support 10 12-06-2008 11:48 PM


All times are GMT +5.5. The time now is 10:51 AM.