View Single Post
Old Sep 4th, 2007, 10:14 AM   #12
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
Fixed

As I said before, in order to save the employee information to a new file the new employee number must be stored in the number variable before you save the file. What you did was initialize your variables with the first set of values. The next employee you attempt to save will have blank values because the new values are not being stored before the save. I mailed your project back to you.

Old Code:
    ' Employee name Info
    Dim first = managercp.txtfirst.Text
    Dim middle = managercp.txtmiddle.Text
    Dim last = managercp.txtlast.Text
    ' Address Info
    Dim address = managercp.txtaddress.Text
    Dim city = managercp.txtcity.Text
    Dim state = managercp.txtstate.Text
    Dim zip = managercp.txtzip.Text.ToString
    ' Birthday
    Dim bday = managercp.txtbday.Text.ToString
    ' Home Phone
    Dim hphone = managercp.txthome.Text.ToString
    ' Cell Phone
    Dim cphone = managercp.txtcell.Text.ToString
    ' Social Security Number
    Dim ssn = managercp.txtssn.Text.ToString
    ' Employee Number + Employee File
    Dim number = managercp.txtnumber.Text.ToString
    ' Empty the Text Boxes



    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)
        ' Clear TextBoxes
        first = ""
        middle = ""
        last = ""
        address = ""
        city = ""
        state = ""
        zip = ""
        bday = ""
        hphone = ""
        cphone = ""
        ssn = ""
        number = ""
    End Sub

New Code:
    ' Employee name Info
    Dim first As String
    Dim middle As String
    Dim last As String
    ' Address Info
    Dim address As String
    Dim city As String
    Dim state As String
    Dim zip As String
    ' Birthday
    Dim bday As String
    ' Home Phone
    Dim hphone As String
    ' Cell Phone
    Dim cphone As String
    ' Social Security Number
    Dim ssn As String
    ' Employee Number + Employee File
    Dim number As String
    ' Empty the Text Boxes



    Sub Save()

        first = managercp.txtfirst.Text
        middle = managercp.txtmiddle.Text
        last = managercp.txtlast.Text
        address = managercp.txtaddress.Text
        city = managercp.txtcity.Text
        state = managercp.txtstate.Text
        zip = managercp.txtzip.Text.ToString
        bday = managercp.txtbday.Text.ToString
        hphone = managercp.txthome.Text.ToString
        cphone = managercp.txtcell.Text.ToString
        ssn = managercp.txtssn.Text.ToString
        number = managercp.txtnumber.Text.ToString

        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)
        ' Clear TextBoxes
        first = ""
        middle = ""
        last = ""
        address = ""
        city = ""
        state = ""
        zip = ""
        bday = ""
        hphone = ""
        cphone = ""
        ssn = ""
        number = ""
    End Sub
__________________
"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