Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21990

[RESOLVED] Load a textfile into a label caption array starting at index 0?

$
0
0
Hello there everyone!

I am working on a prog to help track student behavior. I have a textfile with the student names, and an array of label captions I am trying to load them into. It is from an earlier project where in that older project I needed to start at index 1, but this time I need to start at index 0, but am not sure what to change.

Basically I want it to start at 0, then load for index 1,2,3,etc.

Here is the modified code.
VB Code:
  1. ' THIS CODE LOADS The Students Names TO the Label Captions
  2.     Dim sFileText As String
  3.         Dim iFileNo As Integer
  4.         Dim iCount As Integer
  5.           iFileNo = FreeFile
  6.               'open the file for reading
  7.              
  8.           Open App.Path & "\StudentRosters\Roster1\Roster1.txt" For Input As #iFileNo
  9.         'change this filename to an existing file!  (or run the example below first)
  10.               'read the file until we reach the end
  11.           Do While Not EOF(iFileNo)
  12.            iCount = iCount + 1
  13.             Input #iFileNo, sFileText
  14.               'show the text (you will probably want to replace this line as appropriate to your program!)
  15.             TrafficLights.StudentNameLBL(iCount).Caption = sFileText
  16.           Loop
  17.               'close the file (if you dont do this, you wont be able to open it again!)
  18.           Close #iFileNo

I am pretty sure it has something to do with iCount = iCount + 1, but I need it to to increase, so it will load 1 line of the text file to StudentNameLBL(0). then the next line to StudentNameLBL(1), etc.

Can anyone tell me what I have to change to start at 0?

Thanks!

Viewing all articles
Browse latest Browse all 21990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>