Option Strict Off
Option Explicit On
Module TUSBKDIO
	'-----------------------------------------------
	'API for TUSB-K16DIO Driver
	'Visual Basic 6 Module
	'
	'Oct. 31 2006
	'Copyright (C) 2006 Turtle Industry Co.,Ltd.
	'-----------------------------------------------
	
	'API Function declaration
	
    Declare Function TUSBK16DIO_Dir Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByVal Port As Byte, ByVal Direction As Byte) As Short
	Declare Function TUSBK16DIO_PortWrite Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByVal Port As Byte, ByVal data As Byte) As Short
	Declare Function TUSBK16DIO_Write Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByVal Data1 As Byte, ByVal Data2 As Byte) As Short
	Declare Function TUSBK16DIO_Read Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByRef Data1 As Byte, ByRef Data2 As Byte) As Short
	Declare Function TUSBK16DIO_DirRead Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByRef Dir1 As Byte, ByRef Dir2 As Byte) As Short
	Declare Function TUSBK16DIO_OutputRead Lib "TUSBKDIO.DLL" (ByVal Id As Short, ByRef Data1 As Byte, ByRef Data2 As Byte) As Short
	Declare Function TUSBK16DIO_Chk Lib "TUSBKDIO.DLL" (ByVal Id As Short) As Short
	Declare Sub TUSBK16DIO_Load Lib "TUSBKDIO.DLL" ()
	Declare Sub TUSBK16DIO_Unload Lib "TUSBKDIO.DLL" ()
	
	' Error Message
	Public Function TUSBK02AD_ErrorDisp(ByVal ErrCode As Short) As Object
        Dim tmpStr As String

        Select Case ErrCode
            Case 0
                tmpStr = "正常に終了しました"
            Case 2
                tmpStr = "ドライバが初期化されていません"
            Case 6
                tmpStr = "デバイスが見つかりませんでした"
            Case 8
                tmpStr = "パラメータエラー"
            Case 9
                tmpStr = "USB通信エラー"
            Case Else
                tmpStr = "不明なエラーです"
        End Select

        MsgBox(tmpStr)
	End Function
End Module