For-Next Issue

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
SMcClouth
Coder
Posts: 32
Joined: Wed Jun 06, 2012 11:45 am

For-Next Issue

Post by SMcClouth »

Hey all,

I'm writing a small program in QB PDS in which I have the following code:

Code: Select all


For d = 1 To IDs
        If CU(d) = CUR Then
          CUC = CC(d)
        End if
Next
[*]CU(d) is an array containing certains IDs
[*]CUR is the main ID, we locate in the array to find CUC
[*]CUC is the ID to refere to another array, which is taken form CC(d) -> following the CU(d) list.

e.g. I have ID nr 5 and I need to find the ID for a student who is in Array2. If CU(d) = my id nr 5, then
CC(d) will have the ID for Array which then will give me the student's ID.

The thing is, I know that have a list of about 300 records and that the records CU(1-150) are ID nr 5. But instead
of starting at CU(1), it gives me CU(150).

Can someone shines his light upon this code?

Thx.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Re: For-Next Issue

Post by burger2227 »

What is IDS? The FOR loop will stop at that. Use EXIT FOR in an IF statement if you want it to exit early.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
SMcClouth
Coder
Posts: 32
Joined: Wed Jun 06, 2012 11:45 am

Re: For-Next Issue

Post by SMcClouth »

IDS is an integer which is the amount of data records (of which I have 300).
Post Reply