#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    30
    Rep Power
    1

    Question Application crashes when adding values to array


    Ok, I have all my variables set up and have it set so that when I click the checkout button, it not only displays the final results(final total, sales tax amount) in the bottom textboxes, but also opens a new form. However, I cannot seem to get it to add those values to my arraylists, as it crashes with a null referenceexception whenever I try to do so. Any ideas on how to fix this?

    SignUp.vb:
    Code:
    Public Class SignUp
        Dim DailyTotal As ArrayList
        Dim TotalPeople As ArrayList
        Dim TotalTax As ArrayList
    
    
    
        Private Sub PeopleText_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles PeopleText.Leave
            If (PeopleText.Text >= 1 And PeopleText.Text >= 1 And PeopleText.Text <= 5) Then
                SubTotalText.Text = FormatCurrency("50")
    
            ElseIf PeopleText.Text >= "6" And PeopleText.Text <= "10" Then
                SubTotalText.Text = FormatCurrency("45")
    
            ElseIf PeopleText.Text > "10" Then
                SubTotalText.Text = FormatCurrency("40")
    
            End If
    
        End Sub
    
        Private Sub CityText_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles CityText.Leave
            Select CityText.Text
                Case "Mentor"
                    TaxRateText.Text = 0.07
                Case "Painesville"
                    TaxRateText.Text = 0.08
                Case "Kirtland"
                    TaxRateText.Text = 0.09
                Case Else
                    TaxRateText.Text = 0.1
            End Select
        End Sub
    
        Private Sub CheckoutButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckoutButton.Click
            
    
    
            SalesTaxText.Text = FormatCurrency(TaxRateText.Text * SubTotalText.Text)
            FinalAmountText.Text = FormatCurrency(CDec(SubTotalText.Text) + CDec(SalesTaxText.Text))
            DailyTotal.Add(FinalAmountText.Text)
            TotalPeople.Add(PeopleText.Text)
            TotalTax.Add(SalesTaxText.Text)
            InvoiceForm.Show()
            InvoiceForm.CustomerNameText.Text = FirstNameText.Text & LastNameText.Text
            InvoiceForm.GrandTotalText.Text = FormatCurrency(FinalAmountText.Text)
            InvoiceForm.TripDateText.Text = ReservationDateText.Text
        End Sub
    
        Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
            Dim ctl As Control
            For Each ctl In Controls
                If TypeOf ctl Is TextBox Then
                    ctl.Text = ""
                End If
            Next ctl
    
        End Sub
    
        Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
            Me.Close()
        End Sub
    
        
    End Class
    Last edited by darthvader45; July 9th, 2013 at 06:54 AM. Reason: Posing new question
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    3
    Rep Power
    0
    Thanks for the message. It is a very good thing for me to learn.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    30
    Rep Power
    1

    No problem


    Originally Posted by Verda7788
    Thanks for the message. It is a very good thing for me to learn.
    I'm happy to help.

IMN logo majestic logo threadwatch logo seochat tools logo