Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

calling a dll function...no errors....but returns the value -1

Posted on 2007-11-21
7
Medium Priority
?
264 Views
Last Modified: 2013-11-25
hello sir/madam,
i have a Analog to digital converter card connected via usb port to my laptop. it converts the analog value and displays digital value. i want that digital value on my web page. To access that value i m trying to use the dll dunction which is used by that card
Private Declare Function ReadAnalogChannel Lib "C:\Inetpub\wwwroot\K8055D.DLL" (ByVal data As Long) As Long
Private Declare Function OpenDevice Lib "C:\Inetpub\wwwroot\K8055D.DLL" (ByVal N As Long) As Long
Dim data As Long
Dim i As Long
Dim N As Integer
Sub opencard()
i = OpenDevice(0)
End Sub
Sub callBeepDll()
data = ReadAnalogChannel(1)
End Sub
Private Sub cmd1_Click()
Dim data As Long
Call opencard
data = ReadAnalogChannel(1)
Text1.Text = data
End Sub
This is my code. In the description  of the card details says

If succeeded the return value will be the card address read from the K8055 hardware.
Return value -1 indicates that K8055 card was not found.

When i run this vb file...it gives me the value  -1. i.e. card is not connected. Can u plz give me solution or give me an alternate solution for this.
many thanks
0
Comment
Question by:Parvez_Siddiqui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 25

Expert Comment

by:imitchie
ID: 20332419
are you sure the card can be found? maybe the dll cannot find the card due to other misconfiguration
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20332424
try

Sub opencard()
i = OpenDevice(0)
Text1.Text = i
End Sub
Sub callBeepDll()
data = ReadAnalogChannel(1)
End Sub
Private Sub cmd1_Click()
Dim data As Long
Call opencard
data = ReadAnalogChannel(1)
Text1.Text = Text1.Text & " " & data
End Sub
0
 

Author Comment

by:Parvez_Siddiqui
ID: 20332511
Hi imitchie,
I tried the code u said. its showing -1-1...

maybe the dll cannot find the card due to other misconfiguration.....can u plz explain wats the meaning of this..?
this is explained in the k8055 card pdf file


OpenDevice
Syntax
FUNCTION OpenDevice(CardAddress: Longint): Longint;
Parameter
CardAddress: Value between 0 and 3 which corresponds to the jumper (SK5, SK6) setting on the
K8055 board. See table 1.
Result
Longint: If succeeded the return value will be the card address read from the K8055 hardware.
Return value -1 indicates that K8055 card was not found.
Description
Opens the communication link to the K8055 card. Loads the drivers needed to communicate via the
USB port. This procedure must be performed before any attempts to communicate with the K8055
card.
This function can also be used to selects the active K8055 card to read and write the data. All the
communication routines after this function call are addressed to this card until the other card is
selected by this function call.
Example
var h: longint;
BEGIN
h:=OpenDevice(0); // Opens the link to card number 0
END;




ReadAnalogChannel
Syntax
FUNCTION ReadAnalogChannel (Channel: Longint): Longint;
4 Description of the DLL
© 2003 ... Velleman
Parameter
Channel: Value between 1 and 2 which corresponds to the AD channel whose status is to be read.
Result
Longint: The corresponding Analogue to Digital Converter data is read.
Description
The input voltage of the selected 8-bit Analogue to Digital converter channel is converted to a value
which lies between 0 and 255.
Example
var data: longint;
BEGIN
data := ReadAnalogChannel(1);
// AD channel 1 is read to variable 'data'
END;

MANY THANKS
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 25

Expert Comment

by:imitchie
ID: 20332526
try in Sub opencard()

i = OpenDevice(0)
Text1.Text = i
i = OpenDevice(1)
Text1.Text = Text1.Text & " " & i
i = OpenDevice(2)
Text1.Text = Text1.Text & " " & i
i = OpenDevice(3)
Text1.Text = Text1.Text & " " & i

FUNCTION OpenDevice(CardAddress: Longint):
CardAddress: Value between 0 and 3 which corresponds to the jumper (SK5, SK6) setting on the K8055 board. See table 1.

you may have the wrong CardAddress?
0
 

Author Comment

by:Parvez_Siddiqui
ID: 20334878
HI imitchie,
its showing me again -1...when the card is connected...i can see that it is connected via that k8055d card software...its also showing me the default value...but when i m calling through visual basic..it is giving me -1...plz help

0
 
LVL 25

Accepted Solution

by:
imitchie earned 2000 total points
ID: 20335999
i'm afraid either
- the DLL has a problem, because we've tried the OpenDevice with all four CardAddresses and none are connecting
- or it cannot connect while you have the Card software connected (I hope you're not trying it with other software connecteD!)
0
 

Author Comment

by:Parvez_Siddiqui
ID: 20336797
hey imitchie...thanks dear....thank-you very very much...previuosly i was trying when the other software was connected...no i tried without that...and it worked...once again thanks dear...
bye
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question