title: Visual Studio - vb console application. my program keepr crashing with code 0 and i dont know what to do
body: <p>im using console. ive written code its for my exam and im not very good at it but ive tried and no matter what i do i cant get the program to stop crashing. it keeps crashing at code 0 and im really frustrated please help me ive attached the code below </p>
  
  <p>Module Module1</p>
  
  <pre><code>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 &gt; 0 Then
              Console.WriteLine("loss of")
              Console.WriteLine(-finalcost)
          End If
  
          If finalcost = 0 Then
              Console.WriteLine("broken even")
          End If
  
          If finalcost &lt; 0 Then
              Console.WriteLine("profit of")
              Console.WriteLine(finalcost)
          End If
  
      End If
  
  End Sub
  </code></pre>
  
  <p>End Module</p>