I am having problems with my DrDaq visual basic project. I Originally had it working but am now getting errors. I have deleted all of the drivers and software and reinstalled everything, I am still getting an error message when i open up the example saying "cannot open DRDaq on LPT1". This is where I got the code from http://www.comp.lancs.ac.uk/~albrecht/sw/DrDAQ/
Option Explicit
Dim port As Integer 'Used to store port used(1 = lpt1)
Dim opened As Boolean 'boolean value; shows if driver opened
Private Sub chkTimer_Click()
If chkTimer.Value = 1 Then
Timer1.Interval = CInt(mstxt.Text)
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub cmdClose_Click()
If opened Then
'close the port
drdaq_close_unit (port)
End If
statustxt.Text = "DrDAQ Driver Closed on LPT" + CStr(port)
cmdOpen.Enabled = True
cmdClose.Enabled = False
cmdRead.Enabled = False
chkTimer.Enabled = False
End Sub
Private Sub cmdOpen_Click()
Dim VNUm As Integer ' Version number
port = Val(txtPortNum) ' Get Port
opened = drdaq_open_unit(port) <> 0 'Open drdaq driver
If opened Then 'Check driver opened ok
VNUm = drdaq_get_driver_version()
statustxt.Text = "DrDAQ Driver Opened on LPT" + CStr(port) + " - Driver Version:" + CStr(VNUm)
Top = (Screen.Height - Height) / 2
Left = (Screen.Width - Width) / 2
statustxt.Text = ""
cmdRead.Enabled = False
cmdClose.Enabled = False
cmdOpen.Enabled = True
chkTimer.Enabled = False
End Sub
Private Sub Form_Terminate()
cmdQuit_Click
End
End Sub
Private Sub Form_Unload(Cancel As Integer)
cmdQuit_Click
End
End Sub
Private Sub mstxt_Change()
If mstxt.Text <> "" Then
On Error GoTo skipConv
If CLng(mstxt.Text) > 0 And CLng(mstxt.Text) < 30000 Then
Timer1.Interval = CInt(mstxt.Text)
If chkTimer.Value = 0 Then Timer1.Enabled = False
End If
End If
skipConv:
End Sub
Private Sub Timer1_Timer()
If opened = True Then cmdread_Click
End Sub
Private Sub txtPortNum_KeyPress(KeyAscii As Integer)
Select Case (KeyAscii)
Case 48 To 57, 8:
KeyAscii = KeyAscii
Case Else:
Beep
KeyAscii = 0
End Select
End Sub
i have tried your solutuions as given but it is stil not working for me. by any chance could you send a piece of code that will open and close the port on the DrDaq and read in a value as i am still unsure whether it is a software or hardware problem,so if i receive a working prgram and it does not work on my pc i will be able to tell it then.
Paste this into your code in crucial places and step through each line.
drdaq_close_unit (port)
When you get to the next "close" call, step over if the previous fucntions have worked or step into if the previous portions have failed.
Best regards,
Michael
Michael - Tech Support
Pico Technology
Web Support Forum