4

数千の行といくつかの列がタブで区切られたファイルがあります。それぞれを個別にループし、列を配列にドロップして、別のアプリケーションに個別に配置できるようにしてから、次の行に移動します。 。残念ながら、私はこれまでに到達しました:

Open mytextfile.txt For Input As #FileHandle
 Do While Not EOF(FileHandle)
 Line Input #FileHandle, IndividualLine
 StringToBreakup = IndividualLine
Loop

では、個々の行を配列に分割するにはどうすればよいでしょうか。

4

2 に答える 2

7
Dim str() as String

Open mytextfile.txt For Input As #FileHandle
    Do While Not EOF(FileHandle)
    Line Input #FileHandle, IndividualLine
    str = Split(IndividualLine, vbTab)
    Debug.Print str(0)  'First array element
Loop

明確にするために:バリアントの使用を避け、vbTab を使用します。

于 2008-11-15T00:23:16.907 に答える
0

分割コマンドを使用する

Dim StringArray as Variant

Open mytextfile.txt For Input As #FileHandle
 Do While Not EOF(FileHandle)
 Line Input #FileHandle, IndividualLine
 StringToBreakup = IndividualLine

 StringArray = Split(StringToBreakup, CHR(9)) 

 Process array here...

Loop
于 2008-11-15T00:11:36.103 に答える