[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]