2
줄 "Input # 1, Numbers (Row, Column)"은 런타임 버그 9를 제공합니다. 코드의 주석은 일어날 일을 설명합니다. 코드 아래Visual Basic Excel txt 입력 파일
Sub InputImage()
'brings a text file to the workbook
Dim Row As Long, Column As Long, Nrow As Long, Ncolumn As Long
Call MsgBox("Navigate to a folder that contains the file image.txt in the 00_18 folder")
' The next statement will open a dialogue box that will let
' the user navigate to any folder on their system
Call Application.GetOpenFilename
Open "image.txt" For Input As #1
Dim Buffer As String
Line Input #1, Buffer 'read a whole line of characters from
'file #1 into the string variable buffer
Line Input #1, Buffer
Input #1, Buffer, Nrow
Input #1, Buffer, Ncolumn
Dim Numbers(1 To 4, 1 To 4) As Long
For Row = 1 To Nrow
For Column = 1 To Ncolumn
Input #1, Numbers(Row, Column)
Next Column
Next Row
Close #1
End Sub
오류가 발생했을 때 행과 열의 값은 무엇입니까? –
오류 9 아래 첨자가 범위를 벗어남을 의미하며 텍스트 파일의 데이터가 아직 친구가 아닙니다 :-). image.txt 파일에서 읽고 자하는 데이터를 배열 번호에 게시 할 수 있다면 도움이 될 것입니다. – dee
ADO를 사용하여 쿼리를 텍스트 파일로 읽을 수 있음을 알 수 있습니다. [MSDN Scripting Clinic : Text Files에 관한 많은 ADO] (http://msdn.microsoft.com/en-us/library/ms974559)를 참조하십시오. aspx) –