level 1
Public Class Form1
PublicConst UNIT_QNUSB AsShort = &H16S
PublicConst PROTOCOL_USB AsShort = &HDS
#Region "Additional initialization (including Form_Load processing) "
'*Thedeclaration of instance value for ACT controls*******************/
' When you use ACT controls by 'References',you should program as follows;
Privatecom_ReferencesUtlType AsActUtlTypeLib.ActUtlTypeClass
Privatecom_ReferencesProgType AsActProgTypeLib.ActProgTypeClass
PrivateSub frm_Sample_References_Load(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
'*Create instance for ACT Controls*************************************/
com_ReferencesUtlType = New ActUtlTypeLib.ActUtlTypeClass
com_ReferencesProgType = New ActProgTypeLib.ActProgTypeClass
'*Set EventHandler for ACT Controls
AddHandlercom_ReferencesUtlType.OnDeviceStatus, AddressOfcom_ReferencesUtlType_OnDeviceStatus
AddHandlercom_ReferencesProgType.OnDeviceStatus, AddressOfcom_ReferencesProgType_OnDeviceStatus
EndSub
#End Region
#Region "Processing of Open button "
PrivateSub btn_Open_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) Handles btn_Open.Click
DimiReturnCode As Integer 'Returncode
DimiLogicalStationNumber As Integer 'LogicalStationNumber for ActUtlType
'Displayedoutput data is cleared.
ClearDisplay()
'
'Processingof Open method
'
Try
Ifrad_ActProgType.Checked = True Then
'When ActProgType is selected by the radio button,
'set the value of 'UnitType' to the property.
com_ReferencesProgType.ActUnitType = UNIT_QNUSB
'Set the valueof 'ProtocolType' to the property.
com_ReferencesProgType.ActProtocolType = PROTOCOL_USB
'The Open method is executed.
iReturnCode =com_ReferencesProgType.Open()
Else
'WhenActUtlType is selected by the radio button,
'check the 'LogicalStationNumber'.(If succeeded, the valueis gotten.)
If GetIntValue(txt_LogicalStationNumber,iLogicalStationNumber) = False Then
'If failed, thisprocess is end.
Exit Sub
End If
'Set the value of 'LogicalStationNumber' to the property.
com_ReferencesUtlType.ActLogicalStationNumber = iLogicalStationNumber
'The Openmethod is executed.
iReturnCode =com_ReferencesUtlType.Open()
If iReturnCode = 0 Then
'When the Open method is succeeded, disable the TextBox of'LogocalStationNumber'.
txt_LogicalStationNumber.Enabled = False
End If
EndIf
'Exceptionprocessing
Catchexception As Exception
MessageBox.Show(exception.Message, Name, MessageBoxButtons.OK,MessageBoxIcon.Error)
ExitSub
EndTry
'Thereturn code of the method is displayed by the hexadecimal.
txt_ReturnCode.Text = String.Format("0x{0:x8}[HEX]", iReturnCode)
EndSub
#End Region
#Region "Processing of Close button "
PrivateSub btn_Close_Click(ByValsender As System.Object, ByVal e AsSystem.EventArgs) Handles btn_Close.Click
DimiReturnCode As Integer 'Return code
'Displayedoutput data is cleared.
ClearDisplay()
'
'Processingof Close method
'
Try
Ifrad_ActProgType.Checked = True Then
'When ActProgType is selected by the radio button,
'the Close method is executed.
iReturnCode =com_ReferencesProgType.Close()
Else
'When ActUtlType is selected by the radio button,
'the Close method is executed.
iReturnCode =com_ReferencesUtlType.Close()
'When The Close method is succeeded, enable the TextBox of'LogocalStationNumber'.
If iReturnCode = 0 Then
txt_LogicalStationNumber.Enabled = True
End If
EndIf
Catchexception As Exception
'Exceptionprocessing
MessageBox.Show(exception.Message, Name, MessageBoxButtons.OK,MessageBoxIcon.Error)
ExitSub
EndTry
'Thereturn code of the method is displayed by the hexadecimal.
txt_ReturnCode.Text = String.Format("0x{0:x8}[HEX]", iReturnCode)
End Sub
2015年05月25日 12点05分