Hello,
I have some trouble to export this code which works fine to VB 2008
This code is intented to work with datalogger. -
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 : -
ready = 0
-
Do While ready = 0
-
status = pl1000Ready(handled, ready)
-
Loop
-
it looops for ever instead in Excel it work fine
In order to export it to Vb 98 I have changed my declarations in -
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
-
may be it is hard help me cause the software is too long , anyway i try to ask you
Thanks in advance
4 2585
more info:
That code works fine in Vb6 too
There are some differences i dont know VBA Excel/Vb6 Vs VB2008
I have some trouble to export this code which works fine to VB 2008
This code is intented to work with datalogger.
Could you be a little more specific about the problem(s)? "Some trouble" is very vague.
Hello
Declarations's module updated based on difference between vb6 and vb2008 -
Module Module1
-
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
-
Declare Function pl1000CloseUnit Lib "pl1000.dll" (ByRef handle As Short) As Integer
-
Declare Function pl1000GetUnitInfo Lib "pl1000.dll" (ByRef handle As Short, ByVal S As String, ByVal lth As Short, ByRef requiredSize As Short, ByVal info As Short) As Short
-
Declare Function pl1000SetTrigger Lib "pl1000.dll" (ByRef handle As Short, ByVal enabled As Short, ByVal enable_auto As Short, ByVal auto_ms As Short, ByVal channel As Short, ByVal dir As Short, ByVal threshold As Short, ByVal hysterisis As Short, ByVal delay As Single) As Short
-
-
Declare Function pl1000SetInterval Lib "pl1000.dll" (ByRef handle As Short, ByRef us_for_block As Integer, ByVal ideal_no_of_samples As Integer, ByVal channels As Short, ByVal No_of_channels As Short) As Integer
-
-
Declare Function pl1000GetValues Lib "pl1000.dll" (ByRef handle As Short, ByVal values As Short, ByVal no_of_values As Integer, ByVal overflow As Short, ByVal triggerIndex As Integer) As Integer
-
Declare Function pl1000Run Lib "pl1000.dll" (ByRef handle As Short, ByVal no_of_values As Integer, ByVal method As Short) As Short
-
Declare Function pl1000Ready Lib "pl1000.dll" (ByVal handle As Short, ByRef ready As Short) As Integer
-
Declare Function pl1000MaxValue Lib "pl1000.dll" (ByVal handle As Short, ByRef maxValue As Short) As Integer
-
End Module
-
FORM1: -
Public Class Form1
-
Dim status As Integer
-
Dim handled As Short
-
Dim opened As Short
-
Dim values(200) As Short
-
Dim channels(22) As Short
-
Dim nValues As Integer
-
Dim ok As Short
-
Private ready As Short
-
Dim requiredSize As Short
-
-
Dim s As String 'in VB6 it was string*255
-
Public port As Short
-
Public product As Short
-
Dim maxValue As Short
-
Dim Slenght As String
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
' Open device
-
status = pl1000OpenUnit(handled)
-
opened = handled <> 0
-
-
-
If opened Then
-
-
status = pl1000MaxValue(handled, maxValue)
-
-
' Slenght = pl1000GetUnitInfo(handled, s, 255, requiredSize, 3)
-
-
Call pl1000SetTrigger(handled, False, 0, 0, 0, 0, 0, 0, 0)
-
nValues = 100
-
channels(0) = 1
-
channels(1) = 2
-
-
Dim sampleInterval As Integer
-
Dim us_for_block As Integer
-
-
us_for_block = 1000000
-
status = pl1000SetInterval(handled, us_for_block, nValues, channels(0), 2)
-
-
status = pl1000Run(handled, nValues, 0)
-
-
-
ready = 0
-
Do While ready = 0
-
status = pl1000Ready(handled, ready)
-
Loop
-
-
MsgBox("ok")
-
End If
-
End Sub
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
-
pl1000CloseUnit(handled)
-
-
End Sub
-
End Class
-
The problem is this :
At position -
ready = 0
-
Do While ready = 0
-
status = pl1000Ready(handled, ready)
-
Loop
-
The var "ready" is always 0 (zero) so the loop is forever.
This is wrong because the hardware works fine and the program works fine in vb/excel 2003 too.
I dont know why it is always 0.
This software comes with datalogger which works perfectly
Follows the program for vb6/excel 2003:
This woks fine in excel 2003/VB 6 -
Declare Function pl1000OpenUnit Lib "pl1000.dll" (ByRef handle As Integer) As Long
-
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
-
-
This declarations must be changed in "Byval" otherwhise i get an "Accessviolation exceptions.."
- 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
-
Thank for any tips or help
The problem is this :
At position - ready = 0
-
Do While ready = 0
-
status = pl1000Ready(handled, ready)
-
Loop
-
The var "ready" is always 0 (zero) so the loop is forever.
Well... You set ready to zero, you then passed it to another method. But I see no place where you are trying to get that value back. I wouldn't have expected it to change value. Maybe I'm missing something.
When you pass a value as a parameter the receiving method receives into a new variable. A copy of the value you send, if you will.
I would expect you need to do something with the 'status' variable since this is returning results from the method you are calling (pl1000Ready)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andre |
last post by:
I'm not sure if this is the best place for this post or not, but I can't
find many asp newsgroups anymore.
I have an app that's 3-4 years old, and has been working just fine. One of
the pages...
|
by: Matt |
last post by:
I have an ASP page that calls ASP routines that I created that execute
a database query and return the results to a recordset. I then iterate
through the recordset and display the data in a table....
|
by: DC Gringo |
last post by:
I have a simple button that should open another window and export a datagrid
to an Excel file. I'm getting: "Name 'window' is not declared."
What do I need to declare or import?
<INPUT...
|
by: Hemant Sipahimalani |
last post by:
The following piece of code is being used to export HTML to excel.
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
|
by: cehether |
last post by:
Hello everyone.
I am trying to export the contents of a DataGrid to MS Excel using VB.NET 2003. I read of a couple different ways of doing that here (though I couldn't tell which version of...
|
by: sandervanee |
last post by:
Hello,
I am trying to export several Access 2003 select queries to Excel 2003 using an Access macro. I'm using the macro command "TransferSpreadsheet" to export the queries. This going quit well,...
|
by: CoolFactor |
last post by:
MY CODE IS NEAR THE BOTTOM
I want to export this Access query into Excel using a command button on an Access form in the following way I describe below.
Below you will find the simple query I am...
|
by: Cintury |
last post by:
Using Access 2003 (Access 2000 file format) on Windows XP
I have a query that pulls from 2 tables that includes a date as well as other data. What I need is code to put in the SQL view, if this is...
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I have a question for you.
I have a .csv file which has many lines of data.
Each line has many data fields which are delimited by ",".
Now I need to extract part of data from this...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |