Visual Basic algoritmer: Files
ReadChars, ReadWords, ReadRecord
Ex:
Open "c:\windows\system.ini" For Input As #1
Do While Not EOF(1)
c$ = Input$(1, #1) '1 char from #1
t$ = t$ + c$
Loop
Close #1
Ex: PriceList
Type ItemRecord
PrCode As String * 8
PrDescr As String * 40
PrPrice As Double
End Type
Dim Item As ItemRecord
Open FILENAME For Random As #1 Len = Len(Item)
TotRecs = FileLen(FILENAME) / Len(Item)
For i = 1 To TotRecs
Get #1, i, Item
ItemLine$ = Item.PrCode + " " + Item.PrDescr + " " + Item.PrPrice
PriceList.AddItem ItemLine$
Next
Close #1
Ex:
Open "c:\windows\system.ini" For Input As #1
Do While Not EOF(1)
Input #1, w$ 'one word delimited by space, comma or EOL
t$ = t$ + w$
Loop
Close #1