トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

Excel VBA 固定長の構造体をファイルから読む



目次



記事一覧

キーワード

Excel VBA 固定長の構造体をファイルから読む

[Excel VBA]

Type RecClass
    field01     as String * 10
    field02     as String * 5
    field03     as String * 2
End Type

Public Sub readReadData()
    Dim fno     As Integer
    Dim fname   As String
    Dim rec     As RecClass
    Dim recCnt  As Long
    Dim recLen  As Long
    Dim pos     As Long
    Dim i       As Integer

    fno = FreeFile
    Open fname For Binary As fno

    recLen = Len(rec)
    recCnt = FileLen(fname) / recLen

    pos = 1
    For i = 1 To recCnt
        Get #fno, pos, rec
        pos = pos + recLen
        
        Call SomeProcess(rec)
    Next
    
    Close #fno
End Sub



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.