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

[RESOLVED] Changing an open path for saving depending on the number in a textbox?

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

VB Code:
  1. Public Sub StudentBirthdaySave1()
  2.   Dim sFileText As String
  3.     Dim iFileNo As Integer
  4.       iFileNo = FreeFile
  5.           'open the file for writing
  6.       Open App.Path & "\StudentRosters\Roster1\StudentBdaysROSTER1\StudentBday1.txt" For Output As #iFileNo
  7.     'please note, if this file already exists it will be overwritten!
  8.           'write some example text to the file
  9.       Print #iFileNo, NewBDay.LBLBMonth.Caption
  10.       Print #1, NewBDay.LBLBday.Caption
  11.           'close the file (if you dont do this, you wont be able to open it again!)
  12.       Close #iFileNo
  13.      
  14. LBLBMonth.Caption = ""
  15. LBLBday.Caption = ""
  16.  
  17. BdayUpdate.Show
  18. Unload NewBDay
  19. 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!

Viewing all articles
Browse latest Browse all 21243

Trending Articles



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