vb read file, how to read file in visual basic, vb6 file reading source code, read file line by line, read whole file, read file letter by letter, read file character by character, read comma-delimited file vb how to read file
(Website Helper) vb: read file Number of Visitors: Site Map

vb: how to read file



Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
This site provides users with the information aboutvb read file, how to read file in visual basic, vb6 file reading source code, read file line by line, read whole file, read file letter by letter, read file character by character, read comma-delimited file, and more.

If you think that this site is helpful, please recommend your friends to visit our site.



The following lists three ways of reading file. They are read file line by line, read whole file, read file letter by letter (character by character), and read comma-delimited file

1. How to read file line by line?

Open App.Path & "\temp.txt" For Input As #1

Do While Not EOF(1)
    Line Input #1, wholeLine
    wholeLineAll = wholeLineAll & wholeLine & vbCrLf
    DoEvents
Loop

Close #1
2. How to read whole file?
Open App.Path & "\temp.txt" For Input As #1

myString = Input(FileLen(App.Path & "\temp.txt"), #1)

Close #1
3. How to read file letter by letter?
Open App.Path & "\temp.txt" For Input As #1

Do While Not EOF(1)
    MyChar = Input(1, #1) 'one char a line
    If (MyChar = "#") Then
        count_number = count_number + 1
    End If
Loop

Close #1
4. How to read comma-delimited file?
Private Sub Command1_Click()

Dim strIn As String
Dim fields() As String
Dim nFields As Integer
Dim i As Integer

Open "C:\test.csv" For Input As #1
While Not EOF(1)
    Line Input #1, strIn
    fields = Split(strIn, ",")
    nFields = UBound(fields)
    For i = 0 To nFields
    Debug.Print fields(i)
    Next i
Wend

Close #1

End Sub

(Website Helper) vb: read file (c) EduSoftMax - www.edusoftmax.com