Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Old Aug 30th, 2007, 10:00 AM   #2
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Repost your code with line breaks so it's legible and I will take a look.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Aug 30th, 2007, 12:58 PM   #3
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
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

  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
__________________
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.
bigguy is offline   Reply With Quote
Old Aug 30th, 2007, 3:14 PM   #4
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
When you write the 2nd file are you updating the number variable with the new number from txtnumber.text? It doesn't appear so.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Aug 30th, 2007, 4:09 PM   #5
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 330
Rep Power: 3 kruptof is on a distinguished road
Quote:
Originally Posted by bigguy View Post
if I try to create a file with a duplicate employee number, it handle the error
Won't this mean that you trying to create a file that already exist, since the number is used to in the filename?

What was this error it handled?
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Aug 30th, 2007, 4:11 PM   #6
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 203
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
What I don't understand is that this has got 102 views and yet only (now 5 replies)...

Sorry for the OT nonesense...
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Aug 30th, 2007, 4:24 PM   #7
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Quote:
Originally Posted by kruptof View Post
Won't this mean that you trying to create a file that already exist, since the number is used to in the filename?

What was this error it handled?
He is saying that part of the program worked correctly. When he attempted to create a duplicate file "the error was thrown" AKA "it handle the error"

Quote:
Originally Posted by mattireland
What I don't understand is that this has got 102 views and yet only (now 5 replies)...

Sorry for the OT nonesense...
Yes that is BS, I completely agree. Usually I use the forum to recieve help and insight on my own problems, but when I see a post like this just sitting around it bothers the hell out of me that no one tries to help. It happens to me all the time.
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org

Last edited by Kilo; Aug 30th, 2007 at 4:27 PM. Reason: Added a quote...
Kilo is offline   Reply With Quote
Old Aug 30th, 2007, 10:09 PM   #8
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
I think the biggest reason no one helped was because of my damn code tags thanks to avant has now been fixed though. But yeah that EmpExists sub i have created shows the message box incase they already have a employee file with that same number. I guess it really aint an error, but sorry for the confusion.

Also kilo, about the updating this is what I am using.
File.WriteAllText(My.Application.Info.DirectoryPath & "\" & number & ".emp" << I specify it to write to number.emp

Is that kind of what your asking?
__________________
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 30th, 2007 at 10:12 PM. Reason: Forgot soemthing
bigguy is offline   Reply With Quote
Old Aug 31st, 2007, 8:57 AM   #9
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
Quote:
Originally Posted by bigguy View Post
I think the biggest reason no one helped was because of my damn code tags thanks to avant has now been fixed though. But yeah that EmpExists sub i have created shows the message box incase they already have a employee file with that same number. I guess it really aint an error, but sorry for the confusion.

Also kilo, about the updating this is what I am using.
File.WriteAllText(My.Application.Info.DirectoryPath & "\" & number & ".emp" << I specify it to write to number.emp

Is that kind of what your asking?
No not really... I meant this

number = txtnumber.text
File.WriteAllText(My.Application.Info.DirectoryPath & "\" & number & ".emp")
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote
Old Aug 31st, 2007, 1:47 PM   #10
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
Yeah I have that I just didnt post that part, cause I didnt think it would help any. But yeah all that first middle and last stuff I have.

Dim number = managercp.txtnumber.text
Should I have
Dum number As Integer = managercp.txtnumber.text.tostring?
Maybe try that
__________________
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.
bigguy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem processing file into a char array csrocker101 C++ 1 May 8th, 2007 11:50 PM
OnlineTextEditor.Com! Sane Show Off Your Open Source Projects 43 Jun 16th, 2006 8:55 AM
Writing to a file from a TSR (MASM16) Roku Assembly 2 Apr 29th, 2006 7:08 PM
After execution - Error cannot locate /Skin File? wchar Visual Basic 1 Mar 5th, 2005 9:04 PM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 4:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC