Creating code for vm116 k8062

Hello

I’ve checked out the topics for this device, but I’m still having some difficulty…

Can visual basic for applications (VBA) be used to create code for this device? I think the answer is no… I’m very skilled in VBA, but not so much in VB.

I do have VB10, but I’m kind of at a loss of where to start. I’ve copied some vague code from some examples, but I keep getting compile errors.

If VB is the only way to go (I don’t know C++ or others), can someone get me started. If I can get some basic commands to the device, I’m certain that I can make loops and other code to make it cool.

I’m only using 2 4-channel dimmer packs, so the coding can’t be too hard.

Thanks for any assistance.

[quote]Can visual basic for applications (VBA) be used to create code for this device?[/quote]Yes, VBA can be used.
Here a screenshot of a demo VBA for Excel:

Using this demo VBA you can set the 8 first DMX channel values according to the data entered to the cells B2-B9.

When you click the “Run Loop” button, a timer starts to run. The data of channels 1 to 8 is incremented every 100ms by 10. The value is reset when 255 is reached.

I hope the operation of this little VBA macro is quite self-explanatory.

Here a link to download the Excel workbook: box.net/shared/m3h2xqlm8b

If you anyhow like to study the Visual Basic 2010 you can download this simple demo project written in Visual Basic Express 2010:
box.net/shared/cd78tp75f7

The VBA code:

[code]Option Explicit
Private Declare Sub StartDevice Lib “k8062d.dll” ()
Private Declare Sub SetData Lib “k8062d.dll” (ByVal Channel As Long, ByVal Data As Long)
Private Declare Sub SetChannelCount Lib “k8062d.dll” (ByVal Count As Long)
Private Declare Sub StopDevice Lib “k8062d.dll” ()

Private Declare Function SetTimer Lib “user32” (ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib “user32” (ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Dim Data As Long
Dim TimerID As Long
Dim TimerSeconds As Single

Sub Open_Click()
StartDevice
SetChannelCount 8
Data = 0
End Sub

Sub Close_Click()
StopDevice
End Sub

Sub Set_Channels_Click()
Dim i As Long
For i = 2 To 9
SetData i - 1, ActiveSheet.Cells(i, 2)
Next
End Sub

Sub Run_Loop_Click()
TimerSeconds = 0.1 ’ how often to “pop” the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub

Sub Stop_Loop_Click()
On Error Resume Next
KillTimer 0&, TimerID
End Sub

Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
ByVal nIDEvent As Long, ByVal dwTimer As Long)
Dim i As Long
On Error Resume Next

’ The procedure is called by Windows. Put your
’ timer-related code here.

For i = 1 To 8
SetData i, Data
Next i
Data = Data + 10
If Data > 255 Then Data = 0
ActiveSheet.Cells(12, 2) = Data
End Sub[/code]

Outstanding!! Thank you very much.

Still got one problem – Excel freezes when I click the ‘open’ button, which is the procedure that initiates the startdevice command.

I’ve got files k8062d.dll, fasttime32.dll, and k8062e.exe in the windows/system32 directory. I’m running excel 2003 on windows vista.

Any ideas?

THanks.

Problem solved – I removed the ‘option explicit’ from the top. Works great!!

Thanks!

It’s good that you found the solution to the problem!

[quote]I’m running excel 2003 on windows vista.[/quote]I’m using Excel 2002 SP3 on Vista - no problems.
It seems there is some strange difference between Excel 2002 and 2003 …?!

[quote]I’ve got files k8062d.dll, fasttime32.dll, and k8062e.exe in the windows/system32 directory.[/quote]Indeed, I forgot to mention that these files must be copied to System32 folder.
In 64-bit environment (e.g. Windows 7 x64) these files must be put to SysWOW64 folder.