Hi there! I am working on a school program that will randomly pick a student to ask a question. I have a listbox called StudentList, and I am borrowing code from an older project that loaded a textfile to a bunch of label captions, but for the purpose of this prog I am using a listbox to store the names.
This was the old code
I still would like to keep the number of students in the iCount, but I can always do Studentlist.listcount, but how do I chance Attendance.StudentNameLBL(iCount).Caption to StudentList.additem so the textfile loads there? Thanks for your help!!
This was the old code
VB Code:
' 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\Roster1\Roster1.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 StudentNum.Text = iCount Input #iFileNo, sFileText 'show the text (you will probably want to replace this line as appropriate to your program!) Attendance.StudentNameLBL(iCount).Caption = sFileText Loop 'close the file (if you dont do this, you wont be able to open it again!) Close #iFileNo
I still would like to keep the number of students in the iCount, but I can always do Studentlist.listcount, but how do I chance Attendance.StudentNameLBL(iCount).Caption to StudentList.additem so the textfile loads there? Thanks for your help!!