Here is my code. The file abc.csv exists and is full of data.
Dim strContent As String
Dim int As Integer
Open "C:\abc.csv" For Input As #int
strContent = 开发者_如何学JAVAInput(LOF(int), int)
Close #int
The error that I get is that the code proceeds as if the file never existed...but it does exist in the C:\ drive directory. I made extra sure of it. C:\abc.csv is there....What am I missing?
Try
int = FreeFile
Open "C:\abc.csv" For Input As #int
I don't have a VB6 environment to test this in, but I think you want to try it like this:
Dim strContent As String
Dim int As Integer
int = FreeFile
Open "C:\abc.csv" For Input As #int
strContent = Input(LOF(int), #int) '<-- make sure to put the # on the 2nd param
Close #int
See here for more info (under Using the Open method in Classic VB):
http://www.vbknowledgebase.com/?Id=23&Desc=Read-Text-File-into-string-VB6
精彩评论