CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Posts
    4

    PLEASE, VERY VERY URGENT

    Please I need some help
    I have been working and trying to finish this project for almost 2 weeks, I think that our teacher don’t have any idea of what teach in English means and the meaning of teaching itself. This man is giving us a lot of work to do, we only have a 10 week of experience and only 8 project, I think that’s the reason why I don’t know how to complete successfully this project and why It’s making me to loose my mind.
    I’ll give you everything I have done so far, and maybe with your experience you can help me to complete the project and send me something that can work properly.
    YOU CAN MAKE MY LIFE EASIER.
    This is what the Non-common sense teacher is asking me to do:
    I hope you understand what he wants “I’ll give you some tips after his assignment”


    ASSIGNMENT
    1. Create a project to process payroll information.
    2. Project has to use at least 3 forms: Payroll form, DataEntry form and Salary form (feel free to add other forms and standard modules.)
    3. Create a sequential file and call it Employee. Each record will contain fields for first name, last name, hourly pay rate and amount earned. Starting the project will load the employee data into an array of user﷓defined types from the sequential file.
    4. DataEntry form allows adding new employee to the file and printing the list of all Ace Industries Inc employees and their rates. (Supposed all of them have different first names ).
    5. Salary form retrieves salary information including first name, last name, pay rate, worked hours, overtime and salary. Overtime counts as worked hours over 40. Employees receive for overtime time﷓and﷓a﷓half pay. The user has a choice to include salary information in the report or ignore it.
    6. Payroll Form
    a) Allows switching to the DataEntry form.
    b) Allows selecting any employee
    c) Allows finding any employee using employee first name
    d) Allows calculating of a salary and printing report.
    7. Add to the Payroll form FindPay command button or menu command for calculating salary. It has to be accessible only after selecting any employee. Use InputBox to enter worked hour's information.
    8. Printing report should contain the list of first and last names, worked hours and overtime hours, pay rate, salary and total amount earned for all employees.
    9. First name, last name, hourly pay rate and amount earned have to be automatically saved in the Employee file.
    10. For self-checking use this table:

    Employee Name Hours Worked Hours Overtime Pay rate Amount Earned
    Janice Jones 40 0 5.25 210.00
    Chris O’Connell 35 0 5.35 187.25
    Karen Fish 45 5 6.00 285.00
    Tom Winn 42 2 5.75 247.25
    Totals 162 7 929.50

    I found a URL related to this assignment, that can be a bad copy of what he’s trying to do, maybe you’ll understand better reading this site:
    http://www.siue.edu/~dbock/cmis142/vbasgn10_2.htm
    The assignment is similar, if you can help me with any of them I’ll appreciate

    This is what I have done and what people try to help me with, but I still don’t understand
    =================
    Help
    =======================
    Private Sub mnuFileOpen_Click()
    Dim NumRecs, i As Integer
    Dim S As String

    Close
    With CMDialog1
    .Filter = "Data File|*.lst"
    .InitDir = App.Path
    .DefaultExt = "*.lst"
    .DialogTitle = "Open File"
    .Action = 1
    DATAFILE = .Filename
    TITLEFILE = .FileTitle
    End With

    If DATAFILE = "" Then Exit Sub

    DataFileNum = FreeFile
    Open DATAFILE For Random As #DataFileNum Len = Len(Entry)

    ListOfNames.Clear
    Call ClearFields
    NumRecs = LOF(DataFileNum) / Len(Entry)

    For i = 1 To NumRecs
    Get #DataFileNum, i, Entry

    If Not Entry.Deleted Then
    S$ = Trim$(Entry.Company) ''+ ", " + Trim$(Entry.CName)
    ListOfNames.AddItem S$
    ListOfNames.ItemData(ListOfNames.NewIndex) = i
    End If
    Next

    ShowButtons
    frmMain.Caption = "Contact Manager v.2.0 - " & TITLEFILE
    lblCount.Caption = "Record: " & (ListOfNames.ListIndex + 1) & " of " & ListOfNames.ListCount
    txtDateTime.ToolTipText = "Double Click to enter present Date/Time"

    If ListOfNames.ListCount > 0 Then ListOfNames.ListIndex = 0


    Dim NEWDATAFILE As String
    Dim NEWDATAFILENUM As Integer
    Dim NumRecs, i As Integer

    ''============ Don't need it anymore ========
    If DATAFILE = "" Then
    MsgBox "There are no data to save on disk!", 64
    Exit Sub
    End If
    ''=========================================
    With CMDialog1
    .Filter = "Data File|*.lst"
    .InitDir = App.Path
    .DefaultExt = "*.lst"
    .DialogTitle = "Save As ..."
    .Action = 2
    NEWDATAFILE = .Filename
    TITLEFILE = .FileTitle
    End With

    If NEWDATAFILE = "" Then Exit Sub

    NEWDATAFILENUM = FreeFile
    Open NEWDATAFILE For Random As #NEWDATAFILENUM Len = Len(Entry)

    NumRecs = LOF(DataFileNum) / Len(Entry)

    For i = 1 To NumRecs
    Get #DataFileNum, i, Entry

    If Not Entry.Deleted Then
    Put #NEWDATAFILENUM, , Entry
    End If
    Next

    ShowButtons
    frmMain.Caption = "Contact Manager v.2.0 - " & TITLEFILE
    lblCount.Caption = "Record: " & (ListOfNames.ListIndex + 1) & " of " & ListOfNames.ListCount
    ''======================================
    ''Update the list of the most recently opened files
    '' UpdateFileMenu (NEWDATAFILE)
    ''======================================
    Close

    DATAFILE = NEWDATAFILE
    DataFileNum = FreeFile

    Open DATAFILE For Random As #DataFileNum Len = Len(Entry)

    If ListOfNames.ListCount > 0 Then ListOfNames.ListIndex = 0

    End Sub


    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Next Help
    _____

    1) You can store and load an *entire* array with just one pass.
    eg:

    dim ff as integer
    ff = freefile
    open "worker.dat" for binary as #ff
    put #ff,1,NewWorker
    close #ff

    This will save all 50 elements of NewWorker to a binary file.

    dim ff as integer
    ff = freefile
    open "worker.dat" for binary as #ff
    get #ff,1,NewWorker
    close #ff

    This will load all 50 elements into NewWorker().

    2) I suggest you separate the saving routines from the rest. Forget about saving and loading and just work on adding data to the array. Then you can add the save and load routines to the form load and unload events. Or maybe some kind of button event.

    3) Before you load the list control, you should clear it.


    dim s as string

    dim i as integer


    list1.clear

    for i = 0 to 50

    s=trim$(newworker(i).lname)

    if len(s) then

    list1.additem trim$(newworker(i).fname) & " " & s

    else

    exit for

    endif

    next i



    "I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder

    ================================================================ Next Help ==============================================================
    Several things to consider.

    General Declarations:
    You are limiting your NewWorkers array to only 50 workers. Make a module and put the type and array declarations in it like:

    Public Type worker
    FName As String * 15 ' only 15 characters
    LName As String * 15 ' only 15 characters
    End Type

    Public NewWorkers() as Worker

    Then, when you add to the NewWorkers Array use the following code

    Redim Preserve NewWorkers(UBound(NewWorkers)+1)
    NewWorkers(UBound(NewWorkers)).FName = txtFirst.Text

    This will not limit your Array to 50

    Add Procedure:
    You are using NewWorker(3) which just replaces the third Item in the NewWorker array
    Again.. use:
    Redim Preserve NewWorker(UBound(NewWorker)+1)
    NewWorker(UBound(NewWorker)).FName = txtFirst.Text

    I dont think you want txtFirst.UBound try txtFirst.Text

    Input Procedure:
    First of all.. you want to Redim your array here...to clear it before you start writing to it again. This is important if the number of records has changed.

    Redim NewWorkers(0) 'Notice there is no preserve here

    You also want to clear your listbox otherwise you just continue to add to it.

    List1.Clear

    Also.. be aware that you will have to redim your array before every addition to the array if you use the dynamic array method I suggest.


    Note:
    Re Dimensioning the array is not the fastest method because it does require the redimension to take place before every addition. But it is safe in that you will never run into errors with users trying to add more records than the dimensioned limit of the array.
    So if speed is not a concern.. it should work fine.

    Good Luck
    Joe
    =============================================================================================================================== Next Help ======================
    I am using this code and it work very fine and good luck

    ‘ RstTable : it mean record set

    If rsttable.RecordCount > 0 Then ‘check if you have data in your table to don’t get error
    rstTable.MoveLast
    Rcount = rstTable.RecordCount
    rstTable.MoveFirst
    For rNo = 1 To Rcount
    ComboName.AddItem rsttable.Fields(FiledName) Or List name
    ComboName.ItemData(ComboName.NewIndex) = rsttable.Fields(FiledCode)
    rstTable.MoveNext
    Next rNo
    ' rstTable.MoveFirst
    End If
    rstTtable.Close


    Next Help
    Say you had an array of 10. In order to save it to a text file you would simply do the following:

    Open "C:\mytext.txt" For Output as #1
    For i = 0 To 9
    Print #1, myarray(i)
    Next i
    Close #

    that would save the array to the C:\mytext.txt file. That will print each value on a separate line.
    In order to get these values back, you would do the following:

    Open "C:\mytext.txt" For Input as #1
    For i = 0 To 9
    Line Input #1, myvalue
    myarray(i) = myvalue
    Next i
    Close #1

    Hope this helps. If you need anymore help, just reply back to this thread.

    Knows a little about a lot

    Another way would be to just save the whole array, rather than each element one by one. eg:

    Dim ff%

    ff% = FreeFile

    Open "c:\test.dat" For Binary As #ff%

    Put #ff%, 1, mainarray

    Close #ff%





    and

    Dim ff%

    ff% = FreeFile

    Open "c:\test.dat" For Binary As #ff%

    Get #ff%, 1, mainarray

    Close #ff%




    If you want me to send you any attachments with any of my files, I’ll send it right away.
    I need to finish the project by next Thursday, but I don’t really care, I just want to learn from you, because it’s clear that I can not learn from my teacher.
    Send me any file to this e-mail
    [email protected]

    Thankx
    Angelina Tino




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: PLEASE, VERY VERY URGENT

    It is a lot of work. Better you do it as it seems you need some exercise (do not take this the hard side: I too may need exercises, only not yours...). Note that teacher asked for a sequential file. So, you should not use binary or random access opening it, nor use a DB ("recordset") even if you could use Ado (it sounds like cheating, you know...)


    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured