CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Join Date
    Oct 2012
    Posts
    1

    Angry 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

  2. #17
    Join Date
    Jul 2005
    Posts
    1,083

    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
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured