INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Vb6.0 - Looping from different input files

Vb6.0 - Looping from different input files

(OP)
Hello and Good day,

Public Const R = 11
Public Const P = 37
Public Const row = 1 + R + P
Public traveltime(row, row) As Double

If optKuah.Value = True Then
"C:\Users\Acer E1\Desktop\AimiSarah\Dissertation_Langkawi\Langkawi with checkBox\vb_original\kuah_time.txt " For Input As #2
Else
Open "C:\Users\Acer E1\Desktop\AimiSarah\Dissertation_Langkawi\Langkawi with checkBox\vb_original\time.txt" For Input As #2
End If

'assign travel time to an array
For i = 0 To row - 1
For j = 0 To row - 1
Input #2, traveltime(i, j)
Next j
Next i

close #2


Coding above shows run time error 62, input past end of files when I run it.the input files of kuah_time.txt and time.txt, both have data of 49*49.

which means, time for each location from 49 places.
The error won't appears if I only use on file.
However, when I added if..else.. to choose which file to carry out, it displays error 62.

kindly advise on how I can rectify it?

Thanks

RE: Vb6.0 - Looping from different input files

Try this, see what happens:

CODE --> untested

Option Explicit

...

Public Const R As Integer = 11
Public Const P As Integer = 37
Public Const row As Integer = 1 + R + P
Public traveltime(row, row) As Double
Dim i As Integer
Dim j As Integer

Private Const MyPath As String = "C:\Users\Acer E1\Desktop\AimiSarah\Dissertation_Langkawi\Langkawi with checkBox\vb_original\"

If optKuah.Value = True Then
    Open MyPath & "kuah_time.txt " For Input As #2
Else
    Open MyPath & "time.txt" For Input As #2
End If
             
'assign travel time to an array
For i = 0 To row - 1
    For j = 0 To row - 1
        If Not EOF(2) Then
            Input #2, traveltime(i, j)
        Else
            Debug.Print "I am DONE."
        End If
        Debug.Print "traveltime(" & i & ", " & j & ") is " & traveltime(i, j)
    Next j
Next i

Close #2 

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close