Option Strict Off
Option Explicit On
Imports System.Text
Friend Class Form1
	Inherits System.Windows.Forms.Form
#Region "Windows tH[ fUCiɂĐꂽR[h"
	Public Sub New()
		MyBase.New()
		'̌ĂяóAWindows tH[ fUCiŕKvłB
		InitializeComponent()
	End Sub
	'Form ́AR|[lgꗗɌ㏈s邽߂ dispose I[o[Ch܂B
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
	'Windows tH[ fUCiŕKvłB
	Private components As System.ComponentModel.IContainer
	Public WithEvents TextInfo As System.Windows.Forms.TextBox
	Public WithEvents ListData As System.Windows.Forms.ListBox
	Public WithEvents ComboRange As System.Windows.Forms.ComboBox
	Public WithEvents CommandExit As System.Windows.Forms.Button
	Public WithEvents CommandSave As System.Windows.Forms.Button
	Public WithEvents CommandStop As System.Windows.Forms.Button
	Public WithEvents CommandInfo As System.Windows.Forms.Button
	Public WithEvents CommandStart As System.Windows.Forms.Button
	Public WithEvents CommandInit As System.Windows.Forms.Button
	Public WithEvents TextDevice As System.Windows.Forms.TextBox
	Public WithEvents LabelStatus As System.Windows.Forms.Label
	Public WithEvents Label6 As System.Windows.Forms.Label
	Public WithEvents LabelCount As System.Windows.Forms.Label
	Public WithEvents Label5 As System.Windows.Forms.Label
	Public WithEvents Label4 As System.Windows.Forms.Label
	Public WithEvents Label3 As System.Windows.Forms.Label
	Public WithEvents Label2 As System.Windows.Forms.Label
	Public WithEvents Label1 As System.Windows.Forms.Label
	' : ȉ̃vV[W Windows tH[ fUCiŕKvłB
	'Windows tH[ fUCigĕύXł܂B
	'R[hGfB^gďCȂłB


	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.TextInfo = New System.Windows.Forms.TextBox()
		Me.ListData = New System.Windows.Forms.ListBox()
		Me.ComboRange = New System.Windows.Forms.ComboBox()
		Me.CommandExit = New System.Windows.Forms.Button()
		Me.CommandSave = New System.Windows.Forms.Button()
		Me.CommandStop = New System.Windows.Forms.Button()
		Me.CommandInfo = New System.Windows.Forms.Button()
		Me.CommandStart = New System.Windows.Forms.Button()
		Me.CommandInit = New System.Windows.Forms.Button()
		Me.TextDevice = New System.Windows.Forms.TextBox()
		Me.LabelStatus = New System.Windows.Forms.Label()
		Me.Label6 = New System.Windows.Forms.Label()
		Me.LabelCount = New System.Windows.Forms.Label()
		Me.Label5 = New System.Windows.Forms.Label()
		Me.Label4 = New System.Windows.Forms.Label()
		Me.Label3 = New System.Windows.Forms.Label()
		Me.Label2 = New System.Windows.Forms.Label()
		Me.Label1 = New System.Windows.Forms.Label()
		Me.SuspendLayout()
		'
		'TextInfo
		'
		Me.TextInfo.AcceptsReturn = True
		Me.TextInfo.AutoSize = False
		Me.TextInfo.BackColor = System.Drawing.SystemColors.Window
		Me.TextInfo.Cursor = System.Windows.Forms.Cursors.IBeam
		Me.TextInfo.ForeColor = System.Drawing.SystemColors.WindowText
		Me.TextInfo.Location = New System.Drawing.Point(8, 288)
		Me.TextInfo.MaxLength = 0
		Me.TextInfo.Name = "TextInfo"
		Me.TextInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.TextInfo.Size = New System.Drawing.Size(281, 25)
		Me.TextInfo.TabIndex = 17
		Me.TextInfo.Text = ""
		'
		'ListData
		'
		Me.ListData.BackColor = System.Drawing.SystemColors.Window
		Me.ListData.Cursor = System.Windows.Forms.Cursors.Default
		Me.ListData.ForeColor = System.Drawing.SystemColors.WindowText
		Me.ListData.ItemHeight = 12
		Me.ListData.Location = New System.Drawing.Point(104, 72)
		Me.ListData.Name = "ListData"
		Me.ListData.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.ListData.Size = New System.Drawing.Size(185, 184)
		Me.ListData.TabIndex = 10
		'
		'ComboRange
		'
		Me.ComboRange.BackColor = System.Drawing.SystemColors.Window
		Me.ComboRange.Cursor = System.Windows.Forms.Cursors.Default
		Me.ComboRange.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
		Me.ComboRange.ForeColor = System.Drawing.SystemColors.WindowText
		Me.ComboRange.Location = New System.Drawing.Point(104, 32)
		Me.ComboRange.Name = "ComboRange"
		Me.ComboRange.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.ComboRange.Size = New System.Drawing.Size(185, 20)
		Me.ComboRange.TabIndex = 9
		'
		'CommandExit
		'
		Me.CommandExit.BackColor = System.Drawing.SystemColors.Control
		Me.CommandExit.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandExit.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandExit.Location = New System.Drawing.Point(8, 216)
		Me.CommandExit.Name = "CommandExit"
		Me.CommandExit.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandExit.Size = New System.Drawing.Size(81, 25)
		Me.CommandExit.TabIndex = 7
		Me.CommandExit.Text = "I"
		'
		'CommandSave
		'
		Me.CommandSave.BackColor = System.Drawing.SystemColors.Control
		Me.CommandSave.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandSave.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandSave.Location = New System.Drawing.Point(8, 184)
		Me.CommandSave.Name = "CommandSave"
		Me.CommandSave.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandSave.Size = New System.Drawing.Size(81, 25)
		Me.CommandSave.TabIndex = 6
		Me.CommandSave.Text = "t@Cۑ"
		'
		'CommandStop
		'
		Me.CommandStop.BackColor = System.Drawing.SystemColors.Control
		Me.CommandStop.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandStop.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandStop.Location = New System.Drawing.Point(8, 152)
		Me.CommandStop.Name = "CommandStop"
		Me.CommandStop.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandStop.Size = New System.Drawing.Size(81, 25)
		Me.CommandStop.TabIndex = 5
		Me.CommandStop.Text = "W~"
		'
		'CommandInfo
		'
		Me.CommandInfo.BackColor = System.Drawing.SystemColors.Control
		Me.CommandInfo.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandInfo.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandInfo.Location = New System.Drawing.Point(8, 120)
		Me.CommandInfo.Name = "CommandInfo"
		Me.CommandInfo.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandInfo.Size = New System.Drawing.Size(81, 25)
		Me.CommandInfo.TabIndex = 4
		Me.CommandInfo.Text = "Ԏ擾"
		'
		'CommandStart
		'
		Me.CommandStart.BackColor = System.Drawing.SystemColors.Control
		Me.CommandStart.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandStart.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandStart.Location = New System.Drawing.Point(8, 88)
		Me.CommandStart.Name = "CommandStart"
		Me.CommandStart.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandStart.Size = New System.Drawing.Size(81, 25)
		Me.CommandStart.TabIndex = 3
		Me.CommandStart.Text = "WJn"
		'
		'CommandInit
		'
		Me.CommandInit.BackColor = System.Drawing.SystemColors.Control
		Me.CommandInit.Cursor = System.Windows.Forms.Cursors.Default
		Me.CommandInit.ForeColor = System.Drawing.SystemColors.ControlText
		Me.CommandInit.Location = New System.Drawing.Point(8, 56)
		Me.CommandInit.Name = "CommandInit"
		Me.CommandInit.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.CommandInit.Size = New System.Drawing.Size(81, 25)
		Me.CommandInit.TabIndex = 2
		Me.CommandInit.Text = ""
		'
		'TextDevice
		'
		Me.TextDevice.AcceptsReturn = True
		Me.TextDevice.AutoSize = False
		Me.TextDevice.BackColor = System.Drawing.SystemColors.Window
		Me.TextDevice.Cursor = System.Windows.Forms.Cursors.IBeam
		Me.TextDevice.ForeColor = System.Drawing.SystemColors.WindowText
		Me.TextDevice.Location = New System.Drawing.Point(8, 32)
		Me.TextDevice.MaxLength = 0
		Me.TextDevice.Name = "TextDevice"
		Me.TextDevice.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.TextDevice.Size = New System.Drawing.Size(81, 18)
		Me.TextDevice.TabIndex = 1
		Me.TextDevice.Text = "DIG000"
		'
		'LabelStatus
		'
		Me.LabelStatus.BackColor = System.Drawing.SystemColors.Control
		Me.LabelStatus.Cursor = System.Windows.Forms.Cursors.Default
		Me.LabelStatus.ForeColor = System.Drawing.SystemColors.ControlText
		Me.LabelStatus.Location = New System.Drawing.Point(224, 264)
		Me.LabelStatus.Name = "LabelStatus"
		Me.LabelStatus.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.LabelStatus.Size = New System.Drawing.Size(57, 17)
		Me.LabelStatus.TabIndex = 16
		Me.LabelStatus.Text = "0H"
		'
		'Label6
		'
		Me.Label6.BackColor = System.Drawing.SystemColors.Control
		Me.Label6.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label6.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label6.Location = New System.Drawing.Point(160, 264)
		Me.Label6.Name = "Label6"
		Me.Label6.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label6.Size = New System.Drawing.Size(57, 17)
		Me.Label6.TabIndex = 15
		Me.Label6.Text = "Xe[^X"
		'
		'LabelCount
		'
		Me.LabelCount.BackColor = System.Drawing.SystemColors.Control
		Me.LabelCount.Cursor = System.Windows.Forms.Cursors.Default
		Me.LabelCount.ForeColor = System.Drawing.SystemColors.ControlText
		Me.LabelCount.Location = New System.Drawing.Point(96, 264)
		Me.LabelCount.Name = "LabelCount"
		Me.LabelCount.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.LabelCount.Size = New System.Drawing.Size(57, 17)
		Me.LabelCount.TabIndex = 14
		Me.LabelCount.Text = "0"
		'
		'Label5
		'
		Me.Label5.BackColor = System.Drawing.SystemColors.Control
		Me.Label5.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label5.Location = New System.Drawing.Point(8, 264)
		Me.Label5.Name = "Label5"
		Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label5.Size = New System.Drawing.Size(81, 17)
		Me.Label5.TabIndex = 13
		Me.Label5.Text = "TvO"
		'
		'Label4
		'
		Me.Label4.BackColor = System.Drawing.SystemColors.Control
		Me.Label4.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label4.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label4.Location = New System.Drawing.Point(176, 56)
		Me.Label4.Name = "Label4"
		Me.Label4.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label4.Size = New System.Drawing.Size(65, 17)
		Me.Label4.TabIndex = 12
		Me.Label4.Text = "d"
		'
		'Label3
		'
		Me.Label3.BackColor = System.Drawing.SystemColors.Control
		Me.Label3.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label3.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label3.Location = New System.Drawing.Point(104, 56)
		Me.Label3.Name = "Label3"
		Me.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label3.Size = New System.Drawing.Size(57, 17)
		Me.Label3.TabIndex = 11
		Me.Label3.Text = "JEg"
		'
		'Label2
		'
		Me.Label2.BackColor = System.Drawing.SystemColors.Control
		Me.Label2.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label2.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label2.Location = New System.Drawing.Point(104, 8)
		Me.Label2.Name = "Label2"
		Me.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label2.Size = New System.Drawing.Size(97, 17)
		Me.Label2.TabIndex = 8
		Me.Label2.Text = "̓W"
		'
		'Label1
		'
		Me.Label1.BackColor = System.Drawing.SystemColors.Control
		Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
		Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
		Me.Label1.Location = New System.Drawing.Point(8, 8)
		Me.Label1.Name = "Label1"
		Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
		Me.Label1.Size = New System.Drawing.Size(65, 17)
		Me.Label1.TabIndex = 0
		Me.Label1.Text = "foCX"
		'
		'Form1
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
		Me.ClientSize = New System.Drawing.Size(301, 325)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextInfo, Me.ListData, Me.ComboRange, Me.CommandExit, Me.CommandSave, Me.CommandStop, Me.CommandInfo, Me.CommandStart, Me.CommandInit, Me.TextDevice, Me.LabelStatus, Me.Label6, Me.LabelCount, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
		Me.Location = New System.Drawing.Point(4, 30)
		Me.MaximizeBox = False
		Me.Name = "Form1"
		Me.Text = "f[^K["
		Me.ResumeLayout(False)

	End Sub
#End Region 

	Dim Id As Short	' foCXID
	Const MAX_SAMPLES As Integer = 1000	' őTvO
	Dim Data(MAX_SAMPLES) As Single	' 擾f[^̔z
	Dim Samples As Integer	' 擾f[^

	'==================================
	' tH[̃[h
	'==================================
	Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		'----------------------------------
		' ̓WR{{bNX̏
		'----------------------------------
		ComboRange.Items.Add(("-20.0 - +20.0V"))
		ComboRange.Items.Add(("-10.0 - +10.0V"))
		ComboRange.Items.Add(("-5.0 - +5.0V"))
		ComboRange.Items.Add(("-2.0 - +2.0V"))
		ComboRange.Items.Add(("-1.0 - +1.0V"))
		ComboRange.Items.Add(("-0.5 - + 0.5V"))
		ComboRange.Items.Add(("-0.2 - +0.2V"))
		ComboRange.Items.Add(("-0.1 - +0.1V"))
		ComboRange.Items.Add(("-0.05 - +0.05V"))
		ComboRange.Items.Add(("-0.02 - +0.02V"))

		Samples = 0
	End Sub

	'==================================
	' 
	'==================================
	Private Sub CommandInit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandInit.Click
		Dim Ret As Integer	   ' ߂l
		Dim Ret2 As Integer	   ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)	   ' G[

		'----------------------------------
		' 
		'----------------------------------
		Ret = DigInit(TextDevice.Text, Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigInit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' foCX̃Zbg
		'----------------------------------
		Ret = DigResetDevice(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigResetDevice = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = " : I"
	End Sub

	'==================================
	' ̓W̐ݒ
	'==================================
	Private Sub ComboRange_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles ComboRange.SelectedIndexChanged
		Dim Range As Single
		Dim Index As Short
		Index = ComboRange.SelectedIndex
		Select Case Index
			Case 0 : Range = DIG_RANGE_40VPP
			Case 1 : Range = DIG_RANGE_20VPP
			Case 2 : Range = DIG_RANGE_10VPP
			Case 3 : Range = DIG_RANGE_4VPP
			Case 4 : Range = DIG_RANGE_2VPP
			Case 5 : Range = DIG_RANGE_1VPP
			Case 6 : Range = DIG_RANGE_400MVPP
			Case 7 : Range = DIG_RANGE_200MVPP
			Case 8 : Range = DIG_RANGE_100MVPP
			Case 9 : Range = DIG_RANGE_40MVPP
		End Select

		'----------------------------------
		' `l0̓̓Wݒ
		'----------------------------------
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)		  ' G[

		Ret = DigSetRange(Id, DIG_CHANNEL0, Range)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetRange = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = "̓Wݒ : I"
	End Sub

	'==================================
	' WJn
	'==================================
	Private Sub CommandStart_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandStart.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)		  ' G[

		'----------------------------------
		' ϐ
		'----------------------------------
		Samples = 0
		ListData.Items.Clear()

		'----------------------------------
		' 샂[hݒFf[^K[[h
		'----------------------------------
		Ret = DigSetDigitizerMode(Id, DIG_MODE_LOGGER)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetDigitizerMode = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' TvONbN\[XݒF{[hU@
		'----------------------------------
		Ret = DigSetClockSource(Id, DIG_ECU_SRC_CLOCK)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetClockSource = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' TvONbNݒF1000usec (ݒl * 10 + 10(nsec))
		'----------------------------------
		Ret = DigSetSampleClock(Id, 99999)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetSampleClock = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' R[hW񐔐ݒF1
		'----------------------------------
		Ret = DigSetRecordNumber(Id, 1)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetRecordNumber = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' vgKTvݒF1000Tv
		'----------------------------------
		Ret = DigSetPreSampleTimes(Id, MAX_SAMPLES)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetPreSampleTimes = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' |XggKTvݒFȂ
		'----------------------------------
		Ret = DigSetPostSampleTimes(Id, 0)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetPostSampleTimes = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' `lݒF0`l̂ݗL
		'----------------------------------
		' 0`lLɂ
		Ret = DigSetChannel(Id, DIG_CHANNEL0, DIG_ENABLE)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetChannel = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		' 1`l𖳌ɂ
		Ret = DigSetChannel(Id, DIG_CHANNEL1, DIG_DISABLE)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetChannel = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' vgKނ̐ݒF
		'----------------------------------
		Ret = DigSetPreTriggerType(Id, DIG_TRIGGERTYPE_AUTO)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigSetPreTriggerType = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' Jn
		'----------------------------------
		Ret = DigStart(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigStart = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		TextInfo.Text = "WJn : I"

		'----------------------------------
		' 쒆Xe[^XOFFɂȂ܂Ń|[O
		'----------------------------------
		Dim Status As Integer

		Do
			System.Windows.Forms.Application.DoEvents()			 ' _CAOLɂ邽߂̏
			'----------------------------------
			' hCoTv擾
			'----------------------------------
			Ret = DigGetDriverMemorySamples(Id, Samples)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
				TextInfo.Text = "DigGetDriverMemorySamples = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
			LabelCount.Text = CStr(Samples)

			'----------------------------------
			' Xe[^X̎擾
			'----------------------------------
			Ret = DigGetStatus(Id, Status)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
				TextInfo.Text = "DigGetStatus = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
			LabelStatus.Text = Hex(Status) & "H"
		Loop While (Status And DIG_STATUS_BUSY) = DIG_STATUS_BUSY

		'----------------------------------
		' ~ɃhCoɊi[ĂTv擾
		'----------------------------------
		Ret = DigGetDriverMemorySamples(Id, Samples)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigGetDriverMemorySamples = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		'----------------------------------
		' Wf[^擾
		'----------------------------------
		Dim TriggerPoint As Integer		  ' |XggK̐擪f[^ʒu
		If Samples > 0 Then
			' 擾TvOf[^i[zTCY𒴂Ȃ悤
			If Samples > MAX_SAMPLES Then
				Samples = MAX_SAMPLES
			End If
            Ret = DigReadSamples(Id, Samples, Data, TriggerPoint)
			If Ret <> 0 Then
				Ret2 = DigGetErrorString(Ret, ErrorString)
				TextInfo.Text = "DigReadSamples = " & Ret & " : " & ErrorString.ToString()
				Exit Sub
			End If
		End If
		'----------------------------------
		' 擾f[^\
		'----------------------------------
		Dim i As Integer
		For i = 0 To Samples - 1
			ListData.Items.Add(i + 1 & "           " & String.Format("{0:F3}", Data(i)))
		Next i

	End Sub

	'==================================
	' Ԏ擾
	'==================================
	Private Sub CommandInfo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandInfo.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)		  ' G[
		Dim Count As Integer		  ' TvO
		Dim Status As Integer		  ' Xe[^X

		'----------------------------------
		' hCoTv擾
		'----------------------------------
		Ret = DigGetDriverMemorySamples(Id, Count)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
            TextInfo.Text = "DigGetDriverMemorySamples = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		LabelCount.Text = CStr(Count)

		'----------------------------------
		' Xe[^X̎擾
		'----------------------------------
		Ret = DigGetStatus(Id, Status)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigGetStatus = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If
		LabelStatus.Text = Hex(Status) & "H"

		TextInfo.Text = "Ԏ擾 : I"
	End Sub

	'==================================
	' W~
	'==================================
	Private Sub CommandStop_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandStop.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)		  ' G[

		Ret = DigStop(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigExit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = "W~ : I"
	End Sub

	'==================================
	' t@Cۑ
	'==================================
	Private Sub CommandSave_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandSave.Click
		' f[^݂ȂꍇAG[Ԃ܂B
		If Samples = 0 Then
			TextInfo.Text = "Wf[^݂܂B"
			Exit Sub
		End If

		'----------------------------------
		' t@Cۑ
		'----------------------------------
		Dim FileName As String		 ' t@C
		FileName = "DataLogger.csv"		  ' t@C̐ݒ

		' t@C쐬܂B
		' R[hShift-JISŃt@C㏑
		Dim sw As New System.IO.StreamWriter(FileName, False, System.Text.Encoding.GetEncoding(932))
		Try
			Dim i As Integer
			For i = 0 To Samples - 1
				' t@CɃf[^݂܂B
				sw.WriteLine(String.Format("{0:F3}", Data(i)))
			Next i
		Finally
			' t@C܂B
			sw.Close()
		End Try

		TextInfo.Text = "t@Cۑ : I"
	End Sub

	'==================================
	' I
	'==================================
	Private Sub CommandExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles CommandExit.Click
		Dim Ret As Integer		  ' ߂l
		Dim Ret2 As Integer		  ' ߂l2
		Dim ErrorString As New StringBuilder("", 256)		  ' G[

		Ret = DigExit(Id)
		If Ret <> 0 Then
			Ret2 = DigGetErrorString(Ret, ErrorString)
			TextInfo.Text = "DigExit = " & Ret & " : " & ErrorString.ToString()
			Exit Sub
		End If

		TextInfo.Text = "I : I"
	End Sub

	'==================================
	' tH[̃A[h
	'==================================
	Private Sub Form1_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
		Dim Ret As Integer		  ' ߂l
		Ret = DigExit(Id)
	End Sub
End Class