hi all,

when trying to execute a code for reading from a text file in VB, using the ReadAllText function, i get 'variable not defined' error.

the following is the code:
Private Sub Command2_Click()
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt")
MsgBox (fileReader)
End Sub

kindly enlighten me on why i get the error and what should be done to clear it.

Recommended Answers

All 2 Replies

start quote:

Private Sub Command2_Click()
        Dim fileReader As String
        fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt")
        MsgBox (fileReader)
End Sub

end quote.

What exactly do you want to the Test.txt?

Wait, are you sure this is VB4/5/6? I thaught the MY namespace only came in in .NET ????

Be a part of the DaniWeb community

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