Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript error 800A0401 'Expected end of statement' on 'Open ... For Input ...'

258 views
Skip to first unread message

Alpsummit

unread,
May 24, 2004, 9:56:22 AM5/24/04
to
Hi,

I tried this code :

FileName = "C:\temp\SC.csv"
Open FileName For Input as #1
Do Until EOF #1
Input #1, datastring
Loop
Close #1

and I get this message :

Windows Script Host
Error: Expected end of statement
Code: 800A0401
Source: Microsoft VBScript compilation error

I can't find out where I made a mistake...

Can anyone help me ?

Thanks

McKirahan

unread,
May 24, 2004, 10:04:44 AM5/24/04
to
"Alpsummit" <pbe...@groupemutuel.ch> wrote in message
news:58b77371.04052...@posting.google.com...


You're use QBasic not VBScript syntax.

You need to use the FileSystemObject.

Option Explicit
Const cOTF = "C:\temp\SC.csv"
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objOTF
Set objOTF = objFSO.OpenTextFile(cOTF,1)
If Not objOTF.AtEndOfStream Then
WScript.Echo objOTF.ReadLine()
End If
Set objOTF = Nothing
Set objFSO = Nothing

This just displays each line in the file.

Run under WScript it will "popup" each record.

Run under CScript it will list each record in a window.


0 new messages