Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
my pc's operating system
windows 7 ultimate 32 bit
login access: username & password - admin
i am working on a project that will control 5 devices through pc parallel port/printer port.
when i run the program it will first appear a loginform
then when i enter.
it always returns that the port doesnt exist.
even though i have the port it cant detect it.. i dont know what is wrong with my code.

Dim FILE_NAME As String = "LPT1"

If System.IO.File.Exists(FILE_NAME) Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
MsgBox("port does not exist")
End If
then after the login the next form is homepage. there you'll see the switch buttons that will turn on and off a device. when i clicked any of this buttons an error will prompt. its say that object reference not set to an instance of an object

NullReferenceException was unhandled.

Private Sub btn_app1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app1.Click
If btn_app1.Text = "ON" Then
btn_app1.Text = "OFF"
btn_app1.BackColor = Color.Red
btn_app1.Text = "ON"
btn_app1.BackColor = Color.Green
End If
End Sub

Private Sub btn_app2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app2.Click
If btn_app2.Text = "ON" Then
btn_app2.Text = "OFF"
btn_app2.BackColor = Color.Red
btn_app2.Text = "ON"
btn_app2.BackColor = Color.Green
End If
End Sub

Private Sub btn_app3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app3.Click
If btn_app3.Text = "ON" Then
btn_app3.Text = "OFF"
btn_app3.BackColor = Color.Red
btn_app3.Text = "ON"
btn_app3.BackColor = Color.Green
End If
End Sub

Private Sub btn_app4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app4.Click
If btn_app4.Text = "ON" Then
btn_app4.Text = "OFF"
btn_app4.BackColor = Color.Red
btn_app4.Text = "ON"
btn_app4.BackColor = Color.Green
End If
End Sub

Private Sub btn_app5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_app5.Click
If btn_app5.Text = "ON" Then
btn_app5.Text = "OFF"
btn_app5.BackColor = Color.Red
btn_app5.Text = "ON"
btn_app5.BackColor = Color.Green
End If
End Sub

Private Sub io(ByVal bit As Integer)
val = axHwinterface1.InPort(888)
axHwinterface1.OutPort(888, CShort(val Or bit))
End Sub

please help me im new in this.. i need your help guys.. thank you in advance..
every response is very much appreciated

if you want to see my whole project you can Download it here
Posted 15-Jan-13 20:17pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You definitely don't do it like that!
Have a look at this: I/O Ports Uncensored - 1 - Controlling LEDs (Light Emiting Diodes) with Parallel Port[^] - it shows you how to do it in a variety of languages using LEDs for the machines you want to control.
Do be aware that you can't power the machines from the parallel port - you will probably damage your hardware if you try!
Lord Christian at 21-Jan-13 0:48am
Sir OriginalGriff. i have here a device with 5 plug sockets and can be connected to pc's parallel port so i can be able to turn on and off a appliances.
i there somethings wrong with my project? please please let me know. im currently reading the article you forwarded to me.. thank you very much sir.
OriginalGriff at 21-Jan-13 3:19am
You're welcome - just look at the article and give it a try - it explains what you need to do.
Lord Christian at 21-Jan-13 4:36am
:( i don't know how to debug my program.Please help me. I've already read the article but i think my really problem is i the dll. please check my project. :( i need to finish this project.
OriginalGriff at 21-Jan-13 4:44am
Your project as is shown above won't work - it is completely the wrong approach, parallel ports do not work that way.
Try the download from the link, and put an oscilloscope on the outputs to see what is happening.
If you don't have access to a 'scope, then I suspect you do not have any of the equipment you are going to need to make this work - parallel ports are data transfer devices, not driver circuits. You can't just wire them to a bunch of relays and expect anything to work!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 330
1 Sergey Alexandrovich Kryukov 295
2 ClimerChinna 207
3 Magic Wonder 205
4 Gihan Liyanage 192
0 Sergey Alexandrovich Kryukov 8,188
1 OriginalGriff 6,991
2 CPallini 2,598
3 Richard MacCutchan 1,925
4 Abhinav S 1,736

Advertise | Privacy | Mobile
Web03 | 2.8.140826.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100