I have two functions on Visual Basic for read and write one file
The problem is in the read Function. The return
sentence doesn't return anything. I only want read the first line of the file
What Am i doing wrong? Why does the return
not put the value in the text variable?
Function readfile()
Dim objFSO
Dim objLF
Dim text
Set objFSO = CreateObject("Scripting.FileSystemObject")
on error resume next
Set objLF= objFSO.OpenTextFile ("file.txt",1,false)
if Err.Number <> 0 Then
Wscript.echo "error"
else
text = objLF.ReadLine
objLF.Close
return text
end if
On Error Goto 0
End Function