Multiple Forms Exception Error

  • From: "Marvin Hunkin" <startrekcafe@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 3 Feb 2009 11:39:09 +1100

Hi.
okay, got an excpetion error.
and got a friend variaible in a main form, and wanted to have the text box 
value passed to the next form, text box, but getting a null reference error.
can any one help?
will post the error, below.
and should i post the entire project below as well?
let me know if you can help.
cheers Marvin.

and will post the error message below.

cheers Marvin.

the project is for my programming book, where i have a main form, and the 
update summary information is in a separate form, all working, until i click 
the summary menu item, then get a null reference error.
and in the main form, in the main class have some thing like friend 
tbTextBox as Textbox
what am i doing wrong?
cheers Marvin.

Public Class frmUpdateSummary


    Private Sub btnCloseButton_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles btnCloseButton.Click


        'Close this form and return to main menu

        Me.Hide()
        frmVBMail.Show()


    End Sub

    Private Sub frmUpdateSummary_Activated(ByVal sender As Object, ByVal e 
As System.EventArgs) Handles Me.Activated


        'Declare Variables


        Dim intTotalWeightShipped As Integer = 0
        Dim decShippingCharge As Decimal = 0.0
        Dim tbStateTextBox As TextBox
        Dim decTotalPriceCharged As Decimal = 0.0


        'Check For shipping Charge


        If intTotalWeightShipped < 10 Then
            decShippingCharge = 1.0
        ElseIf (intTotalWeightShipped > 10) And (intTotalWeightShipped <= 
100) Then
            decShippingCharge = 3.0
        ElseIf intTotalWeightShipped > 100 Then
            decShippingCharge = 5.0


        End If


        '  Calculate Tax


        Dim decTax As Decimal = 0.0


        If tbStateTextBox.Text = "CA" Then


            decTax = decTotalPriceCharged * 0.08
        Else
            decTax = 0.0


        End If


        'Calculate Total Order


        Dim decTotalAmountWithExpenses As Decimal = 0.0


        decTotalAmountWithExpenses = decTotalPriceCharged + decTax + 
decShippingCharge


        'Format Text Boxes


        tbDollarAmountTextBox.Text = 
frmVBMail.decTotalPriceCharged.ToString("C")
        tbSalesTaxTextBox.Text = frmVBMail.decTax.ToString("C")
        tbShippingChargeTextBox.Text = 
frmVBMail.decShippingCharge.ToString("C")
        tbTotalAmountTextBox.Text = 
frmVBMail.decTotalAmountWithExpenses.ToString("C")


    End Sub
End Class

Public Class frmUpdateSummary


    Private Sub btnCloseButton_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles btnCloseButton.Click


        'Close this form and return to main menu

        Me.Hide()
        frmVBMail.Show()


    End Sub

    Private Sub frmUpdateSummary_Activated(ByVal sender As Object, ByVal e 
As System.EventArgs) Handles Me.Activated


        'Declare Variables


        Dim intTotalWeightShipped As Integer = 0
        Dim decShippingCharge As Decimal = 0.0
        Dim tbStateTextBox As TextBox
        Dim decTotalPriceCharged As Decimal = 0.0


        'Check For shipping Charge


        If intTotalWeightShipped < 10 Then
            decShippingCharge = 1.0
        ElseIf (intTotalWeightShipped > 10) And (intTotalWeightShipped <= 
100) Then
            decShippingCharge = 3.0
        ElseIf intTotalWeightShipped > 100 Then
            decShippingCharge = 5.0


        End If


        '  Calculate Tax


        Dim decTax As Decimal = 0.0


        If tbStateTextBox.Text = "CA" Then


            decTax = decTotalPriceCharged * 0.08
        Else
            decTax = 0.0


        End If


        'Calculate Total Order


        Dim decTotalAmountWithExpenses As Decimal = 0.0


        decTotalAmountWithExpenses = decTotalPriceCharged + decTax + 
decShippingCharge


        'Format Text Boxes


        tbDollarAmountTextBox.Text = 
frmVBMail.decTotalPriceCharged.ToString("C")
        tbSalesTaxTextBox.Text = frmVBMail.decTax.ToString("C")
        tbShippingChargeTextBox.Text = 
frmVBMail.decShippingCharge.ToString("C")
        tbTotalAmountTextBox.Text = 
frmVBMail.decTotalAmountWithExpenses.ToString("C")


    End Sub
End Class


so the excpetion error is at line 46.
can any one help?

E-mail: startrekcafe@xxxxxxxxx
MSN: sttartrekcafe@xxxxxxx
Skype: startrekcafe
We Are The Borg! You Will Be Assimilated! Resistance Is Futile!
Star Trek Voyager Episode 68 Scorpian Part One
E-mail: startrekcafe@xxxxxxxxx
MSN: sttartrekcafe@xxxxxxx
Skype: startrekcafe
We Are The Borg! You Will Be Assimilated! Resistance Is Futile!
Star Trek Voyager Episode 68 Scorpian Part One 


__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts:

  • » Multiple Forms Exception Error - Marvin Hunkin