IT・Office

VBAメモ

更新日:

Dim inst As Class1

Sub mainProc()

Dim pathName As String
Dim inputFileName As String
Dim fullPathName As String
Dim i As Integer
Dim work As Variant
Dim buf As String
Set inst = New Class1

pathName = " "
inputFileName = "input.txt"
fullPathName = pathName & inputFileName

If Dir(fullPathName) <> "" Then
Else
MsgBox inputFileName & "が存在しません"
' 終了処理
Exit Sub
End If

Open fullPathName For Input As #1

' ファイルが空の場合は終了処理
If (FileLen(fullPathName) = 0) Then

MsgBox "ファイルが空です"
GoTo continue

End If

' 見出しをスキップ(空読み)
Line Input #1, buf

' ファイルを最後まで読み込む
Do Until EOF(1)

Line Input #1, buf
work = Split(buf, vbTab)

' 各項目に割り付ける
ShareText work, inst

' Trim処理
inst.test01 = MyTrim(inst.test01)

' output
Call fileOutput

Loop

continue:

Close #1

MsgBox "end"

End Sub

'Function ShareText(work As Variant, ByRef inst As Class1)
Function ShareText(work As Variant, inst As Class1)

Dim ErrFlg(3) As Boolean
ErrFlg(0) = True
ErrFlg(1) = True
ErrFlg(2) = True
ErrFlg(3) = True

With inst
.test01 = work(0)
.test02 = work(1)
.test03 = work(2)
End With

' ShareText = inst

End Function
Function MyTrim(test01 As String)

test01 = Trim(test01)

MyTrim = test01

End Function

Sub fileOutput()

End Sub

Sub validation()

End Sub

'###################################################
' メモ ダブルクオーテーションなどを削除するときはreplace関数
'###################################################

-IT・Office

Copyright© hobby23 , 2019 All Rights Reserved Powered by AFFINGER5.