Input# Statement

Loeb andmeid avatud jadafailist.

SĂŒntaks:

Input Statement diagram


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

Parameetrid:

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.

Lause Input# loeb avatud failist arv- ja stringvÀÀrtusi ning mÀÀrab andmed ĂŒhele vĂ”i mitmele muutujale. Arvmuutujaid loetakse kuni esimese tagasijooksu (Asc=13), reavahetuse (Asc=10), tĂŒhiku vĂ”i komani. Stringmuutujaid loetakse esimese tagasijooksu (Asc=13), reavahetuse (Asc=10) vĂ”i komani.

Avatud faili andmed ja andmetĂŒĂŒbid peavad olema samas jĂ€rjestuses, kui "var" parameetrile edastatavad muutujad. Kui mÀÀrad arvmuutujale mittearvvÀÀrtused, mÀÀrtakse parameetri "var" vÀÀrtuseks 0.

Komadega eraldatud kirjeid ei saa stringmuutujale mÀÀrata. Failides ei tohi kasutada ka jutumÀrke ("). Kui soovid neid mÀrke failist lugeda, kasuta tekstifailide (failid, mis sisaldavad prinditavaid mÀrke) reahaaval lugemiseks lauset Line Input#.

Kui andmeelemendi lugemisel jÔutakse faili lÔppu, ilmneb viga ja protsess katkestatakse.

NĂ€ide:


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

Palun toeta meid!