Attribute VB_Name = "StartProject"
Sub Main()

    'initialize variables
    InitializeVariables

    'Open Device
    Result = sdSearchDevice(DeviceIndex) 'if you connect several devices,for example four devices
                                        'device1    DeviceIndex = 0
                                        'device2    DeviceIndex = 1
                                        'device3    DeviceIndex = 2
                                        'device4    DeviceIndex = 3
                                        '.......    ................
    If Result = 0 Then
        MsgBox ("DSO not found!")
        End
    End If
    
    'Main Form display
    MainForm.Visible = True
    
    'initialize hardware
    Result = sdGetLevel(DeviceIndex, level(0))
    Result = sdSetTriggerAndSampleRate(DeviceIndex, TriggerSlope, ETS, Controlstate, PulseTrigger, PulseTriggerMode, PulseWidth)
    Result = sdSetFilt(DeviceIndex, FiltAndTrigger)
    Result = sdSetVoltageAndCoupling(DeviceIndex, Ch1Voltage, Ch2Voltage, Ch1_ACDC, Ch2_ACDC, Controlstate)
    Result = sdSetOffset(DeviceIndex, levers, Ch1Voltage, Ch2Voltage, TriggerSource, level(0))
    Result = sdCaptureStart(DeviceIndex)
    Result = sdTriggerEnabled(deivceindex)
    
    Initialization = False
    MainForm.GetDataLoop.Enabled = True
End Sub
Public Sub InitializeVariables()
    
    Initialization = True
    DeviceIndex = 0
    Ch1Enabled = True
    Ch2Enabled = True
    Ch1Voltage = 6
    Ch2Voltage = 6
    InterpolationLineMode = 1
    Ch1Position = 128
    Ch2Position = 384
    Ch1TriggerLevel = 128
    Ch2TriggerLevel = 384
    ExtTriggerLevel = 255
    TriggerSlope = 0
    TriggerSource = 0
    TriggerPosition = 50
    TriggerMode = 0
    PointOrLine = 1
    StartCapture = 1
    GridOn = True
    XYMode = False
    ScrollMode = 0
    TimeState.ScrollStart = 0
    FFTOn = False
    
    Controlstate.BufferSize = 10
    Controlstate.DataLength = 1
    Controlstate.IsAlt = 0
    Controlstate.SelectedChannel = 2
    Controlstate.Timebase = 13
    Controlstate.TriggerPosition = 50
    Controlstate.TriggerSource = 0
    
    levers.Ch1Position = 128
    levers.Ch2Position = 384
    levers.Ch1TriggerLevel = 128
    levers.Ch2TriggerLevel = 384
    levers.ExtTriggerLevel = 255
    
    FiltAndTrigger.Ch1Filt = 0
    FiltAndTrigger.Ch2Filt = 0
    FiltAndTrigger.TriggerFilt = 0
    FiltAndTrigger.TriggerMode = 0
    FiltAndTrigger.TriggerSlope = 0
    
    AutosetData.Ch1Enabled = 1
    AutosetData.Ch2Enabled = 1
    AutosetData.Ch1InGND = 0
    AutosetData.Ch2InGND = 0
    
    Ch1_ACDC = 1
    Ch2_ACDC = 1
    
    CH1_color.R = 0
    CH1_color.G = 255
    CH1_color.B = 0
    CH2_color.R = 255
    CH2_color.G = 255
    CH2_color.B = 0
    
    PulseWidth = 2
    PulseTriggerMode = 0
    PulseTrigger = 0
    ETS = 0
    
End Sub
