0

I've been hitting my head against a wall here trying to figure out what stupd thing I'm doing wrong. I know its right in front of me but can't grasp it and my chapter for multiforms is pathedically short. What I'm trying to accomplish is for the user to select a form NewTester from the MainForm and enter a rating from 1 to 10( 10 being the best) for two different drinks. Then Display the average rating for each drink, which drink had a higher rating, and the total number of testers in a SummaryForm.

Public Class MainForm

    Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
        
    End Sub

    Private Sub NewTesterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTesterToolStripMenuItem.Click
        'Display NewTesterForm'
        NewTesterForm.ShowDialog()

    End Sub

    Private Sub SummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryToolStripMenuItem.Click
        'Display SummaryForm'
        SummaryForm.Show()

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        'Close Program'
        Me.Close()

    End Sub

    Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click

    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        'Display AboutBox'
        AboutBox1.ShowDialog()

    End Sub
End Class
Public Class NewTesterForm
    'Module level variables'
    Friend TesterCountInteger As Integer
    Friend pruneCountInteger As Integer
    Friend appleCountInteger As Integer


    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub pruneTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub

    Private Sub appleTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub okButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim pruneRateInteger As Integer
        Dim appleRateInteger As Integer
        'Gather rating from user catch any blank spaces or non-whole numbers'
        Try
            pruneRateInteger = Integer.Parse(TextBox1.Text)
            appleRateInteger = Integer.Parse(TextBox2.Text)
        Catch ex As FormatException
            MessageBox.Show("Missing or invalid data entry.", _
            "Data entry Error", MessageBoxButtons.OK, _
            MessageBoxIcon.Information)
        End Try
        'Add to total tester count and sum all ratings'
        If Button1.Enabled = True Then
            TesterCountInteger += 1
            pruneCountInteger += pruneRateInteger
            appleCountInteger += appleRateInteger
        End If
        'Clear text for next user input'
        Button1.Enabled = True
        TextBox1.Clear()
        TextBox2.Clear()

    End Sub

    Private Sub closeButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Close form'
        Me.Close()

    End Sub
End Class
Public Class SummaryForm
    'Module level variables to add test ratings'
    Friend avgPruneDouble As Double
    Friend avgAppleDouble As Double

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

    End Sub

    Private Sub pruneTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        'Calculate and display the average rating gathered from NewTesterForm'
        avgPruneDouble = (NewTesterForm.pruneCountInteger / NewTesterForm.TesterCountInteger)
        TextBox1.Text = avgPruneDouble.ToString("N")

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click

    End Sub

    Private Sub appleTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        'Calcualte and display the average rating gathered from NewTesterForm'
        avgAppleDouble = (NewTesterForm.appleCountInteger / NewTesterForm.TesterCountInteger)
        TextBox2.Text = avgAppleDouble.ToString("N")

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub winnerTextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        'Display which drink is the winner'
        If avgPruneDouble > avgAppleDouble Then
            TextBox3.Text = "Prune Punch"
        ElseIf avgAppleDouble > avgPruneDouble Then
            TextBox3.Text = "Apple Ade"
        End If

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

    End Sub

    Private Sub testercountTextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged
        'Count of all Taste Testers'
        TextBox4.Text = NewTesterForm.TesterCountInteger

    End Sub

    Private Sub okButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Close Form'
        Me.Close()

    End Sub
End Class
1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by close_encounter
0

I figured it out all on my own. I was trying to display from the summaryform. All I had to do was format my displays in the mainform. I also added some validation if else and try/catch for the rating inputs and moved the acculators inside the try catch with if else statements as well. Thanks..I think after looking at the code all at once on the forum it was easy to tell.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.