View Single Post
Old Aug 18th, 2007, 4:17 AM   #1
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
Need Help with Writing to File

Hey I need some help. I cant figure out whats going on. I'm working on a Restaurant Management System, and I can create an employee, but then when I try to create another after I created one, it wont work. My Post Tools aint working so I'm gonna wing it on the CODE Tags. So sorry if it's messy. Maybe big_k can wrap em up till I figure out my problem. Here is the code that saves the employee info to file, and the code to show a message box if that employee number file already exists.
 Sub Save()         File.WriteAllText(My.Application.Info.DirectoryPath & "\" & number & ".emp", _         "-Employee Name Info-:" + vbCrLf _         & first + " " & middle + " " & last + vbCrLf _         & "-Employee Address Info-:" + vbCrLf _         & address + vbCrLf & city + vbCrLf & state + vbCrLf & zip + vbCrLf _         & "-Employee Info-:" + vbCrLf _         & bday + vbCrLf & hphone + vbCrLf & cphone + vbCrLf _         & "-Employee Social Security Number-:" + vbCrLf _         & ssn)         managercp.txtfirst.Text = ""         managercp.txtmiddle.Text = ""         managercp.txtlast.Text = ""         managercp.txtaddress.Text = ""         managercp.txtcity.Text = ""         managercp.txtstate.Text = ""         managercp.txtzip.Text = ""         managercp.txtbday.Text = ""         managercp.txthome.Text = ""         managercp.txtcell.Text = ""         managercp.txtssn.Text = ""         managercp.txtnumber.Text = ""     End Sub      Sub EmpExists()         MsgBox("Employee File with that number already exists. Please specify a new number, or delete the existing Employee File.", _         MsgBoxStyle.Critical, "Employee File Error")     End Sub
Here is my code for the Save Employee Button:
  Private Sub save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save.Click         If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath & "\" & txtnumber.Text & ".emp") Then             Employee.EmpExists()         Else             Employee.Save()         End If     End Sub
Like I said everything would work, if I only wanted to create one employee file. But it wont let me write to another file. When I click save, it erases the text boxes, and if I try to create a file with a duplicate employee number, it handle the error. It just wont create the file. I typed in my info for all the info i needed, clicked save, the text was "" in the textboxes, but no file was created. Am I missing somehtign in my code, guess I've been looking at it for the past hour and a half trying to see it, but i don't. Either I'm tired, or I can't program. I'll let yall be the judge of that. But just help me, if ya can. Thanks
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain

Destruction leads to a very rough road, but it also breeds creation.

Last edited by bigguy; Aug 18th, 2007 at 4:21 AM. Reason: Trying to fix the CODE
bigguy is offline   Reply With Quote