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

Bad File Mode error?

$
0
0
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.


VB Code:
  1. Public Sub LoadClassRoster()
  2.  
  3.  
  4.  
  5.     ' THIS CODE LOADS The Students Names TO the Label Captions
  6.     Dim sFileText As String
  7.         Dim iFileNo As Integer
  8.         Dim iCount As Integer
  9.           iFileNo = FreeFile
  10.               'open the file for reading
  11.              'RosterNumTXT.Text = "1"
  12.           'Open App.Path & "\StudentRosters\Roster1\Roster1.txt" For Input As #iFileNo
  13.           Open App.Path & "\StudentRosters\Roster" & RosterNumTXT.Text & "\" & "Roster" & RosterNumTXT.Text & ".txt" For Random As #iFileNo
  14.         'change this filename to an existing file!  (or run the example below first)
  15.               'read the file until we reach the end
  16.           Do While Not EOF(iFileNo)
  17.            iCount = iCount + 1
  18.              StudentNum.Text = iCount
  19.             Input #iFileNo, sFileText
  20.               'show the text (you will probably want to replace this line as appropriate to your program!)
  21.             AttendanceV3.SignInNameLBL(iCount).Caption = sFileText
  22.           Loop
  23.               'close the file (if you dont do this, you wont be able to open it again!)
  24.           Close #iFileNo
  25. 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!!!

Viewing all articles
Browse latest Browse all 21272

Trending Articles



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