VM110 - using with Active Server pages

Is there any sample code to use the VM110 with Microsoft Active Server Pages (ASP)? Visual Basic code would be fine but I use Jscript, so a Jscript example would be better. Thanks.

Scripting languages like VBScript and JScript require a COM interface (ActiveX, …) to be able to use 3rd party functionality.

As for Visual Basic 6.0, try this download:
velleman.be/downloads/files/ … e_code.zip

It contains examples in VB 6.0, Delphi and Borland C++ Builder.

Google around a bit with the keywords: importing dll VB ASP

I did some Googling and found that I needed to register the DLL first. I tried running this from a batch file:

cd C:\WINDOWS\system32
C:\WINDOWS\system32\regsvr32 K8055D.dll

but got the error mesage:

“K8055D.dll was loaded, but the DllRegisterServer entry point was not found. This file cannot be registered”

Is there something that I need to do with the DLL before registering it? Or do I need a different DLL?

regsvr32.exe registers a COM-enabled dll by calling one of its predefined functions (DllRegisterServer).

K8055D.dll is not a COM dll, therefore the file cannot be registered or used as a COM object. What you can do is write your own COM object as a wrapper around the K8055D dll, but this requires some advanced programming skills.

Maybe you should switch to ASP.NET or something like that?

I created an ActiveX wrapper in VB6 and use it in ASP pages, vbscripts and HTML applications (.hta).

Here is the source for the wrapper and the ASP page. I called my DLL USB8055 and the class ZAP8055

Option Explicit
Private Declare Function OpenDevice Lib “k8055d.dll” (ByVal CardAddress As Long) As Long
Private Declare Sub CloseDevice Lib “k8055d.dll” ()

Private Declare Function ReadAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long) As Long
Private Declare Sub ReadAllAnalog Lib “k8055d.dll” (Data1 As Long, Data2 As Long)
Private Declare Sub OutputAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub OutputAllAnalog Lib “k8055d.dll” (ByVal Data1 As Long, ByVal Data2 As Long)
Private Declare Sub ClearAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub SetAllAnalog Lib “k8055d.dll” ()
Private Declare Sub ClearAllAnalog Lib “k8055d.dll” ()
Private Declare Sub SetAnalogChannel Lib “k8055d.dll” (ByVal Channel As Long)

Private Declare Sub WriteAllDigital Lib “k8055d.dll” (ByVal Data As Long)
Private Declare Sub ClearDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub ClearAllDigital Lib “k8055d.dll” ()
Private Declare Sub SetDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long)
Private Declare Sub SetAllDigital Lib “k8055d.dll” ()
Private Declare Function ReadDigitalChannel Lib “k8055d.dll” (ByVal Channel As Long) As Boolean
Private Declare Function ReadAllDigital Lib “k8055d.dll” () As Long

Private Declare Function ReadCounter Lib “k8055d.dll” (ByVal CounterNr As Long) As Long
Private Declare Sub ResetCounter Lib “k8055d.dll” (ByVal CounterNr As Long)
Private Declare Sub SetCounterDebounceTime Lib “k8055d.dll” (ByVal CounterNr As Long, ByVal DebounceTime As Long)

Private Declare Function SearchDevices Lib “k8055d.dll” () As Long
Private Declare Function SetCurrentDevice Lib “k8055d.dll” (ByVal Address As Long) As Long
Private Declare Sub Version Lib “k8055d.dll” ()
'Opens the communication link to the K8055 device
Public Function Open_Device(CardAddress As Long) As Long
Open_Device = OpenDevice(CardAddress) 'rs
End Function

'Closes the link to the K8055 device
Public Sub Close_Device()
CloseDevice
End Sub

'Reads the status of one analogue input-channel
Public Function Read_AnalogChannel(ByVal Channel As Long) As Long
Read_AnalogChannel = ReadAnalogChannel(Channel)
End Function

'Reads the status of both analogue input-channels
Public Sub Read_AllAnalog(Data1 As Long, Data2 As Long)
ReadAllAnalog Data1, Data2
End Sub

'Sets the analogue output channel according to the Data
Public Sub Output_AnalogChannel(ByVal Channel As Long, ByVal Data As Long)
OutputAnalogChannel Channel, Data
End Sub

'Sets both analogue output channels according to the Data
Public Sub Output_AllAnalog(ByVal Data1 As Long, ByVal Data2 As Long)
OutputAllAnalog Data1, Data2
End Sub

'Sets the analogue output channel to minimum
Public Sub Clear_AnalogChannel(ByVal Channel As Long)
ClearAnalogChannel Channel
End Sub

'Sets all analogue output channels to maximum
Public Sub Set_AllAnalog()
SetAllAnalog
End Sub

'Sets all analogue output channels to minimum
Public Sub Clear_AllAnalog()
ClearAllAnalog
End Sub

'Sets the analogue output channel to maximum
Public Sub Set_AnalogChannel(ByVal Channel As Long)
SetAnalogChannel Channel
End Sub

'Sets the digital outputs according to the data
Public Sub Write_AllDigital(ByVal Data As Long)
WriteAllDigital Data
End Sub

'Clears the output channel
Public Sub Clear_DigitalChannel(ByVal Channel As Long)
ClearDigitalChannel Channel
End Sub

'Clears all output channels
Public Sub Clear_AllDigital()
ClearAllDigital
End Sub

'Sets the output channel
Public Sub Set_DigitalChannel(ByVal Channel As Long)
SetDigitalChannel (Channel)
End Sub

'Sets all output channels
Public Sub Set_AllDigital()
SetAllDigital
End Sub

'Reads the status of the input channel
Public Function Read_DigitalChannel(ByVal Channel As Long) As Boolean
Read_DigitalChannel = ReadDigitalChannel(Channel)
End Function

'Reads the status of all the input channels
Public Function Read_AllDigital() As Long
Read_AllDigital = ReadAllDigital
End Function

'Reads the content of the pulse counter number 1 or counter number 2
Public Function Read_Counter(ByVal CounterNr As Long) As Long
Read_Counter = ReadCounter(CounterNr)
End Function

'Resets the 16 bit pulse counter number 1 or counter number 2
Public Sub Reset_Counter(ByVal CounterNr As Long)
ResetCounter CounterNr
End Sub

'Sets the debounce time to the pulse counter
Public Sub Set_CounterDebounceTime(ByVal CounterNr As Long, ByVal DebounceTime As Long)
SetCounterDebounceTime CounterNr, DebounceTime
End Sub

'Returns all connected devices as bit field
'bin 0000, dec 0 - No devices found
'bin 0001, dec 1 - card address 0 found
'bin 0010, dec 2 - card address 1 found
'bin 0100, dec 4 - card address 2 found
'bin 1000, dec 8 - card address 3 found
'e.g. value 9 = card 0 and card 3 connected
Public Function Search_Devices() As Long
Search_Devices = SearchDevices
End Function

'Set the current controlled device 0 thru 3. Returns device address or -1 if specified address not found
Public Function Set_CurrentDevice(ByVal Address As Long) As Long
Set_CurrentDevice = SetCurrentDevice(Address)
End Function

'Pops up window showing DLL version info
Public Sub DLL_Version()
Version
End Sub
-------------------------------------ASP source ------------------------
<%@ Language=VBScript %>
<%
Option Explicit
Dim USB8055

Set USB8055 = Server.CreateObject(“USB8055.ZAP8055”)
if USB8055.Open_Device(0) < 0 then
Response.Write “Open USB8055 device failed”
Response.End
end if

dim strHTML
dim strDataAction, strChan, strLog
strDataAction = Trim(Request.Form(“hidDataAction”))
strChan = Trim(Request.Form(“hidChannel”))
strLog = Trim(Request.Form(“hidLog”))
Select Case strDataAction
case “set”
if strChan = “all” then
USB8055.Set_AllDigital
strLog = “”
else
USB8055.Set_DigitalChannel strChan
end if
strHTML = strLog & "Turn on chan " & strChan & vbcrlf
’ Response.Write strHTML '“Case 10”
’ Response.End
case “clear”
if strChan = “all” then
USB8055.Clear_AllDigital
strLog = “”
else
USB8055.Clear_DigitalChannel strChan
end if
strHTML = strLog & "Turn off chan " & strChan & vbcrlf
’ Response.Write strHTML '“Case 10”
’ Response.End
end select
strDataAction = “”
USB8055.Close_Device
’ set USB8055 = nothing

%>

USB8055 USB Interface .menubtn2 { BACKGROUND-IMAGE: url(grad3.gif); BORDER-LEFT: #003399 1px solid; BORDER-RIGHT: #003399 1px solid; BORDER-TOP: #003399 1px solid; BORDER-BOTTOM: #003399 1px solid; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; PADDING-TOP: 4px; PADDING-BOTTOM: 4px; DISPLAY: inline; FONT-WEIGHT: bold; FONT-SIZE: 8pt; CURSOR: hand; COLOR: #3366ff; FONT-FAMILY: Verdana, Tahoma; TEXT-ALIGN: center; TEXT-DECORATION: none } .menubtn { FONT-WEIGHT: 500; FONT-SIZE: 12pt; CURSOR: hand; COLOR: crimson; FONT-FAMILY: Comic Sans MS, Verdana, Tahoma; TEXT-ALIGN: center; TEXT-DECORATION: none }   

Channel: <% ' generate drop-down options dim i for i = 1 to 8 if cstr(i) = strChan then Response.Write ("" & i & "") else Response.Write ("" & i & "") end if next %>   
<%=strHTML%>  <% ' Hidden fields to pass needed info to from client-side code %>

Ronczap, this is so nice, that you found a solution, Im a ASP guy as well.

I have some problem though, I have never built an Active X DLL before, and I cant get it to work, so hopefully you can answer my questions.

  1. In VB6 I create a Active X DLL projects.
  2. I paste the code for the dll in the Class window, change the name in the properties for the ClassModule to ZAP8055.
  3. I use “file/make project Dll” in VB6, saves it… as USB8055.DLL
  4. Drop the dll to “C:\WINDOWS\system32” and run regsvr32 “C:\WINDOWS\System32\USB8055.DLL”

Then, this should work, right?
I have the original Dll in System32 as well, but nothing, “Unknowng classstring” message.

I got this to work.
Step 2 in this tutorial was what ive missed…

devguru.com/features/tutoria … veX_VB.asp

ASP Object library, and then simply regsvr32 “C:\windows…”

I know we’re talking nearly 7 years on but I want to say a big thank you to ‘ronczap’ for posting information back in 2009 which explained how to create an ActiveX wrapper and then access the K8055.dll from ASP code.
It saved me buckets of time and allowed focus on the actual project (pH controller).
Many thanks