VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 1695 ClientLeft = 60 ClientTop = 345 ClientWidth = 6015 LinkTopic = "Form1" ScaleHeight = 113 ScaleMode = 3 'Pixel ScaleWidth = 401 StartUpPosition = 3 'Windows Default Begin VB.CommandButton DACSetButton Caption = "Confirm DAC Range" Height = 375 Left = 120 TabIndex = 2 Top = 840 Width = 1575 End Begin VB.ComboBox DACCombo Height = 315 ItemData = "MainForm.frx":0000 Left = 120 List = "MainForm.frx":0010 Style = 2 'Dropdown List TabIndex = 1 Top = 360 Width = 1575 End Begin VB.CommandButton StopButton Caption = "Stop" Enabled = 0 'False Height = 375 Left = 1800 TabIndex = 4 Top = 600 Width = 1575 End Begin VB.ListBox VoltList Columns = 1 Height = 1425 ItemData = "MainForm.frx":0046 Left = 3480 List = "MainForm.frx":0048 TabIndex = 5 Top = 120 Width = 2415 End Begin VB.CommandButton GoButton Caption = "Go" Enabled = 0 'False Height = 375 Left = 1800 TabIndex = 3 Top = 120 Width = 1575 End Begin VB.Timer ADPollTime Enabled = 0 'False Interval = 45 Left = 1800 Top = 1080 End Begin VB.Label DACLabel Alignment = 2 'Center Caption = "DAC Range" Height = 255 Left = 120 TabIndex = 0 Top = 120 Width = 1575 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim DeviceIndex As Long Const Channels = 2 Private Sub ADPollTime_Timer() Dim Status As Long Dim Volts(0 To Channels - 1) As Double Dim Channel As Long Status = ADC_GetScanV(DeviceIndex, Volts(0)) If Status <> 0 Then StopButton.Value = True MsgBox "Error " & Status & " from ADC_GetScanV.", , "ADC_GetScanV Error" Exit Sub End If For Channel = 0 To Channels - 1 VoltList.List(Channel) = "Ch " & Channel & ": " & Volts(Channel) & " V" Next End Sub Private Sub DACSetButton_Click() Dim I As Long I = DACCombo.ListIndex If (I < 0) Or (I > 3) Then Beep Exit Sub End If 'Set the DAC range, to unsleep the DAC/ADC reference. DACSetBoardRange DeviceIndex, I DACLabel.Visible = False DACCombo.Visible = False DACSetButton.Visible = False GoButton.Enabled = True End Sub Private Sub Form_Load() Dim Dlg As DetectForm Dim Status As Long 'dummy variables for function call since we can't do null in VBasic Dim PID As Long Dim NameSize As Long Dim Name As String Dim DIOBytes As Long Dim Counters As Long Dim outdata As Long NameSize = 256 Name = String$(NameSize, " ") 'If you only have the one board, QueryDeviceInfo with diOnly will succeed 'with the right PID. If you have more than one board, or haven't plugged it 'in, it will fail, and this code will pop up the detector form so the user 'can pick a board or cancel. DeviceIndex = diOnly Status = QueryDeviceInfo(DeviceIndex, PID, NameSize, Name, DIOBytes, Counters) If (Status <> 0) Or Not ((PID >= &H8070&) And (PID <= &H807F&)) Then Set Dlg = New DetectForm Dlg.Show vbModal DeviceIndex = Dlg.DeviceIndex Unload Dlg If DeviceIndex = -1 Then Unload Me Exit Sub End If End If DACCombo.ListIndex = 2 End Sub Private Sub GoButton_Click() GoButton.Enabled = False StopButton.Enabled = True ADPollTime.Enabled = True End Sub Private Sub StopButton_Click() ADPollTime.Enabled = False GoButton.Enabled = True StopButton.Enabled = False End Sub