Re: Run-time Error 52 Bad filename or number
have the same problem with the following piece of code help plz i have over 1000 lines code working already aand really need this bit to work but cant work it out :
Code:
frm_winnings.lblnumbers_matched = ("you have matched " & result & "numbers")
Select Case result
Case result < 3
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #1
winnings(1) = Input(LOF(6), 1)
Close #1
Case result = 3
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #2
winnings(2) = Input(LOF(6), 2)
Close #2
Case result = 4
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #3
winnings(3) = Input(LOF(6), 3)
Close #3
Case result = 5
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #4
winnings(4) = Input(LOF(6), 4)
Close #4
Case result = 6
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #5
winnings(5) = Input(LOF(6), 5)
Close #5
Case result = 7
Open "N:\Computing\Advanced Higher Computing\Software Development\winnings.txt" For Input As #6
winnings(6) = Input(LOF(6), 6)
Close #6
End Select
End Sub
Re: Run-time Error 52 Bad filename or number
You should use the same file number in the LOF function
Code:
'
winnings(1) = Input(LOF(1), 1)
'
winnings(2) = Input(LOF(2), 2)
'
'etc
The LOF function retrieves the size of the file you want to load