Problem with transfering values from form to form

john19

New member
Joined
Jan 18, 2010
Messages
1
Programming Experience
Beginner
Im having a problem when transfering values from form to form.
Firstly I have a main menu form, click on a button to go to the dell components form. I choose the components for the computer and when i hit calculate the total is displayed in a textbox for my subtotal. When i press send it will send the sub total from the dell components form to the grand total and display it in the dell sub total in the grand total form. This part works ok, however, i go to the main menu and click on a button to go to the packardbell components form. Do the same again but when i press send, it will send the value to the grand total form in the packardbell sub total textbox but the value in the dell sub total textbox has vanished.

I have been using this website for the code. The constructor approach:
http://www.vbdotnetheaven.com/Upload.../passdata.aspx

Here is the code in the dell components form
Code:

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim frm As frmGrandTotal = New frmGrandTotal(txtDellSubTotal.Text)
Me.Hide()
frm.Show()
End Sub

Code for the packard bell components form:
Code:

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim frm As frmGrandTotal = New frmGrandTotal(txtPackardbellSubTotal.Text)
Me.Hide()
frm.Show()
End Sub

Here is the code in the grand total form. The global var is in a module.
Code:

VB.NET:
    Public Sub New(ByVal strTextBox As String)
        InitializeComponent()
        If GlobalVarComputer = 1 Then
            txtDellSubTotal.Text = strTextBox
        ElseIf GlobalVarComputer = 2 Then
            txtPackardBellSubTotal.Text = strTextBox
        ElseIf GlobalVarComputer = 3 Then
            txtCompaqSubTotal.Text = strTextBox
        ElseIf GlobalVarComputer = 4 Then
            txtHPSubTotal.Text = strTextBox
        ElseIf GlobalVarComputer = 5 Then
            txtAlienwareSubTotal.Text = strTextBox
        End If
    End Sub

Finally, the other problem im having is on the main menu form when I click on the view total button I get this error:

Here is the code for this bit
Code:

VB.NET:
    Private Sub btnViewTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewTotal.Click
        'frmGrandTotal.Show()
        Me.Hide()
    End Sub
 
Back
Top