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
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.
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
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?
Re: write to txt file: subscript out of range
use Print instead of Write.
casey.
Re: write to txt file: subscript out of range
Quote:
Originally Posted by vbasicgirl
use Print instead of Write.
casey.
Great, thanks all.