Visual Studio - vb 控制台应用程序。我的程序保持器崩溃,代码为 0,我不知道该怎么办

Visual Studio - vb console application. my program keepr crashing with code 0 and i dont know what to do

提问人:john 提问时间:4/12/2017 最后编辑:Tim Williamsjohn 更新时间:4/12/2017 访问量:96

问:

我使用控制台。我为我的考试编写了代码,我不是很擅长,但我尝试过,无论我做什么,我都无法让程序停止崩溃。它一直在代码 0 处崩溃,我真的很沮丧,请帮我附上下面的代码

模块 Module1

Sub Main()

    Dim discount As Integer = 0
    Dim freetickets As Integer = 0
    Dim estimatedcost As Integer = 0
    Dim totalstudents As Integer = 0
    Dim coachcost As Integer = 550
    Dim entryticket As Integer = 30
    Dim name(45) As String
    Dim paidstatus(45) As Boolean
    Dim studentspaid As Integer = 0
    Dim totalcost As Integer = 0
    Dim collectedcost As Integer = 0
    Dim finalcost As Integer = 0

    Console.WriteLine("Enter Student Name")
    name(45) = Console.ReadLine()
    Console.WriteLine("has the student paid? (true/false)")
    paidstatus(45) = Console.ReadLine()

    If paidstatus(45) = True Then
        studentspaid = studentspaid + 1
        totalstudents = totalstudents + 1

    ElseIf paidstatus(45) = False Then
        totalstudents = totalstudents + 1
    End If

    totalcost = (totalstudents * 30) + (550 / totalstudents)

    If totalstudents = 45 Then



        If studentspaid = 10 Then
            freetickets = freetickets + 1
        End If


        If studentspaid = 20 Then
            freetickets = freetickets + 1
        End If



        If studentspaid = 30 Then
            freetickets = freetickets + 1
        End If


        If studentspaid = 40 Then
            freetickets = freetickets + 1
        End If



        collectedcost = (studentspaid * 30) + (550 / studentspaid)
        discount = (freetickets * 30) - (550 / studentspaid)
        finalcost = totalcost - collectedcost - discount

        If finalcost > 0 Then
            Console.WriteLine("loss of")
            Console.WriteLine(-finalcost)
        End If

        If finalcost = 0 Then
            Console.WriteLine("broken even")
        End If

        If finalcost < 0 Then
            Console.WriteLine("profit of")
            Console.WriteLine(finalcost)
        End If

    End If

End Sub

终端模块

可视化工作室

评论

0赞 Tony Dong 4/12/2017
你能尝试调试你的代码吗?
0赞 john 4/12/2017
是的,我按 strat 调试,它运行代码,执行第一步并询问姓名,然后是第二步,如果学生是否付款。 然后在该输入之后,它崩溃并显示错误消息:程序“[2040] ConsoleApp1.exe”已退出,代码为 0 (0x0)
2赞 Asons 11/26/2017
Visual Basic 的可能副本 - 我写了一些代码来循环一个程序 45 次,但它没有循环

答: 暂无答案