Device Controll through PC’s LPT-1 port code in VB6

Following is the Visual Basic 6 code for device controlling through PC’s LPT-1 Port.

This code will be written in Module1.bas

Public Declare Function Inp Lib “inpout32.dll” Alias “Inp32” _
(ByVal address As Integer) _
As Integer

Public Declare Sub Out Lib “inpout32.dll” Alias “Out32” _
(ByVal address As Integer, _
ByVal Value As Integer)

This code will be written in Form1.frm

Option Explicit
Dim AEPPort As Integer
Dim AEPData As Integer
Dim Data, pat

Sub AEPOut(Data As Integer)
Out AEPPort, AEPData
End Sub

Private Sub Form_Load()
Shape1.Visible = False
pat = 0
End Sub

Private Sub Command1_Click()
AEPPort = &H378
Label5.Caption = AEPPort
pat = Text1.Text
AEPData = Val(pat)
AEPOut (Data)
If pat = “” Then GoTo y Else GoTo X
If pat = 0 Then GoTo y Else GoTo x1
Shape1.Visible = True
Shape2.Visible = False
End Sub

Private Sub Command2_Click()
AEPPort = &H378
pat = 0
AEPData = Val(pat)
AEPOut (Data)
Shape1.Visible = False
Shape2.Visible = True
End Sub

Private Sub Command3_Click()
AEPPort = &H378
pat = 0
AEPData = Val(pat)
AEPOut (Data)
End Sub

Private Sub Timer1_Timer()
Label3.Caption = Format(Date, “dd-mm-yyyy”)
Label4.Caption = Time
AEPPort = &H379
Label6.Caption = AEPPort
Label7.Caption = Inp(&H379)
End Sub

Adeeb Raza

About adeebraza1236

I am an electronic instrumentation engineer by profession but I am working as a design engineer. I can design electronic hardware interface circuits for computer based security system, Computer based industrial control system for automation and process control Etc. My Interests: Electronics Circuit designing with PCB Designing, Computer software development using VB & C , PC based security system, Designing LED Lights, UPS, Inverter Etc
This entry was posted in Uncategorized, Visual Basic 6 Code and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s