「Excel VBA 固定長の構造体をファイルから読む」の版間の差分
ナビゲーションに移動
検索に移動
(同じ利用者による、間の1版が非表示) | |||
1行目: | 1行目: | ||
− | ==Excel VBA 固定長の構造体をファイルから読む== | + | ==[[Excel VBA 固定長の構造体をファイルから読む]]== |
− | [[Excel VBA]] | + | [[Excel VBA]] | |
− | Type | + | Type [[R]]ecClass |
field01 as String * 10 | field01 as String * 10 | ||
field02 as String * 5 | field02 as String * 5 | ||
8行目: | 8行目: | ||
End Type | End Type | ||
− | Public Sub | + | Public Sub read[[R]]eadData() |
Dim fno As Integer | Dim fno As Integer | ||
Dim fname As String | Dim fname As String | ||
− | Dim rec As | + | Dim rec As [[R]]ecClass |
Dim recCnt As Long | Dim recCnt As Long | ||
Dim recLen As Long | Dim recLen As Long |
2020年2月16日 (日) 04:25時点における最新版
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
© 2006 矢木浩人