Search Tools Links Login

Write data to COM/LPT ports without using the API

Posted: 2002-06-01
By: ArchiveBot
Viewed: 65

Filed Under:

Visual Basic 6

No attachments for this post


This simple yet effective code lets you send any data to the COM/LPT ports on the computer.

Original Author: Jordan Bayliss-McCulloch

Side Effects

If the data is sent to the printer port (LPT1/2) and the printer is off or not connected, the program may freeze.

Code

Dim strTest as String
strTest = "This is the data I want to write."
'This will write strTest to LPT1
Open "LPT1:" For Output Access Write As #1
Print #1, strTest
Close #1
'This will write strTest to COM1
Open "COM1:" For Output Access Write As #1
Print #1, strTest
Close #1
'It's that simple!


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.