Option Strict Off
Option Explicit On 
Public Class Counter
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	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

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents Label13 As System.Windows.Forms.Label
	Friend WithEvents Label11 As System.Windows.Forms.Label
	Friend WithEvents Label7 As System.Windows.Forms.Label
	Friend WithEvents GroupBox3 As System.Windows.Forms.GroupBox
	Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
	Friend WithEvents Label3 As System.Windows.Forms.Label
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents Label10 As System.Windows.Forms.Label
	Friend WithEvents Label9 As System.Windows.Forms.Label
	Friend WithEvents Label8 As System.Windows.Forms.Label
	Friend WithEvents Label6 As System.Windows.Forms.Label
	Friend WithEvents Label5 As System.Windows.Forms.Label
	Friend WithEvents Label4 As System.Windows.Forms.Label
	Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
	Friend WithEvents CntTimer As System.Windows.Forms.Timer
	Friend WithEvents btnCntExit As System.Windows.Forms.Button
	Friend WithEvents btnCntStop As System.Windows.Forms.Button
	Friend WithEvents btnCntPreset As System.Windows.Forms.Button
	Friend WithEvents btnCntCompare As System.Windows.Forms.Button
	Friend WithEvents btnCntInit As System.Windows.Forms.Button
	Friend WithEvents txtPreset7 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset6 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset5 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset4 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset3 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset2 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset1 As System.Windows.Forms.TextBox
	Friend WithEvents txtPreset0 As System.Windows.Forms.TextBox
	Friend WithEvents rdoPreset1 As System.Windows.Forms.RadioButton
	Friend WithEvents rdoPreset0 As System.Windows.Forms.RadioButton
	Friend WithEvents txtCh7 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh6 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh5 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh4 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh3 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh2 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh1 As System.Windows.Forms.TextBox
	Friend WithEvents txtCh0 As System.Windows.Forms.TextBox
	Friend WithEvents rdoCh1 As System.Windows.Forms.RadioButton
	Friend WithEvents rdoCh0 As System.Windows.Forms.RadioButton
	Friend WithEvents txtErr As System.Windows.Forms.TextBox
	Friend WithEvents txtStart As System.Windows.Forms.TextBox
	Friend WithEvents cboDeviceName As System.Windows.Forms.ComboBox
	Friend WithEvents btnCntStart As System.Windows.Forms.Button
	Friend WithEvents btnExit As System.Windows.Forms.Button
	Friend WithEvents txtReturnCode As System.Windows.Forms.TextBox
	Friend WithEvents btnCntMode As System.Windows.Forms.Button
	Friend WithEvents txtStatus7 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus6 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus5 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus4 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus3 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus2 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus1 As System.Windows.Forms.TextBox
	Friend WithEvents txtStatus0 As System.Windows.Forms.TextBox
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.components = New System.ComponentModel.Container()
		Me.btnCntExit = New System.Windows.Forms.Button()
		Me.btnCntStop = New System.Windows.Forms.Button()
		Me.btnCntPreset = New System.Windows.Forms.Button()
		Me.btnCntCompare = New System.Windows.Forms.Button()
		Me.btnCntInit = New System.Windows.Forms.Button()
		Me.Label13 = New System.Windows.Forms.Label()
		Me.Label11 = New System.Windows.Forms.Label()
		Me.Label7 = New System.Windows.Forms.Label()
		Me.GroupBox3 = New System.Windows.Forms.GroupBox()
		Me.txtPreset7 = New System.Windows.Forms.TextBox()
		Me.txtPreset6 = New System.Windows.Forms.TextBox()
		Me.txtPreset5 = New System.Windows.Forms.TextBox()
		Me.txtPreset4 = New System.Windows.Forms.TextBox()
		Me.txtPreset3 = New System.Windows.Forms.TextBox()
		Me.txtPreset2 = New System.Windows.Forms.TextBox()
		Me.txtPreset1 = New System.Windows.Forms.TextBox()
		Me.txtPreset0 = New System.Windows.Forms.TextBox()
		Me.rdoPreset1 = New System.Windows.Forms.RadioButton()
		Me.rdoPreset0 = New System.Windows.Forms.RadioButton()
		Me.GroupBox1 = New System.Windows.Forms.GroupBox()
		Me.txtCh7 = New System.Windows.Forms.TextBox()
		Me.txtCh6 = New System.Windows.Forms.TextBox()
		Me.txtCh5 = New System.Windows.Forms.TextBox()
		Me.txtCh4 = New System.Windows.Forms.TextBox()
		Me.txtCh3 = New System.Windows.Forms.TextBox()
		Me.txtCh2 = New System.Windows.Forms.TextBox()
		Me.txtCh1 = New System.Windows.Forms.TextBox()
		Me.txtCh0 = New System.Windows.Forms.TextBox()
		Me.rdoCh1 = New System.Windows.Forms.RadioButton()
		Me.rdoCh0 = New System.Windows.Forms.RadioButton()
		Me.txtErr = New System.Windows.Forms.TextBox()
		Me.txtStart = New System.Windows.Forms.TextBox()
		Me.Label3 = New System.Windows.Forms.Label()
		Me.Label1 = New System.Windows.Forms.Label()
		Me.Label2 = New System.Windows.Forms.Label()
		Me.cboDeviceName = New System.Windows.Forms.ComboBox()
		Me.btnCntStart = New System.Windows.Forms.Button()
		Me.btnExit = New System.Windows.Forms.Button()
		Me.txtReturnCode = New System.Windows.Forms.TextBox()
		Me.Label10 = New System.Windows.Forms.Label()
		Me.btnCntMode = New System.Windows.Forms.Button()
		Me.Label9 = New System.Windows.Forms.Label()
		Me.Label8 = New System.Windows.Forms.Label()
		Me.Label6 = New System.Windows.Forms.Label()
		Me.Label5 = New System.Windows.Forms.Label()
		Me.Label4 = New System.Windows.Forms.Label()
		Me.GroupBox2 = New System.Windows.Forms.GroupBox()
		Me.txtStatus7 = New System.Windows.Forms.TextBox()
		Me.txtStatus6 = New System.Windows.Forms.TextBox()
		Me.txtStatus5 = New System.Windows.Forms.TextBox()
		Me.txtStatus4 = New System.Windows.Forms.TextBox()
		Me.txtStatus3 = New System.Windows.Forms.TextBox()
		Me.txtStatus2 = New System.Windows.Forms.TextBox()
		Me.txtStatus1 = New System.Windows.Forms.TextBox()
		Me.txtStatus0 = New System.Windows.Forms.TextBox()
		Me.CntTimer = New System.Windows.Forms.Timer(Me.components)
		Me.GroupBox3.SuspendLayout()
		Me.GroupBox1.SuspendLayout()
		Me.GroupBox2.SuspendLayout()
		Me.SuspendLayout()
		'
		'btnCntExit
		'
		Me.btnCntExit.Location = New System.Drawing.Point(437, 367)
		Me.btnCntExit.Name = "btnCntExit"
		Me.btnCntExit.Size = New System.Drawing.Size(104, 25)
		Me.btnCntExit.TabIndex = 11
		Me.btnCntExit.Text = "CntExit"
		'
		'btnCntStop
		'
		Me.btnCntStop.Location = New System.Drawing.Point(437, 272)
		Me.btnCntStop.Name = "btnCntStop"
		Me.btnCntStop.Size = New System.Drawing.Size(104, 25)
		Me.btnCntStop.TabIndex = 10
		Me.btnCntStop.Text = "CntStopCount"
		'
		'btnCntPreset
		'
		Me.btnCntPreset.Location = New System.Drawing.Point(437, 240)
		Me.btnCntPreset.Name = "btnCntPreset"
		Me.btnCntPreset.Size = New System.Drawing.Size(104, 25)
		Me.btnCntPreset.TabIndex = 9
		Me.btnCntPreset.Text = "CntPreset"
		'
		'btnCntCompare
		'
		Me.btnCntCompare.Location = New System.Drawing.Point(437, 136)
		Me.btnCntCompare.Name = "btnCntCompare"
		Me.btnCntCompare.Size = New System.Drawing.Size(104, 25)
		Me.btnCntCompare.TabIndex = 7
		Me.btnCntCompare.Text = "Set Comparison..."
		'
		'btnCntInit
		'
		Me.btnCntInit.Location = New System.Drawing.Point(437, 12)
		Me.btnCntInit.Name = "btnCntInit"
		Me.btnCntInit.Size = New System.Drawing.Size(104, 25)
		Me.btnCntInit.TabIndex = 0
		Me.btnCntInit.Text = "CntInit"
		'
		'Label13
		'
		Me.Label13.Location = New System.Drawing.Point(10, 412)
		Me.Label13.Name = "Label13"
		Me.Label13.Size = New System.Drawing.Size(78, 17)
		Me.Label13.TabIndex = 77
		Me.Label13.Text = "Return Value :"
		'
		'Label11
		'
		Me.Label11.Location = New System.Drawing.Point(10, 364)
		Me.Label11.Name = "Label11"
		Me.Label11.Size = New System.Drawing.Size(62, 18)
		Me.Label11.TabIndex = 74
		Me.Label11.Text = "Channel 7"
		'
		'Label7
		'
		Me.Label7.Location = New System.Drawing.Point(10, 258)
		Me.Label7.Name = "Label7"
		Me.Label7.Size = New System.Drawing.Size(62, 19)
		Me.Label7.TabIndex = 70
		Me.Label7.Text = "Channel 3"
		'
		'GroupBox3
		'
		Me.GroupBox3.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtPreset7, Me.txtPreset6, Me.txtPreset5, Me.txtPreset4, Me.txtPreset3, Me.txtPreset2, Me.txtPreset1, Me.txtPreset0, Me.rdoPreset1, Me.rdoPreset0})
		Me.GroupBox3.Location = New System.Drawing.Point(314, 88)
		Me.GroupBox3.Name = "GroupBox3"
		Me.GroupBox3.Size = New System.Drawing.Size(107, 304)
		Me.GroupBox3.TabIndex = 5
		Me.GroupBox3.TabStop = False
		Me.GroupBox3.Text = "Preset Value"
		'
		'txtPreset7
		'
		Me.txtPreset7.Location = New System.Drawing.Point(8, 273)
		Me.txtPreset7.Name = "txtPreset7"
		Me.txtPreset7.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset7.TabIndex = 9
		Me.txtPreset7.Text = "TextBox8"
		'
		'txtPreset6
		'
		Me.txtPreset6.Location = New System.Drawing.Point(8, 246)
		Me.txtPreset6.Name = "txtPreset6"
		Me.txtPreset6.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset6.TabIndex = 8
		Me.txtPreset6.Text = "TextBox7"
		'
		'txtPreset5
		'
		Me.txtPreset5.Location = New System.Drawing.Point(8, 219)
		Me.txtPreset5.Name = "txtPreset5"
		Me.txtPreset5.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset5.TabIndex = 7
		Me.txtPreset5.Text = "TextBox6"
		'
		'txtPreset4
		'
		Me.txtPreset4.Location = New System.Drawing.Point(8, 192)
		Me.txtPreset4.Name = "txtPreset4"
		Me.txtPreset4.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset4.TabIndex = 6
		Me.txtPreset4.Text = "TextBox5"
		'
		'txtPreset3
		'
		Me.txtPreset3.Location = New System.Drawing.Point(8, 165)
		Me.txtPreset3.Name = "txtPreset3"
		Me.txtPreset3.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset3.TabIndex = 5
		Me.txtPreset3.Text = "TextBox4"
		'
		'txtPreset2
		'
		Me.txtPreset2.Location = New System.Drawing.Point(8, 138)
		Me.txtPreset2.Name = "txtPreset2"
		Me.txtPreset2.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset2.TabIndex = 4
		Me.txtPreset2.Text = "TextBox3"
		'
		'txtPreset1
		'
		Me.txtPreset1.Location = New System.Drawing.Point(8, 111)
		Me.txtPreset1.Name = "txtPreset1"
		Me.txtPreset1.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset1.TabIndex = 3
		Me.txtPreset1.Text = "TextBox2"
		'
		'txtPreset0
		'
		Me.txtPreset0.Location = New System.Drawing.Point(8, 84)
		Me.txtPreset0.Name = "txtPreset0"
		Me.txtPreset0.Size = New System.Drawing.Size(88, 20)
		Me.txtPreset0.TabIndex = 2
		Me.txtPreset0.Text = "TextBox1"
		'
		'rdoPreset1
		'
		Me.rdoPreset1.Location = New System.Drawing.Point(24, 47)
		Me.rdoPreset1.Name = "rdoPreset1"
		Me.rdoPreset1.Size = New System.Drawing.Size(60, 23)
		Me.rdoPreset1.TabIndex = 1
		Me.rdoPreset1.Text = "Hex"
		'
		'rdoPreset0
		'
		Me.rdoPreset0.Location = New System.Drawing.Point(24, 21)
		Me.rdoPreset0.Name = "rdoPreset0"
		Me.rdoPreset0.Size = New System.Drawing.Size(60, 23)
		Me.rdoPreset0.TabIndex = 0
		Me.rdoPreset0.Text = "Dec"
		'
		'GroupBox1
		'
		Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtCh7, Me.txtCh6, Me.txtCh5, Me.txtCh4, Me.txtCh3, Me.txtCh2, Me.txtCh1, Me.txtCh0, Me.rdoCh1, Me.rdoCh0})
		Me.GroupBox1.Location = New System.Drawing.Point(80, 88)
		Me.GroupBox1.Name = "GroupBox1"
		Me.GroupBox1.Size = New System.Drawing.Size(123, 304)
		Me.GroupBox1.TabIndex = 3
		Me.GroupBox1.TabStop = False
		Me.GroupBox1.Text = "Count Value"
		'
		'txtCh7
		'
		Me.txtCh7.Location = New System.Drawing.Point(8, 273)
		Me.txtCh7.Name = "txtCh7"
		Me.txtCh7.Size = New System.Drawing.Size(107, 20)
		Me.txtCh7.TabIndex = 9
		Me.txtCh7.Text = "TextBox8"
		'
		'txtCh6
		'
		Me.txtCh6.Location = New System.Drawing.Point(8, 246)
		Me.txtCh6.Name = "txtCh6"
		Me.txtCh6.Size = New System.Drawing.Size(107, 20)
		Me.txtCh6.TabIndex = 8
		Me.txtCh6.Text = "TextBox7"
		'
		'txtCh5
		'
		Me.txtCh5.Location = New System.Drawing.Point(8, 219)
		Me.txtCh5.Name = "txtCh5"
		Me.txtCh5.Size = New System.Drawing.Size(107, 20)
		Me.txtCh5.TabIndex = 7
		Me.txtCh5.Text = "TextBox6"
		'
		'txtCh4
		'
		Me.txtCh4.Location = New System.Drawing.Point(8, 192)
		Me.txtCh4.Name = "txtCh4"
		Me.txtCh4.Size = New System.Drawing.Size(107, 20)
		Me.txtCh4.TabIndex = 6
		Me.txtCh4.Text = "TextBox5"
		'
		'txtCh3
		'
		Me.txtCh3.Location = New System.Drawing.Point(8, 165)
		Me.txtCh3.Name = "txtCh3"
		Me.txtCh3.Size = New System.Drawing.Size(107, 20)
		Me.txtCh3.TabIndex = 5
		Me.txtCh3.Text = "TextBox4"
		'
		'txtCh2
		'
		Me.txtCh2.Location = New System.Drawing.Point(8, 138)
		Me.txtCh2.Name = "txtCh2"
		Me.txtCh2.Size = New System.Drawing.Size(107, 20)
		Me.txtCh2.TabIndex = 4
		Me.txtCh2.Text = "TextBox3"
		'
		'txtCh1
		'
		Me.txtCh1.Location = New System.Drawing.Point(8, 111)
		Me.txtCh1.Name = "txtCh1"
		Me.txtCh1.Size = New System.Drawing.Size(107, 20)
		Me.txtCh1.TabIndex = 3
		Me.txtCh1.Text = "TextBox2"
		'
		'txtCh0
		'
		Me.txtCh0.Location = New System.Drawing.Point(8, 84)
		Me.txtCh0.Name = "txtCh0"
		Me.txtCh0.Size = New System.Drawing.Size(107, 20)
		Me.txtCh0.TabIndex = 2
		Me.txtCh0.Text = "TextBox1"
		'
		'rdoCh1
		'
		Me.rdoCh1.Location = New System.Drawing.Point(24, 47)
		Me.rdoCh1.Name = "rdoCh1"
		Me.rdoCh1.Size = New System.Drawing.Size(60, 23)
		Me.rdoCh1.TabIndex = 1
		Me.rdoCh1.Text = "Hex"
		'
		'rdoCh0
		'
		Me.rdoCh0.Location = New System.Drawing.Point(24, 21)
		Me.rdoCh0.Name = "rdoCh0"
		Me.rdoCh0.Size = New System.Drawing.Size(60, 23)
		Me.rdoCh0.TabIndex = 0
		Me.rdoCh0.Text = "Dec"
		'
		'txtErr
		'
		Me.txtErr.Location = New System.Drawing.Point(290, 56)
		Me.txtErr.Name = "txtErr"
		Me.txtErr.Size = New System.Drawing.Size(32, 20)
		Me.txtErr.TabIndex = 2
		Me.txtErr.Text = ""
		'
		'txtStart
		'
		Me.txtStart.Location = New System.Drawing.Point(156, 56)
		Me.txtStart.Name = "txtStart"
		Me.txtStart.Size = New System.Drawing.Size(32, 20)
		Me.txtStart.TabIndex = 1
		Me.txtStart.Text = ""
		'
		'Label3
		'
		Me.Label3.Location = New System.Drawing.Point(212, 57)
		Me.Label3.Name = "Label3"
		Me.Label3.Size = New System.Drawing.Size(96, 19)
		Me.Label3.TabIndex = 61
		Me.Label3.Text = "Error Register :"
		'
		'Label1
		'
		Me.Label1.Location = New System.Drawing.Point(10, 15)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(78, 19)
		Me.Label1.TabIndex = 59
		Me.Label1.Text = "Device Name :"
		'
		'Label2
		'
		Me.Label2.Location = New System.Drawing.Point(78, 57)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(94, 19)
		Me.Label2.TabIndex = 60
		Me.Label2.Text = "Start Register :"
		'
		'cboDeviceName
		'
		Me.cboDeviceName.Location = New System.Drawing.Point(101, 14)
		Me.cboDeviceName.Name = "cboDeviceName"
		Me.cboDeviceName.Size = New System.Drawing.Size(192, 21)
		Me.cboDeviceName.TabIndex = 15
		'
		'btnCntStart
		'
		Me.btnCntStart.Location = New System.Drawing.Point(437, 200)
		Me.btnCntStart.Name = "btnCntStart"
		Me.btnCntStart.Size = New System.Drawing.Size(104, 25)
		Me.btnCntStart.TabIndex = 8
		Me.btnCntStart.Text = "CntStartCount"
		'
		'btnExit
		'
		Me.btnExit.Location = New System.Drawing.Point(437, 408)
		Me.btnExit.Name = "btnExit"
		Me.btnExit.Size = New System.Drawing.Size(104, 25)
		Me.btnExit.TabIndex = 12
		Me.btnExit.Text = "Exit"
		'
		'txtReturnCode
		'
		Me.txtReturnCode.Location = New System.Drawing.Point(88, 410)
		Me.txtReturnCode.Name = "txtReturnCode"
		Me.txtReturnCode.Size = New System.Drawing.Size(333, 20)
		Me.txtReturnCode.TabIndex = 14
		Me.txtReturnCode.Text = "TextBox26"
		'
		'Label10
		'
		Me.Label10.Location = New System.Drawing.Point(10, 338)
		Me.Label10.Name = "Label10"
		Me.Label10.Size = New System.Drawing.Size(62, 19)
		Me.Label10.TabIndex = 73
		Me.Label10.Text = "Channel 6"
		'
		'btnCntMode
		'
		Me.btnCntMode.Location = New System.Drawing.Point(437, 96)
		Me.btnCntMode.Name = "btnCntMode"
		Me.btnCntMode.Size = New System.Drawing.Size(104, 25)
		Me.btnCntMode.TabIndex = 6
		Me.btnCntMode.Text = "Set Mode..."
		'
		'Label9
		'
		Me.Label9.Location = New System.Drawing.Point(10, 310)
		Me.Label9.Name = "Label9"
		Me.Label9.Size = New System.Drawing.Size(62, 19)
		Me.Label9.TabIndex = 72
		Me.Label9.Text = "Channel 5"
		'
		'Label8
		'
		Me.Label8.Location = New System.Drawing.Point(10, 284)
		Me.Label8.Name = "Label8"
		Me.Label8.Size = New System.Drawing.Size(62, 19)
		Me.Label8.TabIndex = 71
		Me.Label8.Text = "Channel 4"
		'
		'Label6
		'
		Me.Label6.Location = New System.Drawing.Point(10, 229)
		Me.Label6.Name = "Label6"
		Me.Label6.Size = New System.Drawing.Size(62, 19)
		Me.Label6.TabIndex = 69
		Me.Label6.Text = "Channel 2"
		'
		'Label5
		'
		Me.Label5.Location = New System.Drawing.Point(10, 201)
		Me.Label5.Name = "Label5"
		Me.Label5.Size = New System.Drawing.Size(62, 19)
		Me.Label5.TabIndex = 68
		Me.Label5.Text = "Channel 1"
		'
		'Label4
		'
		Me.Label4.Location = New System.Drawing.Point(10, 176)
		Me.Label4.Name = "Label4"
		Me.Label4.Size = New System.Drawing.Size(62, 19)
		Me.Label4.TabIndex = 65
		Me.Label4.Text = "Channel 0"
		'
		'GroupBox2
		'
		Me.GroupBox2.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtStatus7, Me.txtStatus6, Me.txtStatus5, Me.txtStatus4, Me.txtStatus3, Me.txtStatus2, Me.txtStatus1, Me.txtStatus0})
		Me.GroupBox2.Location = New System.Drawing.Point(213, 88)
		Me.GroupBox2.Name = "GroupBox2"
		Me.GroupBox2.Size = New System.Drawing.Size(91, 304)
		Me.GroupBox2.TabIndex = 4
		Me.GroupBox2.TabStop = False
		Me.GroupBox2.Text = "Status"
		'
		'txtStatus7
		'
		Me.txtStatus7.Location = New System.Drawing.Point(8, 273)
		Me.txtStatus7.Name = "txtStatus7"
		Me.txtStatus7.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus7.TabIndex = 9
		Me.txtStatus7.Text = "TextBox8"
		'
		'txtStatus6
		'
		Me.txtStatus6.Location = New System.Drawing.Point(8, 246)
		Me.txtStatus6.Name = "txtStatus6"
		Me.txtStatus6.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus6.TabIndex = 8
		Me.txtStatus6.Text = "TextBox7"
		'
		'txtStatus5
		'
		Me.txtStatus5.Location = New System.Drawing.Point(8, 219)
		Me.txtStatus5.Name = "txtStatus5"
		Me.txtStatus5.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus5.TabIndex = 7
		Me.txtStatus5.Text = "TextBox6"
		'
		'txtStatus4
		'
		Me.txtStatus4.Location = New System.Drawing.Point(8, 192)
		Me.txtStatus4.Name = "txtStatus4"
		Me.txtStatus4.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus4.TabIndex = 6
		Me.txtStatus4.Text = "TextBox5"
		'
		'txtStatus3
		'
		Me.txtStatus3.Location = New System.Drawing.Point(8, 165)
		Me.txtStatus3.Name = "txtStatus3"
		Me.txtStatus3.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus3.TabIndex = 5
		Me.txtStatus3.Text = "TextBox4"
		'
		'txtStatus2
		'
		Me.txtStatus2.Location = New System.Drawing.Point(8, 138)
		Me.txtStatus2.Name = "txtStatus2"
		Me.txtStatus2.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus2.TabIndex = 4
		Me.txtStatus2.Text = "TextBox3"
		'
		'txtStatus1
		'
		Me.txtStatus1.Location = New System.Drawing.Point(8, 111)
		Me.txtStatus1.Name = "txtStatus1"
		Me.txtStatus1.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus1.TabIndex = 3
		Me.txtStatus1.Text = "TextBox2"
		'
		'txtStatus0
		'
		Me.txtStatus0.Location = New System.Drawing.Point(8, 84)
		Me.txtStatus0.Name = "txtStatus0"
		Me.txtStatus0.Size = New System.Drawing.Size(72, 20)
		Me.txtStatus0.TabIndex = 2
		Me.txtStatus0.Text = "TextBox1"
		'
		'CntTimer
		'
		'
		'Counter
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(554, 447)
		Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnCntExit, Me.btnCntStop, Me.btnCntPreset, Me.btnCntCompare, Me.btnCntInit, Me.Label13, Me.Label11, Me.Label7, Me.GroupBox3, Me.GroupBox1, Me.txtErr, Me.txtStart, Me.Label3, Me.Label1, Me.Label2, Me.cboDeviceName, Me.btnCntStart, Me.btnExit, Me.txtReturnCode, Me.Label10, Me.btnCntMode, Me.Label9, Me.Label8, Me.Label6, Me.Label5, Me.Label4, Me.GroupBox2})
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
		Me.MaximizeBox = False
		Me.MinimizeBox = False
		Me.Name = "Counter"
		Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
		Me.Text = "Counter Sample"
		Me.GroupBox3.ResumeLayout(False)
		Me.GroupBox1.ResumeLayout(False)
		Me.GroupBox2.ResumeLayout(False)
		Me.ResumeLayout(False)

	End Sub

#End Region
    Dim Ret As Int32                                    ' Return value
	Dim szError As New System.Text.StringBuilder(256)	' Error string
	Dim m_Ch(7) As TextBox								' Controls of count value
	Dim m_Status(7) As TextBox							' Controls of status value
	Dim m_Preset(7) As TextBox							' Controls of preset value
	Dim CompCount(7) As Integer							' The times of count-match
	Dim szText As New String("", 100)

	'---------------------------------------------------------
	'	Initialize dialog
	'---------------------------------------------------------
	Private Sub Counter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		Dim i As Short
		Dim PresetData As Integer
		'-----------------------------------
		' Detect device
		'-----------------------------------
		Dim Index As Short
		Dim GroupID, UnitID, DeviceID As Short
		Dim DeviceName As New System.Text.StringBuilder(256)
		Dim Device As New System.Text.StringBuilder(256)
		Index = 0
		Do
			Ret = CntQueryDeviceName(Index, GroupID, UnitID, DeviceID, DeviceName, Device)
			If Ret <> CNT_ERR_SUCCESS Then
				Exit Do
			End If
			cboDeviceName.Items.Add(DeviceName.ToString())
			Index += 1
		Loop
		cboDeviceName.SelectedIndex = 0
		'-----------------------------------
		' Initialize screen items
		'-----------------------------------
		txtReturnCode.Text = ""
		rdoCh0.Checked = True
		rdoPreset0.Checked = True
		' Count value
		m_Ch(0) = txtCh0
		m_Ch(1) = txtCh1
		m_Ch(2) = txtCh2
		m_Ch(3) = txtCh3
		m_Ch(4) = txtCh4
		m_Ch(5) = txtCh5
		m_Ch(6) = txtCh6
		m_Ch(7) = txtCh7
		For i = 0 To 7
			m_Ch(i).Text = ""
		Next i
		' Status
		m_Status(0) = txtStatus0
		m_Status(1) = txtStatus1
		m_Status(2) = txtStatus2
		m_Status(3) = txtStatus3
		m_Status(4) = txtStatus4
		m_Status(5) = txtStatus5
		m_Status(6) = txtStatus6
		m_Status(7) = txtStatus7
		For i = 0 To 7
			m_Status(i).Text = ""
		Next i
		' Preset value
		m_Preset(0) = txtPreset0
		m_Preset(1) = txtPreset1
		m_Preset(2) = txtPreset2
		m_Preset(3) = txtPreset3
		m_Preset(4) = txtPreset4
		m_Preset(5) = txtPreset5
		m_Preset(6) = txtPreset6
		m_Preset(7) = txtPreset7
		For i = 0 To 7
			PresetData = i * 100
			m_Preset(i).Text = Str(PresetData)
		Next i
	End Sub

	'---------------------------------------------------------
	'	Initialization
	'---------------------------------------------------------
	Private Sub btnCntInit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntInit.Click

		Dim szDeviceName As New String("", 100)
		Dim i As Short
		'-----------------------------
		' Get device name from screen
		'-----------------------------
		szDeviceName = cboDeviceName.Text
		'-----------------------------
		' Initialize and get ID
		'-----------------------------
		Ret = CntInit(szDeviceName, Id)
		'-----------------------------
		' Process error
		'-----------------------------
		CntGetErrorString(Ret, szError)
		txtReturnCode.Text = "CntInt : " & szError.ToString()
		If Ret <> CNT_ERR_SUCCESS Then
			Exit Sub
		End If
		'-----------------------------
		' Get total number of channels
		'-----------------------------
		CntGetMaxChannels(Id, ChannelNum)
		'-----------------------------
		' Disable the display of counter, status and preset
		'-----------------------------
		For i = 0 To 7
			If i < ChannelNum Then
				m_Ch(i).Enabled = True
				m_Status(i).Enabled = True
				m_Preset(i).Enabled = True
			Else
				m_Ch(i).Enabled = False
				m_Status(i).Enabled = False
				m_Preset(i).Enabled = False
			End If
		Next i
		'-----------------------------
		' Start timer
		'-----------------------------
		CntTimer.Enabled = True

	End Sub

	'---------------------------------------------------------
	'	Display mode dialog
	'---------------------------------------------------------
	Private Sub btnCntMode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntMode.Click

		'-----------------------------
		' Display dialog in modal
		'-----------------------------
		Dim ModeDlg As New Mode()
		ModeDlg.ShowDialog()
		ModeDlg.Dispose()

	End Sub

	'---------------------------------------------------------
	'	Display comparison dialog
	'---------------------------------------------------------
	Private Sub btnCntCompare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntCompare.Click

		'-----------------------------
		' Display dialog in modal
		'-----------------------------
		Dim CompDlg As New Comp()
		CompDlg.ShowDialog()
		CompDlg.Dispose()

	End Sub

	'---------------------------------------------------------
	'	Counter start
	'---------------------------------------------------------
	Private Sub btnCntStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntStart.Click

		Dim ChNo(7) As Short
		Dim i As Short
		'-----------------------------
		' Set parameter
		'-----------------------------
		For i = 0 To (ChannelNum - 1)
			ChNo(i) = i
		Next i
		'-----------------------------
		' Counter start
		'-----------------------------
        Ret = CntStartCount(Id, ChNo, ChannelNum)
		'-----------------------------
		' Process error
		'-----------------------------
		CntGetErrorString(Ret, szError)
		txtReturnCode.Text = "CntStartCount : " & szError.ToString()
		If Ret <> CNT_ERR_SUCCESS Then
			Exit Sub
		End If

	End Sub

	'---------------------------------------------------------
	'	Preset
	'---------------------------------------------------------
	Private Sub btnCntPreset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntPreset.Click

		Dim ChNo(7) As Short
        Dim PresetData(7) As Int32
		Dim i As Short
		'-----------------------------
		' Get data from screen and set parameter
		'-----------------------------
		For i = 0 To (ChannelNum - 1)
			ChNo(i) = i
            szText = m_Preset(i).Text
            Try
                If rdoPreset0.Checked = True Then
                    PresetData(i) = Integer.Parse(szText)
                Else
                    PresetData(i) = Integer.Parse(szText, System.Globalization.NumberStyles.HexNumber)
                End If
            Catch ex As Exception
                PresetData(i) = 0
            End Try
        Next i
		'-----------------------------
		' Preset
		'-----------------------------
        Ret = CntPreset(Id, ChNo, ChannelNum, PresetData)
		'-----------------------------
		' Process error
		'-----------------------------
		CntGetErrorString(Ret, szError)
		txtReturnCode.Text = "CntPreset : " & szError.ToString()

	End Sub

	'---------------------------------------------------------
	'	Counter stop
	'---------------------------------------------------------
	Private Sub btnCntStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntStop.Click

		Dim ChNo(7) As Short
		Dim i As Short
		'-----------------------------
		' Set parameter
		'-----------------------------
		For i = 0 To (ChannelNum - 1)
			ChNo(i) = i
		Next i
		'-----------------------------
		' Counter stop
		'-----------------------------
        Ret = CntStopCount(Id, ChNo, ChannelNum)
		'-----------------------------
		' Process error
		'-----------------------------
		CntGetErrorString(Ret, szError)
		txtReturnCode.Text = "CntStopCount : " & szError.ToString()

	End Sub

	'---------------------------------------------------------
	'	Termination
	'---------------------------------------------------------
	Private Sub btnCntExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCntExit.Click

		'-----------------------------
		' Stop timer
		'-----------------------------
		CntTimer.Enabled = False
		'-----------------------------
		' Termination
		'-----------------------------
		Ret = CntExit(Id)
		'-----------------------------
		' Process error
		'-----------------------------
		CntGetErrorString(Ret, szError)
		txtReturnCode.Text = "CntExit :" & szError.ToString()

	End Sub

	'---------------------------------------------------------
	'	Exit dialog
	'---------------------------------------------------------
	Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

		'-----------------------------
		' Stop timer
		'-----------------------------
		CntTimer.Enabled = False
		'-----------------------------
		' Termination
		'-----------------------------
		Ret = CntExit(Id)
		'-----------------------------
		' Exit dialog
		'-----------------------------
		End

	End Sub

	Private Sub Counter_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed

		' Termination
		Ret = CntExit(Id)

	End Sub

	'---------------------------------------------------------
	'	Process timer
	'---------------------------------------------------------
	Private Sub CntTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CntTimer.Tick

		Dim ChNo(7) As Short
        Dim CountData(7) As Int32
		Dim Sts(7) As Short
		Dim i As Short
		Dim bIs10 As Boolean
		Dim Start, Err As Byte
		'-----------------------------
		' Get start register value
		'-----------------------------
		Ret = CntGetRemoteStatus(Id, Start, Err)
		'-----------------------------
		' Process error
		'-----------------------------
		If Ret <> CNT_ERR_SUCCESS Then
			CntGetErrorString(Ret, szError)
			txtReturnCode.Text = "CntGetRemoteStatus : " & szError.ToString()
			Exit Sub
		End If
		'-----------------------------
		' Set parameter
		'-----------------------------
		For i = 0 To (ChannelNum - 1)
			ChNo(i) = i
			CountData(i) = 0
		Next i
		'-----------------------------
		' Get count value
		'-----------------------------
        Ret = CntReadCount(Id, ChNo, ChannelNum, CountData)
		'-----------------------------
		' Process error
		'-----------------------------
		If Ret <> CNT_ERR_SUCCESS Then
			CntGetErrorString(Ret, szError)
			txtReturnCode.Text = "CntReadCount : " & szError.ToString()
			Exit Sub
		End If
		'-----------------------------
		' Get status
		'-----------------------------
		For i = 0 To (ChannelNum - 1)
			Ret = CntReadStatus(Id, i, Sts(i))
			'-----------------------------
			' Process error
			'-----------------------------
			If Ret <> CNT_ERR_SUCCESS Then
				CntGetErrorString(Ret, szError)
				txtReturnCode.Text = "CntReadStatus : " & szError.ToString()
				Exit Sub
			End If
		Next i
		'-----------------------------
		' Display count data and status data
		'-----------------------------
		txtStart.Text = String.Format("{0:X2}", Start)
		txtErr.Text = String.Format("{0:X2}", Err)
		bIs10 = rdoCh0.Checked
		For i = 0 To (ChannelNum - 1)
			If bIs10 = True Then
				szText = Str(CountData(i))
			Else
				szText = String.Format("{0:X8}", CountData(i))
			End If
			m_Ch(i).Text = szText
			szText = String.Format("{0:X2}", Sts(i))
			m_Status(i).Text = szText
		Next i

	End Sub

	'---------------------------------------------------------
	'	Shift Dec/Hex
	'---------------------------------------------------------
	'	Channel data : Dec
	Private Sub rdoCh0_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles rdoCh0.MouseDown

		CntTimer_Tick(CntTimer, New System.EventArgs())

	End Sub

	'	Channel data : Hex
	Private Sub rdoCh1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles rdoCh1.MouseDown

		CntTimer_Tick(CntTimer, New System.EventArgs())

	End Sub

	'	Preset data : Dec
	Private Sub rdoPreset0_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles rdoPreset0.MouseDown

		'-----------------------------
		' Get data from screen and change the display
		'-----------------------------
		Dim i As Short
		Dim PresetData As Integer
		For i = 0 To 7
            szText = m_Preset(i).Text
            Try
                PresetData = CLng("&H" & szText)
            Catch ex As Exception
                PresetData = 0
            End Try
            szText = String.Format("{0:d}", PresetData)
            m_Preset(i).Text = szText
        Next i

	End Sub

	'	Preset data : Hex
	Private Sub rdoPreset1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles rdoPreset1.MouseDown

		'-----------------------------
		' Get data from screen and change the display
		'-----------------------------
		Dim i As Short
		Dim PresetData As Integer
		For i = 0 To 7
			szText = m_Preset(i).Text
            Try
                PresetData = CLng(szText)
            Catch ex As Exception
                PresetData = 0
            End Try
            szText = String.Format("{0:X8}", PresetData)
            m_Preset(i).Text = szText
        Next i

	End Sub
End Class