|
-
May 16th, 2008, 09:18 AM
#1
Thread Starter
Addicted Member
[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:
Option Explicit
Dim DelFiles(0 To 100) As String
Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim File As File
Private Sub Form_Load()
Dim strStartPath As String
strStartPath = "C:\invprnt"
Call ListFolder(strStartPath)
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim i As Integer
Dim Cnt As Integer
Dim Cmd As String
Cmd = "c:\dosprint\dosprinter /raw "
Cnt = 0
StrtTime.Enabled = False
Set FSfolder = FS.GetFolder(sFolderPath)
Text1.Text = ""
For Each File In FSfolder.Files
DoEvents
Text1.Text = Text1.Text & File & vbCrLf
Shell (Cmd & File)
DelFiles(Cnt) = File
Cnt = Cnt + 1
Next File
Timer.Enabled = True
End Sub
Private Sub StrtTime_Timer()
StrtTime.Enabled = False
Call ListFolder("c:\invprnt")
End Sub
Private Sub Timer_Timer()
Dim Flag As Boolean
Dim Cnt As Integer
Timer.Enabled = False
Flag = True
Cnt = 0
Do While Flag = True And Cnt < 101
If IsNull(DelFiles(Cnt)) = True Or DelFiles(Cnt) = "" Then
Flag = False
Else
Call FileCopy(DelFiles(Cnt), "c:\bkupinv\" & Right(DelFiles(Cnt), 11))
Cnt = Cnt + 1
End If
Loop
Flag = True
Cnt = 0
Do While Flag = True And Cnt < 101
If IsNull(DelFiles(Cnt)) = True Or DelFiles(Cnt) = "" Then
Flag = False
Else
Call Kill(DelFiles(Cnt))
Cnt = Cnt + 1
End If
Loop
Cnt = Cnt - 1
Do While Cnt >= 0
DelFiles(Cnt) = ""
Cnt = Cnt - 1
Loop
StrtTime.Enabled = True
End Sub
Thanks for any suggestions
-RT
-
May 16th, 2008, 09:23 AM
#2
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))
-
May 16th, 2008, 10:18 AM
#3
Thread Starter
Addicted Member
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.
-
May 16th, 2008, 10:47 AM
#4
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?
-
May 16th, 2008, 03:45 PM
#5
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?
-
May 16th, 2008, 11:04 PM
#6
Re: Error during Run-Time
On which line is the error happening?
-
May 23rd, 2008, 07:09 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|