Advertisement

04.24.2008 at 09:06PM PDT, ID: 23352637
[x]
Attachment Details

How to calculate the mean, max and min in a VB.NET program?

Asked by aspirinmornings in Visual Studio .NET 2005

Tags: Microsoft, Visual Basic .Net, 2005

Hi All,
I am trying to make a program for my class where i have to use a function to make sure the weight i enter is between 0 and 500 and a number.  I have made the function and it works, and it is set to clear the weight text box after it works, which is what the teacher said to do.

However, as different weights are entered, the counter goes up, and i need to have the max (highest) number of them all displayed and the lowest (min) displayed when analyze is clicked, as well as the mean of all the numbers entered so far.  How do i accomplish this, i attached a picture of the program as well as my code, anything is helpful.

I have tried some different things, but can't figure out a way for the program to hold the information entered so its not erased when the function completes.  ThanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
Public Class frmMain
 
    Private mItemNum As Integer = 1
 
    Private Function ValidateData() As Boolean
 
        If IsNumeric(txtWeight.Text) = False Then
            MessageBox.Show("Weight must be numeric.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtWeight.Focus()
            Return False
        End If
        If CType(txtWeight.Text, Integer) = False Then
            MessageBox.Show("Weight must be an integer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtWeight.Focus()
            Return False
        End If
        If Integer.Parse(txtWeight.Text) < 0 Or _
        Integer.Parse(txtWeight.Text) > 500 Then
            MessageBox.Show("Weight must be > 0 but < 500.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtWeight.Focus()
            Return False
        End If
        Return True
 
    End Function
 
    Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
 
        If ValidateData() = False Then
            Exit Sub
        End If
 
        txtWeight.Text = ""
        btnAnalyze.Enabled = True
 
        mItemNum = mItemNum + 1
        lblItemNumber.Text = mItemNum.ToString
 
 
    End Sub
 
    Private Sub btnAnalyze_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnalyze.Click
 
 
    End Sub
 
    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
 
        Close()
 
    End Sub
End Class
Attachments:
 
Image of Program
Image of Program
 
[+][-]04.24.2008 at 09:29PM PDT, ID: 21437057

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 09:36PM PDT, ID: 21437075

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 09:43PM PDT, ID: 21437091

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 09:52PM PDT, ID: 21437119

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 09:53PM PDT, ID: 21437122

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 09:54PM PDT, ID: 21437125

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:03PM PDT, ID: 21437151

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:09PM PDT, ID: 21437163

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:21PM PDT, ID: 21437205

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 10:26PM PDT, ID: 21437220

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2008 at 12:14AM PDT, ID: 21437520

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Studio .NET 2005
Tags: Microsoft, Visual Basic .Net, 2005
Sign Up Now!
Solution Provided By: brank20
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628