Hi all

How i can read txt file and put it into textbox?
Please help me. Any help will be appreciated.

Thank you

Recommended Answers

All 3 Replies

Try something like this :

    Function FileText(ByVal filename As String) As String
        Dim handle As Integer

           ' ensure that the file exists
        If Len(Dir$(filename)) = 0 Then
            Err.Raise 53  ' File not found
        End If

           ' open in binary mode
        handle = FreeFile
        Open filename$ For Binary As #handle
           ' read the string and close the file
        FileText = Space$(LOF(handle))
        Get #handle, , FileText
        Close #handle
    End Function

Private Sub Command1_Click()
    Text1.Text = FileText("D:\image.txt")
End Sub

That's awesome.
Thank you jx_man

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.