Results 1 to 7 of 7

Thread: [RESOLVED] Error during Run-Time

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Resolved [RESOLVED] Error during Run-Time

    I built, compiled, and ran the application error-free on my Win2k PC. When I load the application on a WinXP PC I error out 'File not Found'. I can not find any reason for the error. below is the code the form consist of a text box "text1" and two timers.

    vb Code:
    1. Option Explicit
    2. Dim DelFiles(0 To 100) As String
    3. Dim FS As New FileSystemObject
    4. Dim FSfolder As Folder
    5. Dim File As File
    6.  
    7. Private Sub Form_Load()
    8. Dim strStartPath As String
    9.     strStartPath = "C:\invprnt"
    10.     Call ListFolder(strStartPath)
    11. End Sub
    12.  
    13. Private Sub ListFolder(sFolderPath As String)
    14.    
    15.     Dim i As Integer
    16.     Dim Cnt As Integer
    17.     Dim Cmd As String
    18.    
    19.     Cmd = "c:\dosprint\dosprinter /raw "
    20.     Cnt = 0
    21.     StrtTime.Enabled = False
    22.     Set FSfolder = FS.GetFolder(sFolderPath)
    23.    
    24.         Text1.Text = ""
    25.         For Each File In FSfolder.Files
    26.             DoEvents
    27.             Text1.Text = Text1.Text & File & vbCrLf
    28.             Shell (Cmd & File)
    29.             DelFiles(Cnt) = File
    30.             Cnt = Cnt + 1
    31.         Next File
    32.        
    33.     Timer.Enabled = True
    34. End Sub
    35.  
    36. Private Sub StrtTime_Timer()
    37. StrtTime.Enabled = False
    38. Call ListFolder("c:\invprnt")
    39. End Sub
    40.  
    41. Private Sub Timer_Timer()
    42.     Dim Flag As Boolean
    43.     Dim Cnt As Integer
    44.     Timer.Enabled = False
    45.    
    46.     Flag = True
    47.     Cnt = 0
    48.    
    49.     Do While Flag = True And Cnt < 101
    50.         If IsNull(DelFiles(Cnt)) = True Or DelFiles(Cnt) = "" Then
    51.             Flag = False
    52.         Else
    53.             Call FileCopy(DelFiles(Cnt), "c:\bkupinv\" & Right(DelFiles(Cnt), 11))
    54.             Cnt = Cnt + 1
    55.            
    56.         End If
    57.     Loop
    58.            
    59.     Flag = True
    60.     Cnt = 0
    61.    
    62.     Do While Flag = True And Cnt < 101
    63.         If IsNull(DelFiles(Cnt)) = True Or DelFiles(Cnt) = "" Then
    64.             Flag = False
    65.         Else
    66.             Call Kill(DelFiles(Cnt))
    67.             Cnt = Cnt + 1
    68.         End If
    69.     Loop
    70.     Cnt = Cnt - 1
    71.     Do While Cnt >= 0
    72.         DelFiles(Cnt) = ""
    73.         Cnt = Cnt - 1
    74.     Loop
    75.     StrtTime.Enabled = True
    76. End Sub

    Thanks for any suggestions

    -RT

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Error during Run-Time

    You have hardcoded file path more than once so one of them is failing I guess:

    strStartPath = "C:\invprnt"
    Cmd = "c:\dosprint\dosprinter /raw "
    Call ListFolder("c:\invprnt")
    Call FileCopy(DelFiles(Cnt), "c:\bkupinv\" & Right(DelFiles(Cnt), 11))

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Re: Error during Run-Time

    -The application watches a folder "c:\invprnt" for a file to be saved to it

    -If it finds a file then the app shells a cmd line "c:\dosprint\dosprinter /raw c:\invprnt" This prints the txt document to the printer in raw format

    -the file is then saved to "c:\bkupinv"

    -and finally deleted from "c:\invprnt"


    This is why there is more than one path. They are all needed and are all present on the PC giving errors.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Error during Run-Time

    File not found is generated from one of two things and only two things:

    1. The folder path does not exist
    2. The file name does not exist

    One of those two are not present on this machine.

    Is this the only machine on which this is happening?

    Also, why does this result in an runtime error? Why don't you have your code error trapped so runtimes don't happen?

  5. #5
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Error during Run-Time

    When you "Load" your application on the other machine are you creating an installation package or just copying the exe?

    Are you creating the folders you are watching if they do not exist?

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Error during Run-Time

    On which line is the error happening?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2006
    Location
    In the midst of corn, cotton, and beans
    Posts
    185

    Re: Error during Run-Time

    The main problem is me not thinking. The problem occurred on line 53. The app copies a file, whose name is 7 characters long, from one folder to another. In testing I created a txt file in the source folder and named it test.txt |note: that test is not 7 characters.

    This problem has been resolved. Much thanks to all.

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