|
-
Sep 5th, 2001, 02:16 AM
#1
Thread Starter
New Member
run-time error 59
I know this is gonna be something really stupid, but for some reason, I can't locate the problem.
I keep getting an error 59 when trying to get this info from a file into an array. Here is the code:
Open (App.Path & "\" & "RegSales.txt") For Random As #intFNum
'im not sure what to put for len
Do Until EOF(intFNum)
Get #intFNum, intCounter, varLine
strArray(intCounter) = varLine
intCounter = intCounter + 1
Loop
Please help. This is a homework assignment, and I need to get it done tonight.
Thanks in advance,
Skyler
-
Sep 5th, 2001, 02:23 AM
#2
-= B u g S l a y e r =-
at what line does the error occur, and what is the error description?
is app.path a local path or does the program reside on a server?
-
Sep 5th, 2001, 02:27 AM
#3
Thread Starter
New Member
at the get statement
the error occurs at the get statement line
Get #intFNum, intCounter, varLine
-
Sep 5th, 2001, 02:31 AM
#4
-= B u g S l a y e r =-
I'll do some quoting 
MSDN
Bad record length (Error 59)
The length of a record variable for a Get or Put statement does not match the length specified in the corresponding Open statement. Because a two- byte descriptor is always added to a variable-length string Put to a random access file, the variable-length string must be at least two characters shorter than the record length specified in the Len clause of the Open statement.
Variant data types also require a two-byte descriptor. Variants containing variable-length strings require a four-byte descriptor. Therefore, for variable-length strings in a Variant, the string must be at least 4 bytes shorter than the record length specified in the Len clause.
does that help u in any way?
-
Sep 5th, 2001, 02:35 AM
#5
-= B u g S l a y e r =-
-
Sep 5th, 2001, 02:40 AM
#6
Hyperactive Member
I do not know if you want to use the get statement for a specific reason, but with this example you read the file line by line and stock it in a dynamic array.
Remeber to always use the option explicit statement to avoid errors.
VB Code
Option Explicit
Dim intFNum As Integer
Dim intcounter As Integer
Dim varline As String
Dim strArray() As String
Private Sub test()
intFNum = FreeFile
intcounter = 0
Open ("C:" & "\" & "RegSales.txt") For Input As #intFNum
'im not sure what to put for len
Do Until EOF(intFNum)
intcounter = intcounter + 1
Input #intFNum, varline
ReDim Preserve strArray(intcounter)
strArray(intcounter) = varline
Loop
Close #intFNum
End Sub
Greetz, Luc
-
Sep 5th, 2001, 02:43 AM
#7
Thread Starter
New Member
solved it
thanks a lot peet! i am no longer getting the error 59. now i am getting a error 9 (subscript out of range) on this line:
strArray(intCounter) = varLine
but hopefully, i will be able to figure it out.
thanks again,
skyler
-
Sep 5th, 2001, 02:49 AM
#8
-
Sep 5th, 2001, 02:50 AM
#9
Thread Starter
New Member
LucGuldentops, you are a life saver!!!
thanks so much LucGuldentops...that is exactly what i was looking to do! you are my hero.
thanks again you guys for taking the time to post and help out,
skyler
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
|