Input# Statement

μ—΄λ¦° 순차 νŒŒμΌμ—μ„œ 데이터λ₯Ό μ½μŠ΅λ‹ˆλ‹€.

Syntax:

Input Statement diagram


Input #fileNum {,|;} var1 [, var2 [, ...]]

Parameters:

fileNum: Number of the file that contains the data that you want to read. The file must be opened with the Open statement using the key word INPUT.

var: A numeric or string variable that you assign the values read from the opened file to.

Input# 문은 μ—΄λ¦° νŒŒμΌμ—μ„œ 숫자 κ°’ λ˜λŠ” λ¬Έμžμ—΄μ„ 읽은 λ‹€μŒ 데이터λ₯Ό ν•˜λ‚˜ μ΄μƒμ˜ λ³€μˆ˜μ— ν• λ‹Ήν•©λ‹ˆλ‹€. 숫자 λ³€μˆ˜λŠ” 첫 번째 캐리지 리턴(Asc=13), 쀄 λ°”κΏˆ(Asc=10), 곡백 λ˜λŠ” μ‰Όν‘œκΉŒμ§€ μ½μŠ΅λ‹ˆλ‹€. λ¬Έμžμ—΄ λ³€μˆ˜λŠ” 첫 번째 캐리지 리턴(Asc=13), 쀄 λ°”κΏˆ(Asc=10) λ˜λŠ” μ‰Όν‘œκΉŒμ§€ μ½μŠ΅λ‹ˆλ‹€.

μ—΄λ¦° 파일의 데이터 및 데이터 ν˜•μ‹μ€ "var" 맀개 λ³€μˆ˜μ—μ„œ μ „λ‹¬λ˜λŠ” λ³€μˆ˜μ™€ λ™μΌν•œ μˆœμ„œλ‘œ λ‚˜νƒ€λ‚˜μ•Ό ν•©λ‹ˆλ‹€. μˆ«μžκ°€ μ•„λ‹Œ 값을 숫자 λ³€μˆ˜μ— ν• λ‹Ήν•  경우 "var"에 κ°’ "0"이 ν• λ‹Ήλ©λ‹ˆλ‹€.

μ‰Όν‘œλ‘œ κ΅¬λΆ„λœ λ ˆμ½”λ“œλŠ” λ¬Έμžμ—΄ λ³€μˆ˜μ— ν• λ‹Ήν•  수 μ—†μŠ΅λ‹ˆλ‹€. λ˜ν•œ 파일의 λ”°μ˜΄ν‘œ(")도 λ¬΄μ‹œλ©λ‹ˆλ‹€. μ΄λŸ¬ν•œ 문자λ₯Ό νŒŒμΌμ—μ„œ 읽으렀면 Line Input# 문을 μ‚¬μš©ν•˜μ—¬ 인쇄 κ°€λŠ₯ 문자만 ν¬ν•¨λœ 순수 ν…μŠ€νŠΈ νŒŒμΌμ„ 쀄 λ‹¨μœ„λ‘œ μ½μŠ΅λ‹ˆλ‹€.

데이터 μš”μ†Œλ₯Ό μ½λŠ” λ™μ•ˆ 파일 끝에 도달할 경우 였λ₯˜κ°€ λ°œμƒν•˜κ³  ν”„λ‘œμ„ΈμŠ€κ°€ μ€‘λ‹¨λ©λ‹ˆλ‹€.

Example:


Sub ExampleWorkWithAFile
    Dim iCount As Integer, sFileName As String
    Dim sName As String, sValue As Integer
    sFileName = "C:\Users\ThisUser\data.txt"
    iCount = Freefile
    ' Write data ( which we will read later with Input ) to file
    Open sFileName For Output As iCount
    sName = "Hamburg" : sValue = 200
    Write #iCount, sName, sValue
    sName = "New York" : sValue = 300
    Write #iCount; sName, sValue
    sName = "Miami" : sValue = 459
    Write #iCount, sName, sValue
    Close #iCount
    ' Read data file using Input
    iCount = Freefile
    Open sFileName For Input As iCount
    Input #iCount, sName, sValue
    MsgBox sName & " " & sValue
    Input #iCount; sName, sValue
    MsgBox sName & " " & sValue
    Input #iCount, sName, sValue
    MsgBox sName & " " & sValue
    Close #iCount
End Sub

Please support us!