案例导致空白输出

时间:2015-11-25 08:14:14

标签: vb.net

我刚刚在课堂上学习Case并且必须将它用于程序。它输出正常,直到我调用一个案例然后它返回空白。当我回收我们在课堂上使用的程序时,很多代码被注释掉了。我的变量是否有错?因为它只是在我打电话selectrecord时搞砸了。

Imports System
Imports System.IO

Module Module1
    Private ItemDescrip As String
    Private ItemNum As Integer
    Private WholeSale As Decimal
    Private MarkupCode As Integer
    Private AmtSold As Integer
    '   Calculated
    '   Assigned Fields
    Private BallNum As Integer
    ' Accumlated Totals
    '   Constants
    Private BALL_CODE_1 As Integer = 150
    Private BALL_CODE_2 As Integer = 200 > 299
    Private BALL_CODE_3 As Integer = 300 > 399
    Private BALL_CODE_4 As Integer = 400 > 499
    Private BALL_CODE_5 As Integer = 500 > 599
    Private BALL_CODE_6 As Integer = 600 > 699

    'Pagination Fields
    Private PageSize As Integer = 15
    Private LineCounter As Integer = 99
    Private PageNum As Integer = 1
    'Working Fields
    Private CurrentRecord() As String
    Private BallFile As New Microsoft.VisualBasic.FileIO.TextFieldParser("BALLFILE.txt")
    'Boolean
    Private RecordSelect As Boolean
    Sub Main()
        Call HouseKeeping()
        Do While Not BallFile.EndOfData
            Call ProcessRecords()
        Loop
        Call EndofJob()
    End Sub
    Private Sub HouseKeeping()
        Call SetDelimiterFile()
        Call ReadFile()
    End Sub
    Private Sub ProcessRecords()
        Call SelectRecord()
        'If RecordSelect Then
        Call DetailCalc()
        ' Call Accumlations()
        Call WriteDetailLine()
        'End If
        ReadFile()
    End Sub
    Private Sub EndofJob()
        'Call SummaryCalc()
        'Call OutputTotalAvg()
        Call CloseFile()
    End Sub
    Private Sub SetDelimiterFile()
        BallFile.TextFieldType = FileIO.FieldType.Delimited
        BallFile.SetDelimiters(",")
    End Sub
    Private Sub ReadFile()
        Try
            CurrentRecord = BallFile.ReadFields()
            If CurrentRecord.Length <> 5 Then
                Console.WriteLine("Line " & Join(CurrentRecord, ""))
            Else
                ItemNum = CurrentRecord(0)
                ItemDescrip = CurrentRecord(1)
                WholeSale = CurrentRecord(2)
                MarkupCode = CurrentRecord(3)
                AmtSold = CurrentRecord(4)
            End If
        Catch ex As Exception
            Console.WriteLine(ex)
        End Try
    End Sub
    Private Sub SelectRecord()
        RecordSelect = False
        If BallNum = 1 Then
            'Or BallNum = 3 Or BallNum = 5 Then
            RecordSelect = True
        End If
    End Sub
    Private Sub DetailCalc()
        'TotalPoints = Test1 + Test2 + Test3
        ' Call DetermineTestPointsByClassTime()
        ' StudentAvg = (TotalPoints / (ClassPoints * 3))
        ' Call DetermineGrade()
    End Sub
    Private Sub DetermineTestPointsByClassTime()
        Select Case ItemNum
            Case Is = 1
                BallNum = BALL_CODE_1
            Case Is = 2
                BallNum = BALL_CODE_2
            Case Is = 3
                BallNum = BALL_CODE_3
            Case Is = 4
                BallNum = BALL_CODE_4
            Case Is = 5
                BallNum = BALL_CODE_5
            Case Else
                BallNum = BALL_CODE_6
        End Select
    End Sub
    'Private Sub DetermineGrade()
    ' Select Case StudentAvg
    '  Case Is >= 0.9
    '      Grade = "A"
    '  Case Is >= 0.8
    '     Grade = "B"
    '  Case Is >= 0.7
    '     Grade = "C"
    '  Case Is >= 0.6
    '      Grade = "D"
    '   Case Else
    '       Grade = "E"

    ' End Select
    'End Sub
    'Private Sub Accumlations()
    '  TotalNumStudents += 1
    '   TotalStudentAvg += StudentAvg
    'End Sub
    Private Sub WriteDetailLine()
        If LineCounter > PageSize Then
            Call WriteHeaders()
        End If
        Console.WriteLine(ItemNum.ToString.PadRight(4) & Space(2) & ItemDescrip.ToString.PadLeft(8) & Space(2) & WholeSale.ToString.PadLeft(5) & Space(4) & MarkupCode.ToString.PadLeft(1) & Space(31) & AmtSold.ToString.PadLeft(2) &
                          Space(3) & BallNum.ToString.PadLeft(3))
        '   Console.WriteLine(Space(1) & StudentName.PadRight(10) & Space(2) & ClassTime.PadLeft(4) & Space(5) & Test1.ToString().PadLeft(3) & Space(5) & Test2.ToString().PadLeft(3) & Space(5) &
        '          Test3.ToString().PadLeft(3) & Space(6) & TotalPoints.ToString().PadLeft(3) & Space(6) & StudentAvg.ToString("P0").PadLeft(5) & Space(5) & Grade)
        LineCounter += 1
    End Sub
    Private Sub WriteHeaders()
        Console.WriteLine()
        Console.WriteLine(Space(6) & "page" & PageNum.ToString().PadLeft(3) & Space(15) & "Sales And Profit Report For")
        Console.WriteLine(Space(35) & "Throw It, Inc.")
        Console.WriteLine(Space(35) & "By Bryan Hendley")
        Console.WriteLine()
        Console.WriteLine("Item Desc" & Space(5) & "WhlSale" & Space(2) & "--Markup--" & Space(3) & "Retail" & Space(4) & "Discount" & Space(3) & "Qty" & Space(2) & "Discnt" & Space(6) & "Total")
        Console.WriteLine(Space(1) & "Num" & Space(12) & "Price" & Space(2) & "Code" & Space(3) & "Amt" & Space(4) & "Price" & Space(4) & "%" & Space(4) & "Amt" & Space(3) & "Sld" & Space(3) & "Price" & Space(3) &
                           Space(5) & "Due" & Space(3) & "Profit")
        Console.WriteLine()
        LineCounter = 1
        PageNum += 1
    End Sub
    '   Private Sub SummaryCalc()
    '   FinalAvg = TotalStudentAvg / TotalNumStudents
    '  End Sub
    ' Private Sub OutputTotalAvg()
    '    Console.WriteLine()
    '    Console.WriteLine(Space(5) & "Total Number of students processed: " & TotalNumStudents.ToString.PadLeft(7))
    '     Console.WriteLine(Space(26) & "Final Average: " & FinalAvg.ToString("P0").PadLeft(7))
    ' End Sub
    Private Sub CloseFile()
        Console.WriteLine()
        Console.WriteLine()
        Console.Write("Press ENTER to Close OutPut Window")
        Console.ReadLine()

        BallFile.Close()
    End Sub
End Module

0 个答案:

没有答案