VB Code:
Private Sub Form_Load() Open "c:\TEXT.TXT" For Output As #1 Get #1, , fileinfo Close #1 Text1.Text = fileinfo End Sub
runtime error 54 "bad file mode". Highlights the 'get #1, , fileinfo" string of code
Any help would be appreciated
Printable View
VB Code:
Private Sub Form_Load() Open "c:\TEXT.TXT" For Output As #1 Get #1, , fileinfo Close #1 Text1.Text = fileinfo End Sub
runtime error 54 "bad file mode". Highlights the 'get #1, , fileinfo" string of code
Any help would be appreciated
You have opened the file for output, which means that you intend to write to the file. The Get statement is used during file input.
But I'm not sure you can even use Get when opening for Input, I though it was only used for Random and Binary.
*edit* using random works. but now we're on a different problem:
error 458:
Variable uses an automation type not supported in Visual Basic
The text file contains:
"ASD"
Have you defined fileinfo as a variable...
Please use a buffer while working with files but you have to Declare the type of that variable first, so
By the wayCode:Private Sub Form_Load()
Dim strFileInfo
Open "c:\TEXT.TXT" For Input As #1
Get #1, , strFileInfo
Close #1
Text1.Text = strFileInfo
End Sub
You can also use relative path for file you wants to open.
that was also a solution. however i get another problem now.
error 59:
bad record length