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

[RESOLVED] Bad File Mode?

$
0
0
Hello there. I have had the chance to try out some really neat software at school that helps with students morning routines, such as signing in/attendance, etc. The program will load up a student roster, and basically the students drag a picturebox with their name to the sign in box.

After they all sign in, I give the option to save the attendance list to the computer in a .txt file using this code.

VB Code:
  1. Dim arrFileName() As String
  2.     Dim i As Integer
  3.     Dim ii As Integer
  4.     Dim sFileText As String
  5.     Dim myFile As String
  6.     Dim iFileNo As Integer
  7.           iFileNo = FreeFile
  8.             myFile = App.Path & "\AttendanceLists\AttendanceList" & "- " & ClassName.Text & "_" & MonthNames.Caption & " " & DayNum.Caption & " " & Year(Now) & ".txt"
  9.     Debug.Print myFile
  10. arrFileName = Split(myFile, "\")
  11. Attendance.TXTFileName.Text = arrFileName(UBound(arrFileName))
  12.     'the output EnglishMonths(4) look something like this:
  13.  
  14.  
  15.     'the actual usage:
  16.     Open myFile For Output As #iFileNo
  17.      Print #1, Attendance.ClassName.Text
  18.      Print #1, "Absent Students Today"
  19.      Print #1, ""
  20.     For i = 0 To AbsentList.ListCount - 1
  21.         Print #1, AbsentList.List(i)
  22.     Next i
  23.     Print #1, ""
  24.     Print #1, "Present Students Today"
  25.      Print #1, ""
  26.    
  27.     For ii = 0 To PresentList.ListCount - 1
  28.         Print #1, PresentList.List(ii)
  29.     Next ii
  30.     Print #1, ""
  31.           Close #1

As you can see, the class name goes in Attendance.ClassName.Text, so when the program saves, you would end up with a txt file named something like AttendanceList- CLASSNAME_February 3 2013.txt

That is printed in the immediate at the bottom of my vb 6 screen

The actual textfile is created, but is empty with 0KB, I am getting an error saying Bad File Mode, and it will highlight the line Print #1, Attendance.ClassName.Text

Would anyone know what bad file mode means? It obviously uses the textbox because the actual file includes the text from the textbox, so I am at a loss here? :) Your help is always appreciated!!

Viewing all articles
Browse latest Browse all 21845

Trending Articles



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