Results 1 to 2 of 2

Thread: Array Work in grades project

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2004
    Posts
    1

    Array Work in grades project

    I am trying to make a program to calculate my grades in my classes this term. but I don't quite know how to use arrays yet (* i just started learning VB.net and its my first language) I just finished designing the user interface... (*see attachment)

    Any help to get this started would be great...


    Honestly, its just getting started. I have a book called... The Visual Basic.net Coach.... and i'm reading about arrays but i'm still stuck on even how to go about starting this project.... here... I start out i have to define variables... for example



    VB:
    --------------------------------------------------------------------------------
    Dim HomeworkAverage As Single
    Dim QuizAverage As Single
    Dim TestAverage As Single

    For Each Grade As Single In Homeworks
    HomeworkAverage += Grade
    Next

    HomeworkAverage /= Homeworks.Length

    For Each Grade As Single In Quizs
    QuizAverage += Grade
    Next

    QuizAverage /= Quizs.Length

    For Each Grade As Single In Tests
    TestAverage += Grade
    Next

    TestAverage /= Tests.Length

    Dim OverallAverage As Single = (5 * TestAverage + 3 * HomeworkAverage + 2 * QuizAverage) / 10
    --------------------------------------------------------------------------------



    I know its something like this, but i'm not really sure where i'm going wrong, or where to go from here.

    Another thing. If you look at the user interface, what am i suppose to do with the "add score" button... add to what? how?
    Attached Images Attached Images  

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    I'm afraid your attachment was virtually unreadable. I don't know if others have had the same result. Your main form flashes up momentarily and then disintegrates.

    I could briefly see some radio buttons and assume you use them to enter the results under each heading;

    Homework
    Quiz
    Tests.

    Because you do not necessarily know the number of results you will have to enter (assuming you intend to use the program several times during the college year) you will find it easier to use an arrayList rather than an array. Look up ArrayLists in MSDN Help.

    So delcare with formwide scope:

    VB Code:
    1. Dim arrLHomework As New ArrayList
    2. Dim arrLQuiz As New ArrayList
    3. Dim arrLTests As New ArrayList

    Add to the form

    A TextBox named txtEnterScore
    3 Labels named lblHomework; lblQuiz; lblTests

    Radio buttons for each of the three types of results e.g.
    rbHomework; rbQuiz; rbTests

    Buttons named:
    btnAddEntry; btnCalculateAverage; btnClear

    in btnAddEntry_Click event
    SelectCase Checked
    Case rbHomework
    arrLHomework.Add(txtEnterScore.Text)
    Case rbQuiz
    arrlQuiz.Add(txtEnterScore.Text)
    Case rbTests
    arrLTests.Add(txtEnterScore.Text)
    End Select

    I will leave you to calculate the averages and display them in the labels and putting in a reset button.

    If my assumptions are wrong, please correct me.

    Meanwhile, look up in MSDN Help the articles on arrays and multidimension arrays.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width