Hi there everyone. I am updating an attendance prog. I have an array of label captions from 0-30, so altogether there is room for 31 students. However, the code I am using keeps loading, and wants to load to an array index 31, but there is no 31? The textfile it loads from only has 31 lines though.
Would it have something to do with the icount?
Here is my load code
Thank you for your help. :) :)
Would it have something to do with the icount?
Here is my load code
VB Code:
Public Sub LoadRoster() ' THIS CODE LOADS The Students Names TO the Label Captions Dim sFileText As String Dim iFileNo As Integer Dim iCount As Integer iFileNo = FreeFile 'open the file for reading Open App.Path & "\StudentRosters\Roster" & RosterNumTXT.Text & "\Roster" & RosterNumTXT.Text & ".txt" For Input As #iFileNo 'change this filename to an existing file! (or run the example below first) 'read the file until we reach the end Do While Not EOF(iFileNo) iCount = iCount + 1 Input #iFileNo, sFileText 'show the text (you will probably want to replace this line as appropriate to your program!) BankV3.StudentLBL(iCount).Caption = sFileText Loop 'close the file (if you dont do this, you wont be able to open it again!) Close #iFileNo End Sub
Thank you for your help. :) :)