Hi there everyone. I am working on a newer version for student attendance prog.
I have a sub that loads the list of students from the textfile to an array of label captions. Basically each line of the file goes to a separate label caption like this.
However, I just tried it. Basically The RosterNumTxt.text tells it which number from 1-6 to load. So I try 1, but I get the error BAD FILE MODE, and it highlights this line Input #iFileNo, sFileText, did I make a mistake doing this with a textfile entering as a roster number.
Thanks!!!
I have a sub that loads the list of students from the textfile to an array of label captions. Basically each line of the file goes to a separate label caption like this.
VB Code:
Public Sub LoadClassRoster() ' 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 'RosterNumTXT.Text = "1" 'Open App.Path & "\StudentRosters\Roster1\Roster1.txt" For Input As #iFileNo Open App.Path & "\StudentRosters\Roster" & RosterNumTXT.Text & "\" & "Roster" & RosterNumTXT.Text & ".txt" For Random 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 StudentNum.Text = iCount Input #iFileNo, sFileText 'show the text (you will probably want to replace this line as appropriate to your program!) AttendanceV3.SignInNameLBL(iCount).Caption = sFileText Loop 'close the file (if you dont do this, you wont be able to open it again!) Close #iFileNo End Sub
However, I just tried it. Basically The RosterNumTxt.text tells it which number from 1-6 to load. So I try 1, but I get the error BAD FILE MODE, and it highlights this line Input #iFileNo, sFileText, did I make a mistake doing this with a textfile entering as a roster number.
Thanks!!!