VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx" Begin VB.Form MainForm Caption = "Form1" ClientHeight = 2295 ClientLeft = 60 ClientTop = 345 ClientWidth = 8775 LinkTopic = "Form1" ScaleHeight = 2295 ScaleWidth = 8775 StartUpPosition = 2 'CenterScreen Begin MSComctlLib.Slider CountSlider Height = 495 Index = 0 Left = 120 TabIndex = 1 Top = 360 Width = 7815 _ExtentX = 13785 _ExtentY = 873 _Version = 393216 LargeChange = 256 Max = 65535 TickFrequency = 4096 End Begin VB.CheckBox UpdateCheck Caption = "Update each DAC individually as you change it (un-check for simultaneous mode)." Height = 375 Left = 1440 TabIndex = 7 Top = 1800 Value = 1 'Checked Width = 7215 End Begin VB.CommandButton UpdateButton Caption = "&Update" Enabled = 0 'False Height = 375 Left = 120 TabIndex = 6 Top = 1800 Width = 1215 End Begin MSComctlLib.Slider CountSlider Height = 495 Index = 1 Left = 120 TabIndex = 3 Top = 840 Width = 7815 _ExtentX = 13785 _ExtentY = 873 _Version = 393216 LargeChange = 256 Max = 65535 TickFrequency = 4096 End Begin VB.Label CountLabel Caption = "0000" Height = 255 Index = 1 Left = 8040 TabIndex = 5 Top = 960 Width = 615 End Begin VB.Label CountLabel Caption = "0000" Height = 255 Index = 0 Left = 8040 TabIndex = 4 Top = 480 Width = 615 End Begin VB.Label Label2 Caption = "DAC 1" Height = 255 Left = 120 TabIndex = 2 Top = 1440 Width = 7815 End Begin VB.Label Label1 Caption = "DAC 0" Height = 255 Left = 120 TabIndex = 0 Top = 120 Width = 7815 End End Attribute VB_Name = "MainForm" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Type TDACPoint Channel As Integer Data As Integer End Type Dim DeviceIndex As Long 'Compensates for the lack of unsigned types and range-check problems. Private Function As16(I32 As Long) As Integer Dim Result As Integer Result = I32 And &H7FFF If I32 And &H8000& Then Result = Result Or &H8000 As16 = Result End Function Private Sub CountSlider_Change(Index As Integer) Dim Counts As Long Dim Buf As String Counts = CountSlider(Index).Value Buf = Hex$(Counts) Buf = String$(4 - Len(Buf), "0") + Buf CountLabel(Index).Caption = Buf If UpdateCheck.Value Then DACDirect DeviceIndex, Index, As16(Counts) Else CountLabel(Index).BackColor = &H8000& CountLabel(Index).ForeColor = &HFFFFFF End If End Sub Private Sub CountSlider_Scroll(Index As Integer) CountSlider_Change Index End Sub Private Sub Form_Load() Dim PID As Long, Status As Long DeviceIndex = diOnly Status = QueryDeviceInfo(DeviceIndex, PID, 0, "", 0, 0) If (Status <> 0) Or (PID < &H8140&) Or (PID > &H815F&) Then DetectForm.Show vbModal, Me If DetectForm.DetectOK Then DeviceIndex = DetectForm.DeviceIndex Unload DetectForm QueryDeviceInfo DeviceIndex, PID, 0, "", 0, 0 Else Unload DetectForm Unload Me Exit Sub End If End If DACDirect DeviceIndex, 0, 0 DACDirect DeviceIndex, 1, 0 DACSetBoardRange DeviceIndex, 0 'Turn on the DACs. End Sub Private Sub UpdateButton_Click() Dim Changes(0 To 1) As TDACPoint Dim I As Long Changes(0).Channel = 0 Changes(0).Data = As16(CountSlider(0).Value) Changes(1).Channel = 1 Changes(1).Data = As16(CountSlider(1).Value) DACMultiDirect DeviceIndex, Changes(0), 2 For I = 0 To 1 CountLabel(I).BackColor = BackColor CountLabel(I).ForeColor = ForeColor Next End Sub Private Sub UpdateCheck_Click() If UpdateCheck.Value Then UpdateButton_Click UpdateButton.Enabled = Not UpdateCheck.Value End Sub