All pastes #257412 Raw Edit

Someone

public text v1 · immutable
#257412 ·published 2006-11-25 08:08 UTC
rendered paste body
Public Class Form2
    'Michael Lustfield
    'Jim Mckeown
    'CIS 251
    'Programming Assignment Ten
    'November 25, 2006
    'ML10.exe, DeuceHardware.dat
    'This program uses control breaks and minor control breaks to read
    'and proccess data from a file.
    Private Sub mnuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileExit.Click
        End
    End Sub

    Private Sub mnuHelpControlBreaksToolStrip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpControlBreaksToolStrip.Click
        Dim frmAbout As New Form4
        frmAbout.Show()
    End Sub

    Private Sub mnuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
        Dim frmHelp As New Form3
        frmHelp.Show()
    End Sub

    Private Sub mnuFileReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileReport.Click
        'Declerations
        Dim srdFile As IO.StreamReader
        Dim strLName As String = Nothing
        Dim strFName As String = Nothing
        Dim strEmployeeNum As String = Nothing
        Dim decSales As Decimal = 0
        Dim strDept As String = Nothing
        Dim Temp() As String = Nothing
        Dim strloadfile As String = Nothing
        Dim decSales3 As Decimal = 0
        Dim decSales1 As Decimal = 0
        Dim decSales2 As Decimal = 0
        Dim strCBreak As String = Nothing
        Dim strMBreak As String = Nothing
        Dim strName As String = Nothing
        'Input
        ofdFile.ShowDialog()
        strloadfile = ofdFile.FileName
        'Preprocessing
        rtbOut.Clear()
        'Header
        rtbOut.AppendText("                  Deuce Hardware, Inc." & ControlChars.NewLine)
        rtbOut.AppendText("                      Sales Report" & ControlChars.NewLine & ControlChars.NewLine)
        rtbOut.AppendText("Emp.       Name               Sales       Dept." & ControlChars.NewLine)
        rtbOut.AppendText("___________________________________________________" & ControlChars.NewLine)
        'Load File
        srdFile = IO.File.OpenText(strloadfile)
        'Processing
        Temp = srdFile.ReadLine.Split(",")
        strCBreak = Temp(2)
        strMBreak = Temp(4)
        Do
            strLName = Temp(0)
            strFName = Temp(1)
            strEmployeeNum = Temp(2)
            decSales = Temp(3)
            strDept = Temp(4)
            decSales1 = decSales
            decSales2 += decSales1

            rtbOut.AppendText(strEmployeeNum.PadRight(8, " "))
            strName = FormName(strLName, strFName)
            rtbOut.AppendText(strName)
            rtbOut.AppendText(decSales.ToString("c").PadLeft(10, " ") & "  ")
            rtbOut.AppendText(strDept & ControlChars.NewLine)

            Temp = srdFile.ReadLine.Split(",")

            If strDept <> Temp(4) Then
                rtbOut.AppendText("Total for " & strDept.PadRight(17, " ") & decSales1.ToString("c") & ControlChars.NewLine & ControlChars.NewLine)
                decSales1 = 0
            End If

            If strEmployeeNum <> Temp(2) Then
                rtbOut.AppendText("Total for " & strName.Trim(" ").PadRight(17, " ") & decSales2.ToString("c") & ControlChars.NewLine & ControlChars.NewLine)
                decSales3 += decSales2
                decSales2 = 0
            End If

        Loop Until srdFile.Peek = -1
    End Sub

    Private Function FormName(ByRef strLName, ByRef strFName)
        Dim strtemp As String
        strtemp = strLName & ", " & strFName
        strtemp = strtemp.PadRight(19, " ")
        Return strtemp
    End Function
End Class