VB6 compile error

Hello,

I've recently had to pick up on VB6 to adapt an existing legacy application (I need to read a file in UTF and output its contents to another charset), but I've stumbled on an annoying problem: given the code below, the Print line it giving me "Compile error: Expected: ("
The code is attached to the post.

Thanks in advance :)


Dim inStr As String
    Dim inputFileNumber As Integer
    Dim outputFileNumber As Integer         
         
    inputFileNumber = FreeFile
    outputFileNumber = FreeFile
    Open "C:\in.txt" For Input As #inputFileNumber
    Open "C:\out.txt" For Output As #outputFileNumber
    
    Do Until EOF(inputFileNumber)
       Line Input #inputFileNumber, inStr
       Print #outputFileNumber, inStr 'this line raises the error
    Loop
    
    Close #inputFileNumber
    Close #outputFileNumber

Open in new window

LVL 1
bass20Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about this:
    Dim inStr As String
    Dim inputFileNumber As Integer
    Dim outputFileNumber As Integer         
         
    inputFileNumber = FreeFile
    Open "C:\in.txt" For Input As #inputFileNumber
    outputFileNumber = FreeFile
    Open "C:\out.txt" For Output As #outputFileNumber
    
    while not EOF(inputFileNumber)
       Line Input #inputFileNumber, inStr
       Print #outputFileNumber, inStr 
    wend
    
    Close #inputFileNumber
    Close #outputFileNumber

Open in new window

0
GrahamSkanRetiredCommented:
instr is a function name
Change it to something else
Dim strIn As String
    Dim inputFileNumber As Integer
    Dim outputFileNumber As Integer
         
    inputFileNumber = FreeFile
    outputFileNumber = FreeFile
    Open "C:\in.txt" For Input As #inputFileNumber
    Open "C:\out.txt" For Output As #outputFileNumber
    
    Do Until EOF(inputFileNumber)
       Line Input #inputFileNumber, strIn
       Print #outputFileNumber, strIn 'this line raises the error
     Loop
    
    Close #inputFileNumber
    Close #outputFileNumber

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
3_SCommented:
change the variable inStr  (you can not use this since this is a VB function)


Dim sInStr As String
    Dim inputFileNumber As Integer
    Dim outputFileNumber As Integer         
         
    inputFileNumber = FreeFile
    outputFileNumber = FreeFile
    Open "C:\in.txt" For Input As #inputFileNumber
    Open "C:\out.txt" For Output As #outputFileNumber
    
    Do Until EOF(inputFileNumber)
       Line Input #inputFileNumber, sInStr
       Print #outputFileNumber, sInStr 
    Loop
    
    Close #inputFileNumber
    Close #outputFileNumber

Open in new window

0
AJKBOCCommented:
bass20,
 
   Instr is a function used to fine a character or a word inside a string. It's consider to be a reserved word for VB. Use something else and it should work fine.

Regards,
Savvas
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.