VERSION 5.00 Begin VB.Form Sample Caption = "Form1" ClientHeight = 3735 ClientLeft = 60 ClientTop = 450 ClientWidth = 1725 LinkTopic = "Form1" ScaleHeight = 3735 ScaleWidth = 1725 StartUpPosition = 3 'Windows Default Begin VB.ListBox Messages Height = 2205 Left = 120 TabIndex = 2 Top = 1200 Width = 1455 End Begin VB.CommandButton Stopbtn Caption = "Stop" Height = 495 Left = 120 TabIndex = 1 Top = 600 Width = 1455 End Begin VB.CommandButton Start Caption = "Start" Height = 495 Left = 120 TabIndex = 0 Top = 120 Width = 1455 End End Attribute VB_Name = "Sample" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Type DacDataPoint X As Integer Y As Integer R As Integer G As Integer B As Integer End Type Dim DeviceIndex As Long Dim DacDataArray(8) As DacDataPoint Dim done As Boolean Const FullCircle = 6.28318530717959 Private Sub Form_Load() Dim Dlg As New DetectForm Dlg.Show (vbModal) DeviceIndex = Dlg.DeviceIndex Stopbtn.Enabled = False End Sub Private Sub Start_Click() Dim ClockHZ As Double Dim Rot As Double Dim EC As Double Dim ES As Double Dim GotDacData As Boolean Dim magicNum As Double Dim I As Integer Dim ErrorCode As Long Messages.AddItem "Opening Dac" DACOutputOpen DeviceIndex, 40000 Messages.AddItem "Dac Opened" GotDacData = False Rot = 0 Start.Enabled = False Stopbtn.Enabled = True Do Until done If GotDacData = False Then Rot = Rot + 0.0004 If Rot > FullCircle Then Rot = 0 End If For I = 0 To 7 magicNum = Rot + I * (2 / 7) * FullCircle EC = Cos(magicNum) ES = Sin(magicNum) DacDataArray(I).X = 2048 + EC * 2047 DacDataArray(I).Y = 2048 + ES * 2047 Next I GotDacData = True End If ErrorCode = DACOutputFrame(DeviceIndex, 8, DacDataArray(0).X) If (ErrorCode = 0) Then GotDacData = False End If DoEvents Loop End Sub Private Sub Stopbtn_Click() done = True Messages.AddItem "Closing Dac" DACOutputClose DeviceIndex, True Messages.AddItem "DAC Closed" Start.Enabled = True End Sub