2018年4月26日木曜日

Accessアクセス from VB ~Class化してみるよ~(6:呼び出し側)

めんどちいので色付けしない( ゚-゚)~゚
なんか、見やすくするよーなやり方を探してるけど…無い!(ぇ
※追記:ありました(*゚-゚)
google/code-prettifyつかってみてます。

    '2元配列のガラだけ用意しSetDBtoTable.Valueでコピって使う
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim DataTable As SetDBtoTable
        Dim Datas(,) As String
        Dim i, j As Long
        Dim str_Print As String
        DataTable = New SetDBtoTable
        DataTable.DataSource = "\\LANDISK1\share\Test.mdb"
        DataTable.ConnectionString = "T_Master"
        DataTable.Open()
        Datas = DataTable.Value
        For i = 0 To DataTable.RecordCount - 1
            str_Print = ""
            For j = 0 To DataTable.ColumnCount - 1
                str_Print = str_Print + Datas(i, j) & " : "
            Next j
            Debug.Print(str_Print)
        Next i
        DataTable.close()
    End Sub
    'Datas Methodでデータを読み出す
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim DataTable As SetDBtoTable
        Dim i, j As Long
        Dim str_Print As String
        DataTable = New SetDBtoTable
        DataTable.DataSource = "\\LANDISK1\share\Test.mdb"
        DataTable.ConnectionString = "T_Master"
        DataTable.Open()
        For i = 0 To DataTable.RecordCount - 1
            str_Print = ""
            For j = 0 To DataTable.ColumnCount - 1
                str_Print = str_Print + DataTable.Datas(i, j) & " : "
            Next j
            Debug.Print(str_Print)
        Next i
        DataTable.close()
    End Sub
    '指定した行(この場合は2行目)のRecordを1元配列にもってくる。
    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim DataTable As SetDBtoTable
        Dim j As Long
        Dim str_Print As String
        Dim Rec_data() As String
        DataTable = New SetDBtoTable
        DataTable.DataSource = "\\LANDISK1\share\Test.mdb"
        DataTable.ConnectionString = "T_Master"
        DataTable.Open()
        Rec_data = DataTable.Datas(1)
        str_Print = ""
        For j = 0 To DataTable.ColumnCount - 1
            str_Print = str_Print + Rec_data(j) & " : "
        Next j
        Debug.Print(str_Print)
        DataTable.close()
    End Sub
    '指定した列(この場合は2列目)のFieldを1元配列にもってくる。
    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim DataTable As SetDBtoTable
        Dim i As Long
        Dim str_Print As String
        Dim Rec_data() As String
        DataTable = New SetDBtoTable
        DataTable.DataSource = "\\LANDISK1\share\Test.mdb"
        DataTable.ConnectionString = "T_Master"
        DataTable.Open()
        Rec_data = DataTable.Column(1)
        str_Print = ""
        For i = 0 To DataTable.RecordCount - 1
            str_Print = str_Print + Rec_data(i) & " : "
        Next i
        Debug.Print(str_Print)
        DataTable.close()
    End Sub
End Class

<<前  次>>

0 件のコメント:

コメントを投稿