
Public Class Form1
    Dim wRtn As UInt16
    Public wTotalBoards As UInt16
    Dim sGetCardInfo As IXUD_CARD_INFO
    Dim sGetDevInfo As IXUD_DEVICE_INFO
    Friend sCardInfo() As IXUD_CARD_INFO
    Friend sDevInfo() As IXUD_DEVICE_INFO
    Dim wBoardNo As UInt16
    Public sModelName As New String(" "c, 20)

    Dim mpbo() As PictureBox    'Output PictureBox Control's Array
    Dim mpbof(31) As Boolean
    Dim mpbi() As PictureBox    'Input PictureBox Control's Array

    Dim mrbSetDio() As RadioButton

    Dim wSetDioMode As UInt16
    Dim wDirectorDioMode As UInt32


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim index As UInt16
        wRtn = Ixud_DriverInit(wTotalBoards)

        ReDim sCardInfo(wTotalBoards - 1)
        ReDim sDevInfo(wTotalBoards - 1)

        For index = 0 To CUShort(wTotalBoards - 1)
            wRtn = Ixud_GetCardInfo(index, sGetDevInfo, sGetCardInfo, sModelName)
            If sModelName <> "0" Then
                Me.cbxSelectBoard.Items.Add(Str(index) + ": " + sModelName)
            Else
                Me.cbxSelectBoard.Items.Add(Str(index) + ": Err Device")
            End If

            sDevInfo(index) = sGetDevInfo
            sCardInfo(index) = sGetCardInfo
        Next

        cbxSize.SelectedIndex = 0
       

    End Sub

   

    Private Sub cbxSelectBoard_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbxSelectBoard.SelectedIndexChanged

        wBoardNo = CUShort(cbxSelectBoard.SelectedIndex)
       

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        wRtn = UniDAQ.Ixud_DriverClose()
        Me.Close()
    End Sub



    Private Sub btnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrite.Click

        If (cbxSelectBoard.SelectedIndex = -1) Then
            MsgBox("Please Selected a Board!!!")
            Exit Sub
        End If

        wRtn = Ixud_WriteMemory(wBoardNo, CUInt(tbxOffset.Text), CUShort(cbxSize.Text), CUInt("&h" + tbxWrite.Text))
        If (wRtn) Then
            MsgBox("Error " + Str(wRtn))
        End If
        'MsgBox("Offset " + tbxOffset.Text + " Size " + cbxSize.Text)


    End Sub

    Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
        Dim dwValue As UInt32
        If (cbxSelectBoard.SelectedIndex = -1) Then
            MsgBox("Please Selected a Board!!!")
            Exit Sub
        End If

        wRtn = Ixud_ReadMemory(wBoardNo, CUInt(tbxOffset.Text), CUShort(cbxSize.Text), dwValue)
        If (wRtn) Then
            MsgBox("Error " + Str(wRtn))
        End If
        'MsgBox("Offset " + tbxOffset.Text + " Size " + cbxSize.Text)
        tbxRead.Text = "0x" + Hex(dwValue)

    End Sub
End Class
