Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
bitoinfo

Comparação Em 2 Arquivos Txt

Question

alguém pode olhar este script e me dizer porque da este erro?

erro: file already open

na linha em negrito

Private Sub contas_pg()

Dim n, m As String

Dim linha(7) As String

Dim i, j As Integer

n = FreeFile()

m = FreeFile()

i = 1

Open "f:\controle de contas\dados.txt" For Input As #n

Do While Not EOF(n)

For j = 0 To 7

Line Input #n, linha(j)

Next

If linha(1) = "P" Then

i = i + 1

Open "f:\controle de contas\contas_pagas.txt" For Output As #m

For j = 0 To 7

Print #m, linha(j)

Next

End If

Loop

Close #m

Close #n

soma

End Sub

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

O problema está em...

n = FreeFile()
m = FreeFile()
... que atribui o mesmo valor para "n" e para "m". O correto seria fazer...
n = FreeFile()
Open "f:\controle de contas\dados.txt" For Input As #n
m = FreeFile()

... daí "n" e "m" teriam valores diferentes (uma vez que o número de arquivo utilizado em "n" já estaria aberto de verdade).

Certo? wink.gif

Graymalkin

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

Cloud Computing


  • Forum Statistics

    • Total Topics
      148105
    • Total Posts
      643381
×
×
  • Create New...