[RESOLVED] What am I missing?
I am currently taking VB.net classes at school. I have an assignment due soon. I feel like I have all the code. But I am missing something. Sould I get a little help as to what I am missing? The problem that I am having is that I can't get my data from the main form to the summary form. It keeps saying that I have not declared the value. But if you notice on my main form, I have declared them as "Friend" which should make it possible to cross forms. Am I not correct?
Please advise. Thanks
Here is my main form code.
Code:
'Program Name: Test Taster
'Programmer: Daniel Davis
'Date: March 2007
'Description: This is a program created to run a taste test to see which drink take the best.
Public Class newtester
'Declare value
Friend ttesters As Decimal
Friend appleamount As Decimal
Friend pruneamount As Decimal
Friend appleaverage As Decimal
Friend pruneaverage As Decimal
Friend applerate As Decimal
Friend prunerate As Decimal
Friend winner As String
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
taste.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' testers
ttesters += 1
'Apple Test
With Me
Try
'apple interger
applerate = Decimal.Parse(.TextBox1.Text)
If applerate < 10 Then
appleamount += applerate
appleaverage = appleamount \ ttesters
End If
'catch errors for apple
Catch TextEX As FormatException
MessageBox.Show("Must have a number between 1 and 10.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
With .TextBox1
.Focus()
.SelectAll()
End With
End Try
End With
'Prune Test
With Me
Try
'prune interger
prunerate = Decimal.Parse(.TextBox2.Text)
If prunerate < 10 Then
pruneamount += prunerate
pruneaverage = pruneamount \ ttesters
End If
'catch errors for prune
Catch TextEX As FormatException
MessageBox.Show("Must have a number between 1 and 10.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
With .TextBox1
.Focus()
.SelectAll()
End With
End Try
'winner
If appleaverage = pruneaverage Then
winner = "Both"
ElseIf appleaverage > pruneaverage Then
winner = "appleaverage"
Else
winner = "Pruneaverage"
End If
'clear boxes
.TextBox1.Clear()
.TextBox2.Clear()
.TextBox1.Focus()
End With
End Sub
End Class
Here is my summary form.
Code:
Public Class summary
Dim ttesters As Decimal
Dim appleaverage As Decimal
Dim pruneaverage As Decimal
Dim winner As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'get date from newtester form
With Me
'number of tasters
.TextBox1.Text = ttesters.newtester.tostring("D")
'average apples
.TextBox2.Text = appleaverage.newtester.tostring("D")
'average prunes
.TextBox3.Text = pruneaverage.newtester.tostring("D")
'winners
.TextBox4.Text = winner.newtester.tostring()
End With
End Sub
End Class