Hi there everyone. Last year I was working on an attendance prog that would give students the option of adding their birthdays. That prog would only hold one roster of students.
This is the code I use to save to a textfile.
Now the program has 6 rosters, so I was wondering. Is there a way to change the save path, to something else depending on what number is in a textbox called RosNumChosen.text?
Like could I change the line
Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo
to
if RosNumChosen.text = "1" then
Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo
end if
if RosNumChosen.text = "2" then
Open App.Path & "\StudentRosters\Roster2\StudentBdaysROSTER2\StudentBday1.txt" For Output As #iFileNo
end if
Rather than do the same sort of save code over and over in a repetitive way?
THANKS!
This is the code I use to save to a textfile.
VB Code:
Public Sub StudentBirthdaySave1() Dim sFileText As String Dim iFileNo As Integer iFileNo = FreeFile 'open the file for writing Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo 'please note, if this file already exists it will be overwritten! 'write some example text to the file Print #iFileNo, NewBDay.LBLBMonth.Caption Print #1, NewBDay.LBLBday.Caption 'close the file (if you dont do this, you wont be able to open it again!) Close #iFileNo LBLBMonth.Caption = "" LBLBday.Caption = "" BdayUpdate.Show Unload NewBDay End Sub
Now the program has 6 rosters, so I was wondering. Is there a way to change the save path, to something else depending on what number is in a textbox called RosNumChosen.text?
Like could I change the line
Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo
to
if RosNumChosen.text = "1" then
Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo
end if
if RosNumChosen.text = "2" then
Open App.Path & "\StudentRosters\Roster2\StudentBdaysROSTER2\StudentBday1.txt" For Output As #iFileNo
end if
Rather than do the same sort of save code over and over in a repetitive way?
THANKS!