Hello,
I have some trouble to export this code which works fine to VB 2008
This code is intented to work with datalogger.
At line :
it looops for ever instead in Excel it work fine
In order to export it to Vb 98 I have changed my declarations in
may be it is hard help me cause the software is too long , anyway i try to ask you
Thanks in advance
I have some trouble to export this code which works fine to VB 2008
This code is intented to work with datalogger.
Code:
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByVal handle As Integer) As Long
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByVal handle As Integer, ByVal S As String, ByVal lth As Integer, ByRef requiredSize As Integer, ByVal info As Integer) As Integer
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByVal handle As Integer, ByVal enabled As Integer, ByVal enable_auto As Integer, ByVal auto_ms As Integer, ByVal channel As Integer, ByVal dir As Integer, ByVal threshold As Integer, ByVal hysterisis As Integer, ByVal delay As Single) As Integer
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByVal handle As Integer, ByRef us_for_block As Long, ByVal ideal_no_of_samples As Long, channels As Integer, ByVal No_of_channels As Integer) As Long
Declare Function pl1000GetValues Lib "pl1000.dll" (ByVal handle As Integer, values As Integer, no_of_values As Long, overflow As Integer, triggerIndex As Long) As Long
Declare Function pl1000Run Lib "pl1000.dll" (ByVal handle As Integer, ByVal no_of_values As Long, ByVal method As Integer) As Integer
Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Integer, ByRef ready As Integer) As Long
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Integer, ByRef maxValue As Integer) As Long
Dim status As Long
Dim handle As Integer
Dim values(200) As Integer
Dim channels(22) As Integer
Dim nValues As Long
Dim ok As Integer
Dim ready As Integer
Dim requiredSize As Integer
Dim S As String * 255
Public port As Integer
Public product As Integer
Dim maxValue As Integer
Function adc_to_mv(value As Integer) As Integer
adc_to_mv = value / maxValue * 2500
End Function
Sub GetPl1000()
' Open device
status = pl1000OpenUnit(handle)
opened = handle <> 0
If opened Then
'Get the maximum ADC value for this variant
status = pl1000MaxValue(handle, maxValue)
' Get the unit information
Cells(6, "E").value = "Unit opened"
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 3)
Cells(7, "E").value = S
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 4)
Cells(8, "E").value = S
SLegnth = pl1000GetUnitInfo(handle, S, 255, requiredSize, 1)
Cells(9, "E").value = S
' No Trigger
Call pl1000SetTrigger(handle, False, 0, 0, 0, 0, 0, 0, 0)
' Say that we want to take 100 readings in 1 s
' from channels 1 and 2
nValues = 100
channels(0) = 1
channels(1) = 2
Dim sampleInterval As Long
Dim us_for_block As Long
us_for_block = 1000000
status = pl1000SetInterval(handle, us_for_block, nValues, channels(0), 2)
status = pl1000Run(handle, nValues, 0)
ready = 0
Do While ready = 0
status = pl1000Ready(handle, ready)
Loop
' Get a block of 100 readings...
' we can call this routine repeatedly
' to get more blocks with the same settings
Dim triggerIndex As Long
Dim overflow As Integer
status = pl1000GetValues(handle, values(0), nValues, overflow, triggerIndex)
' Copy the data into the spreadsheet
For i = 0 To nValues - 1
Cells(i + 4, "A").value = adc_to_mv(values(2 * i))
Cells(i + 4, "B").value = adc_to_mv(values(2 * i + 1))
Next i
' Close the unit when finished to drop the driver
Call pl1000CloseUnit(handle)
Else
Cells(17, "E").value = "Unable to open unit"
End If
End Sub
At line :
Code:
ready = 0
Do While ready = 0
status = pl1000Ready(handled, ready)
Loop
In order to export it to Vb 98 I have changed my declarations in
Code:
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Integer) As Long
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByRef handle As Integer) As Long
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByRef handle As Integer, ByRef S As String, ByRef lth As Integer, ByRef requiredSize As Integer, ByRef info As Integer) As Integer
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByRef handle As Integer, ByRef enabled As Integer, ByRef enable_auto As Integer, ByRef auto_ms As Integer, ByRef channel As Integer, ByRef dir As Integer, ByRef threshold As Integer, ByRef hysterisis As Integer, ByRef delay As Single) As Integer
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByRef handle As Integer, ByRef us_for_block As Long, ByRef ideal_no_of_samples As Long, ByRef channels As Integer, ByRef No_of_channels As Integer) As Long
Declare Function pl1000GetValues Lib "pl1000.dll" (ByRef handle As Integer, ByRef values As Integer, ByRef no_of_values As Long, ByRef overflow As Integer, ByRef triggerIndex As Long) As Long
Declare Function pl1000Run Lib "pl1000.dll" (ByRef handle As Integer, ByRef no_of_values As Long, ByRef method As Integer) As Integer
Declare Function pl1000Ready Lib "pl1000.dll" (ByRef handle As Integer, ByVal ready As Integer) As Long
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByRef handle As Integer, ByRef maxValue As Integer) As Long
Thanks in advance
Comment