|
-
Jul 9th, 2003, 03:24 PM
#1
Thread Starter
Addicted Member
Printing to LPT1
Hi to all VBians
Here is the problem to print the some text on "LPT1"
In VB6 following code works, and print text to printer attached on LPT1
-----------------------------------------------------------------
Dim fh As Integer
fh = FreeFile
TargetPrinter = Trim(Me.Text1.Text)
Open TargetPrinter For Output As #fh
Print #fh, "TEST PRINT"
Print #fh, "=========="
Print #fh, "aaaaaaaaaaaaaaa"
Print #fh,
Print #fh, "bbbbbbbbbbbbbbb"
Print #fh, "ccccccccccccccc"
Close fh
--------------------------------------------------------------------
Now I did same thing in VB.net as:
In starting of code file :
-----------------------------------------
Imports System.IO
-----------------------------------------
and on an event of a button
---------------------------------------------------------------------------------
Dim SW As StreamWriter
Dim FS As FileStream
FS = New FileStream("LPT1:", FileMode.Open)
SW = New StreamWriter(FS)
SW.WriteLine("Parminder")
SW.Close()
FS.Close()
----------------------------------------------------------------------------------
This give me the following error:
==========================================================
An unhandled exception of type 'System.NotSupportedException' in mscorlib.dll
Additional information: File Stream was asked to open a device
that was not a file. FileStream's constructors that take a string
will only work with devices like "com1:" or "lpt1:", then call
CreateFile yourself then use the FileStream constructors that
take an OS handle as an IntPtr.
==========================================================
NOW MY problem is that I am unable to CreateFile method.
Where is this method.
Thanks
-
Jul 11th, 2003, 03:01 PM
#2
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|