-
Code:
dim filenumber as byte
FileNumber = freefile
Open "LPT1:" for output as #FileNumber
print #filenumber, "Hello"
close #filenumber
The "LPT1:" bit is the proper string that identifies the port, it is not interpreted as a filename, just in case you were wondering.
-
Here is code that switches individual parallel port pins on/off. You will need input32.dll.
code:
Option Explicit
Dim Value As Integer
Dim PortAddress As Integer
Dim index As Integer
Private Sub Form_Load()
Value = 0
PortAddress = &H378
End Sub
Private Sub D_Click(index As Integer)
'set individual pin to ON
Text1.Text = Inp(PortAddress)
Value = Value + (2 ^ index)
If Value > 255 Then Value = 255
Out &H378, Value
'show the value
Text1.Text = Inp(PortAddress)
' flick the switch
Call SetOn(index)
End Sub
Private Sub off_Click(index As Integer)
'set individual pin to OFF
Text1.Text = Inp(PortAddress)
Value = Value - (2 ^ index)
If Value < 1 Then Value = 0
Out &H378, Value
'show the value
Text1.Text = Inp(PortAddress)
'flick the switch
Call SetOff(index)
End Sub
Private Sub sveoff_Click()
'all off
Value = 0
Out &H378, Value
Text1.Text = Inp(PortAddress)
Out &H378, 0
For index = 0 To 7
Call SetOff(index)
Next index
End Sub
Private Sub sveon_Click()
'all ON
Value = 255
Out &H378, Value
Text1.Text = Inp(PortAddress)
For index = 0 To 7
Call SetOn(index)
Next index
End Sub
Private Sub IZL_Click()
Unload Form1
End
End Sub
Private Sub SetOff(index As Integer)
'flick pin OFF
off(index).Enabled = False
D(index).Enabled = True
D(index).SetFocus
Form1.Refresh
End Sub
Private Sub SetOn(index As Integer)
'flick pin ON
D(index).Enabled = False
off(index).Enabled = True
off(index).SetFocus
Form1.Refresh
End Sub
-
Many thanks to all, but is there some simpler command
which doesn't need the help of an external dll?
If not, it's sufficient what you have posted until now.
Bye
-
Nope, VB itself does not have any commands that allows writing of data directly to the parallel port.
Sunny
-
Hi,
The input32.dll file doesn't work under Windows 2000. DOes anybody of you have an updated version or do you have any clues where can I get one?
Please advice.
Thanks,
H.