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

[RESOLVED] Load code looks for array element 31?

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

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

Thank you for your help. :) :)

Viewing all articles
Browse latest Browse all 21437

Trending Articles



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