| | |
Runtime Error 5 - Need help please
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2006
Posts: 2
Reputation:
Solved Threads: 0
Hi
I have a procedure which I have pasted below. I am using the VBe Enterprise environment and all test machines are Windows XP Pro SP2 with the latest hotfixes. On my machine (the one with the dev env) I have no issues running the application I have written. The machine is a Sony Vaio.
I have tested it on a Dell Dimension 3100 and it runs there also.
When I try it on another Sony Vaio and also on a couple of other laptops, all of the same XP PRo SP2, I get Error #5.
The line in question is:
It is always this line. If I move it the error moves.
The routine essentially scans through a INF file and retrieves drivers that are used on the PC.
I have read elsewhere in newsgroups that adding DoEvents solves this. But not for me. I have also tried altering the line to use MID, but that also does not work.
Can someone please help, as I cannot move to .Net due to the fact that users will be foced to install .NET framework just for this app and a lot of them refuse as it is a live network.
In Anticipation
Jay
I have a procedure which I have pasted below. I am using the VBe Enterprise environment and all test machines are Windows XP Pro SP2 with the latest hotfixes. On my machine (the one with the dev env) I have no issues running the application I have written. The machine is a Sony Vaio.
I have tested it on a Dell Dimension 3100 and it runs there also.
When I try it on another Sony Vaio and also on a couple of other laptops, all of the same XP PRo SP2, I get Error #5.
The line in question is:
470 BigString$ = Left(BigString$, Len(BigString$) - 1)
It is always this line. If I move it the error moves.
The routine essentially scans through a INF file and retrieves drivers that are used on the PC.
I have read elsewhere in newsgroups that adding DoEvents solves this. But not for me. I have also tried altering the line to use MID, but that also does not work.
Can someone please help, as I cannot move to .Net due to the fact that users will be foced to install .NET framework just for this app and a lot of them refuse as it is a live network.
Function ReadINF(fname As String, InfSec As String)
' !!!!!!!!!!!!! REMEMBER TO PASS INF SECTION VALUE
Dim LineFromFile$, cfSTR$, cfPOS As Variant, cfTRIM$
Dim INF$() ' Load the INF File into this array
Dim cfCOMPS$() 'define cf components array
Dim CompFiles$() ' This is the array that will hold the actual file names
Dim cnt, cnt2
Dim j As Variant, i As Variant, k As Variant, L As Variant, M As Variant
Dim InfSecPos As String, ktemp As String
Dim foundFlag As Boolean, FirstTimeFind As Boolean
Dim BigString$ ' Used to make up a delimited String to populate an array to avoid ERR 9
Dim eqPOS ' Position of Equals sign in CopyFiles String
Dim LBoundOfArray, UBoundOfArray, ArrayCounter
10 On Error GoTo ReadINF_Error
20 foundFlag = False
30 FirstTimeFind = False
' Attach the []
40 InfSec = "[" + InfSec + "]"
' Set up the filesystem object
50 fname = Environ$("WINDIR") + "\inf\" + fname
60 Set fs = CreateObject("Scripting.FileSystemObject")
70 Set A = fs.OpenTextFile(fname, 1, 0)
' Read the inf file in and start process of query
80 cnt = 1
90 While Not A.AtEndOfStream
100 ReDim Preserve INF(cnt) As String
110 INF(cnt) = A.ReadLine
120 cnt = cnt + 1
130 DoEvents
140 Wend
150 A.Close
' First find the section
160 cfSTR$ = ""
170 For Each j In INF
180 If (InStr(1, j, InfSec, 1) = 1) And (foundFlag = False) Then foundFlag = True
190 If (foundFlag = True) And j = "" Then GoTo FoundEndOfSection
200 If (foundFlag = True) And (Mid(j, 1, 9) = "CopyFiles") Then
210 cfSTR = j
220 GoTo FoundEndOfSection
230 End If
240 Next
FoundEndOfSection:
' Trim the "CopyFiles = " away
250 eqPOS = InStr(1, cfSTR, "=", vbTextCompare)
260 cfTRIM$ = Mid$(cfSTR, eqPOS + 1)
'Parse cfSTR into the individual components
270 cfCOMPS$() = Split(cfTRIM$, ",", -1)
' ******************************************************
' Now find each section at a time and copy the files
280 foundFlag = False
290 cnt2 = 1
300 For Each k In cfCOMPS
310 BigString$ = ""
320 ktemp = k
330 ktemp = Mid(ktemp, 2)
340 InfSec = "[" + ktemp + "]"
350 LBoundOfArray = LBound(INF)
360 UBoundOfArray = UBound(INF)
370 ArrayCounter = 0
380 For Each L In INF
' Form1.Print (L)
390 If (InStr(1, L, InfSec, 1) = 1) And (foundFlag = False) Then foundFlag = True
400 If (foundFlag = True) And L = "" Then Exit For
410 If (foundFlag = True) And L <> "" Then
420 If L <> InfSec Then
430 BigString$ = BigString$ + L + ","
440 End If
450 End If
460 Next
' Finished scanning that aection - now remove trailing comma
470 BigString$ = Left(BigString$, Len(BigString$) - 1)
480 If foundFlag = True Then
490 DoEvents
' BigString$ = Mid(BigString$, 1, Len(BigString) - 1)
500 foundFlag = False
' Now pass BigString$ to the FileCopier.
' Form1.Print (BigString$)
510 CopyDrivers regroot$, BigString$
520 End If
530 Next
540 On Error GoTo 0
550 Exit Function
ReadINF_Error:
560 MsgBox "Error " & Err.Number & " at line:" & Erl & vbCrLf & " (" & Err.Description & ") in procedure ReadINF of Form Form1"
End Function
In Anticipation
Jay
Hi,
You havent done a check to see if BigString contains anything in it.
pG
You havent done a check to see if BigString contains anything in it.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
lenBigString = len(BigString) if lenBigString <=1 then msgbox "Invalid String" end if
pG
Last edited by Comatose; Aug 21st, 2006 at 9:49 am.
purpleGERBIL
•
•
Join Date: Aug 2006
Posts: 2
Reputation:
Solved Threads: 0
The problem is not that I feel. The way that the previous area of the code works ensures that BIGSTRIN$ has always got the list of filenames seperated by commas. The reason for the LEFT was to remove the trailing comma.
I have since removed this line altogether and put checking for a blank entry in the array when I split BIGSTRING$.
The issue therefore is something else.
380 For Each L In INF
' Form1.Print (L)
390 If (InStr(1, L, InfSec, 1) = 1) And (foundFlag = False) Then foundFlag = True
400 If (foundFlag = True) And L = "" Then Exit For
410 If (foundFlag = True) And L <> "" Then
420 If L <> InfSec Then
430 BigString$ = BigString$ + L + ","
440 End If
450 End If
460 NextI have since removed this line altogether and put checking for a blank entry in the array when I split BIGSTRING$.
The issue therefore is something else.
Its a strange one this. I cannot recreate the error on my pc.
what about
have you got BigString defined?
pG
what about
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
lenBigString = len(BigString)-1 BigString = Left(BigString, lenBigString)
have you got BigString defined?
pG
purpleGERBIL
The problem with the line (470) is without a doubt, the fact that the length is equal to 0 in the left function. Check this:
I removed the -1 (since the length of bigstring$ was 0) and the left function didn't flip out. It flips out (and returns an invalid procedure call or argument) when left is being called with a negative value. The second argument (parameter) to left, MUST BE a positive value (or 0, which I suppose is also positive). Check the length of bigstring$ first, such as:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
'BigString$ = Left(BigString$, Len(BigString$) - 1) BigString$ = Left(BigString$, Len(BigString$))
if len(bigstring$) < 0 then if you are having problems after removing that line, then there is more than 1 problem in the code, and I'm guessing it has to do with the length of bigstring$ being less than 0 also.... ![]() |
Similar Threads
- Runtime Error -21470024770 (8007007e) (Windows NT / 2000 / XP)
- Runtime Error 226 (Windows 95 / 98 / Me)
- runtime error#58 (Visual Basic 4 / 5 / 6)
- "The Sims" visual C++ runtime error, what shall i do? (Windows Software)
- Visual Runtime Error, Sound Problem, Disabled Norton and more! (Windows NT / 2000 / XP)
- Runtime Error 424 object required (was: Please Help!) (Visual Basic 4 / 5 / 6)
- Runtime error using Incredimail on XP (Windows NT / 2000 / XP)
- Runtime error ??!! (Windows 95 / 98 / Me)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Dial-up a connection through modem using VB6
- Next Thread: Javascript/VBScript within VB6 application
Views: 9273 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic web window windows






