|
-
Jun 20th, 2005, 05:21 PM
#1
Thread Starter
New Member
write to txt file: subscript out of range
hey all
i got this problem:
VB Code:
Dim A As Integer
Dim RijNamen(40) As String
VB Code:
A = 0
Open File For Output As #1
For A = 1 to 80
Select Case A
Case Is < 30
Write #1, RijTijden(A)
Case Is > 30 And < 41
Write #1, RijHighScores(A - 30)
Case Is > 40
Write #1, RijNamen(A - 40) '<--- here's the error
Next
Close #1
everything i put in the array RijNamen are dimmed as strings, but i guess the problem is there, i have no doubt where it could be
Last edited by sheepke; Jun 20th, 2005 at 07:53 PM.
-
Jun 20th, 2005, 05:28 PM
#2
Re: write to txt file: subscript out of range
First of all you aren't handling when A is exactly 30 or exactly 40. Rewrite it this way
VB Code:
A = 0' not needed
Open File For Output As #1
For A = 1 to 80
Select Case A
Case Is > 40 ' 41 to 80
Write #1, RijNamen(A - 40)
Case Is > 30 ' 31 to 40
Write #1, RijHighScores(A - 30)
Case Else ' 0 to 30
Write #1, RijTijden(A)
Next
Close #1
Put a breakpoint on the A = 1 to 80 line and step through the code and see what A is when it fails.
-
Jun 20th, 2005, 05:45 PM
#3
Addicted Member
Re: write to txt file: subscript out of range
Hi,
Martin is on the mark but this may help as well.
VB Code:
For A = 1 To 80
Select Case A
Case Is <= 30
Write #1, RijTijden(A)
Case 31 To 40
Write #1, RijHighScores(A - 30)
Case Is > 40
Write #1, RijNamen(A - 40)
Case Else
End Select
Next A
Have a good one!
BK
-
Jun 20th, 2005, 05:48 PM
#4
Thread Starter
New Member
Re: write to txt file: subscript out of range
i changed to much to know if it's good now
but i have a new problem:
if i have a variable like this: VarLine3 = "text"
how can i get the " away?
-
Jun 20th, 2005, 05:51 PM
#5
Re: write to txt file: subscript out of range
use Print instead of Write.
casey.
-
Jun 20th, 2005, 06:21 PM
#6
Thread Starter
New Member
Re: write to txt file: subscript out of range
 Originally Posted by vbasicgirl
use Print instead of Write.
casey.
Great, thanks 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
|