run-time error 5

JDavis
06-26-2002, 02:33 PM
*Scratches Head*
Okay, I'm puzzled at this one:

I wrote my app on a Win98 machine using VB6 SP5
I sent it to the client and when they install, it says it can't overwrite certain files because they are in use. One of them being 'msvcrt.dll' and another: 'scrrun.dll'. If you ignore the error it will complete setup. The App loads okay, but when a button is pressed, it returns a run-time error 5.

I installed the app on 3 other win2000 sp2 machines here at the office and it works fine. I also installed it on another win98 and it ran fine too. The Client's computer is running win2000 sp2 but it will not run on it for some reason.

Any suggestions or help is appreciated...

Thx

JDavis

Thinker
06-26-2002, 04:05 PM
Don't even bother with msvcrt.dll. That is the VC++ runtime, and
it should already be there and most of the time will be loaded and
locked. scrrun.dll is the microsoft scripting runtime (where the
filesystemobject/dictionary object come from) and most likely
there will already be a newer version on win2k.
Could you post the code in the button click where the error comes
from? One wouldn't expect that error from a missing object library.

JDavis
06-26-2002, 05:40 PM
It is a parsing app that parses an ascii file into seperate word documents and names them accordingly.

Okay here is the code that is in Form1. There is also a module where I have a type declaration

- Module1 -

Type headerInfo
drInit As String
docType As String
Name As String
AcctNumber As String
ssn As String
DOS As String
End Type



- Form1 -

Option Explicit
Dim hdrInfo As headerInfo
Dim lasthdrinfo As headerInfo
Dim MyPath As String
Dim myName As String
Dim sameSSN As Boolean
Dim sameDOS As Boolean

'Below is the button click
Private Sub Command1_Click()
Command1.Enabled = False
Dim ff1 As Integer
Dim strText As String
Dim strLine As String
Dim hdrText As String
Dim counter As Long
Dim j As Integer
Dim fso As New FileSystemObject
MyPath = "C:\Parse\"
Const hdrStart As String = "VWC"

If Not Right$(MyPath, 1) = "\" Then MyPath = MyPath & "\"
'MyPath = MyPath & "*.txt"
strText = ""
myName = Dir(MyPath) ' Retrieve the first entry.
PBar1.Min = 0
PBar1.Max = fso.GetFolder(MyPath).Files.Count
Label5(1).Caption = PBar1.Max

Do While myName <> "" ' Start the loop.
DoEvents
If myName <> "." And myName <> ".." Then
If Not GetAttr(MyPath & myName) = vbDirectory Then
Label5(0).Caption = myName
ff1 = FreeFile
DoEvents
Open MyPath & myName For Input As #ff1
strText = ""
Do While Not EOF(ff1)
Line Input #ff1, strLine
If InStr(1, strLine, hdrStart) Then
' lastSSN = hdrInfo.ssn
' lastDOS = hdrInfo.DOS
'If Not hdrInfo.ssn = "" And Not hdrInfo.DOS = "" Then writeData strText
hdrText = ""
hdrText = strLine
counter = 0
While counter < 6
Line Input #ff1, strLine
hdrText = hdrText & strLine & vbCrLf

Select Case counter

'Case Is = 0, 1, 4
Case Is = 1
getNameAcct strLine
Case Is = 2
getSSN strLine
If InStr(1, strLine, hdrInfo.ssn) Then
sameSSN = True
End If

Case Is = 4
getDOSmdInit strLine
If InStr(1, strLine, hdrInfo.DOS) Then
sameDOS = True
End If
Case Is = 5
If InStr(1, strLine, "CONTINUED") Then
While InStr(1, strLine, "CONTINUED") Or InStr(1, strLine, Chr$(13) & Chr$(11))
hdrText = hdrText & strLine
Line Input #ff1, strLine
Wend
End If
getDocType strLine
Case Else

End Select

counter = counter + 1
Wend
If Len(lasthdrinfo.ssn) = 0 Then
With lasthdrinfo
.AcctNumber = hdrInfo.AcctNumber
.docType = hdrInfo.docType
.DOS = hdrInfo.DOS
.drInit = hdrInfo.drInit
.Name = hdrInfo.Name
.ssn = hdrInfo.ssn
End With
End If
If lasthdrinfo.ssn = hdrInfo.ssn And lasthdrinfo.DOS = hdrInfo.DOS Then
strText = strText & hdrText & vbCrLf
Line Input #ff1, strLine
Else
writeData strText
With lasthdrinfo
.AcctNumber = hdrInfo.AcctNumber
.docType = hdrInfo.docType
.DOS = hdrInfo.DOS
.drInit = hdrInfo.drInit
.Name = hdrInfo.Name
.ssn = hdrInfo.ssn
End With
strText = ""
strText = hdrText & vbCrLf
End If

End If
strText = strText & strLine & vbCrLf
Loop
writeData strText
Close #ff1
End If
End If
PBar1.Value = PBar1.Value + 1
myName = Dir
Loop

MsgBox "Finished!", vbInformation, "Attention!"
PBar1.Value = PBar1.Min
For j = Label5.LBound To Label5.UBound
Label5(j).Caption = ""
Next
Command1.Enabled = True
Set fso = Nothing
End Sub

Private Sub writeData(textString As String)
Dim ff2 As Integer
Dim fso As New FileSystemObject
Dim saveFolder As String
Dim dateOfSvc As String
Dim docType As String
Dim drInit As String
Dim FLName As String
Dim actNum As String

ff2 = FreeFile
If Not Len(textString) = 0 Then
With lasthdrinfo
saveFolder = MyPath & Left$(myName, Len(myName) - Len(fso.GetExtensionName(myName))) & "_"
If fso.FolderExists(saveFolder) = False Then MkDir saveFolder
dateOfSvc = .DOS
docType = .docType
drInit = .drInit
FLName = .Name
actNum = .AcctNumber
ReplChars drInit, dateOfSvc, docType, FLName, actNum
'dateOfSvc = Replace(dateOfSvc, "/", "")
'docType = Replace(.docType, "/", "")
Open saveFolder & "\" & drInit & "_" & dateOfSvc & "_" & docType & "_" & FLName & "_" & actNum & ".doc" For Output As #ff2
Print #ff2, textString
Close #ff2
End With
End If
Set fso = Nothing
End Sub

Private Sub getNameAcct(namAct As String)
Dim namStart As Integer
Dim actStart As Integer

namStart = InStr(1, namAct, "Name:")
hdrInfo.Name = Trim$(Mid$(namAct, namStart + 7, 32))
actStart = InStrRev(namAct, "Acct. #:")
hdrInfo.AcctNumber = Trim$(Mid$(namAct, actStart + 10, (Len(namAct) - actStart - 9)))

End Sub

Private Sub getSSN(ssn As String)
Dim ssnStart As Integer

ssnStart = InStrRev(ssn, "SSN:")
hdrInfo.ssn = Trim$(Mid$(ssn, ssnStart + 10, Len(ssn) - ssnStart - 9))
End Sub

Private Sub getDOSmdInit(DOSMD As String)
hdrInfo.DOS = Trim$(Mid$(DOSMD, 1, 24))
hdrInfo.drInit = Trim$(Mid$(DOSMD, 25, Len(DOSMD) - 20))
End Sub


Private Sub getDocType(docType As String)
hdrInfo.docType = Trim$(docType)
End Sub

Private Sub ReplChars(DI As String, DOS As String, docType As String, FLName As String, actNum As String)
Dim i As Integer
Dim x(9)
x(0) = "/"
x(1) = "\"
x(2) = ":"
x(3) = "*"
x(4) = "?"
x(5) = Chr(34)
x(6) = ">"
x(7) = "<"
x(8) = "|"

For i = 0 To 8 'Replaces Illegal filename chars
DI = Replace(DI, x(i), "-")
DOS = Replace(DOS, x(i), "-")
docType = Replace(docType, x(i), "-")
FLName = Replace(FLName, x(i), "-")
actNum = Replace(actNum, x(i), "-")
Next
Erase x

End Sub



Thank you,

JDavis

Flyguy
06-27-2002, 01:13 AM
You could replace all FSO code by standard VB methods. In that case you don't need a reference to FSO anymore.

Thinker
06-27-2002, 06:04 PM
Arnout's idea may be the best one. You only seem to be using it
to get a count of all the files in the folder. It might be the easiest
way to do that, but if it is causing this error, it would be better to
do it in a way that doesn't require scrrun.dll.

JDavis
06-28-2002, 08:22 AM
Okay, They got it to work on a win98 laptop. The client runs a citrix client, but I dont think that that is affecting my app. It worked on the win 98 laptop until they installed windows networking on it. After that, it too generated the run-time error 5, but only after installing Microsoft Windows Networking and rebooting the laptop. Is there a file that networking adds that is not compatible with the app? The only files that my App is installing are: Mscomctl.ocx, msvcrt.dll, scrrun.dll. Also I have networking installed at my office and it works fine for me on 2000 and 98. I am looking into replacing the scrrun.dll as suggested by ArnoutV, but would it have anything to do with networking?

Any help is appreciated

Thank you,

JDavis

Thinker
06-28-2002, 08:48 AM
No, I wouldn't think it would have anything to do with networking.
It is just a object library originally created for ASP/VBScript to
provide for things that were missing (file handling and collections).

Is there any chance that MyPath might be getting set to a
network UNC, like \\server\C\program files?

JDavis
06-28-2002, 09:47 AM
Yes! I finally found the problem. The test files that the client gave to me to work off of are different than the ones that the application was being run on and it was returning errors.
I now have the other files that they are running them on and am writing it to work on them. Thank you Arnout, and Thinker for your time and help.

JDavis

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum