Results 1 to 7 of 7

Thread: Need help: Grade program - Constants and Functions

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Need help: Grade program - Constants and Functions

    Hey there,

    So I have this problem. I've been working tirelessly with VisualBasic 2010 on an assignment for my CS 105 class. The assignment seemed pretty straightforward: Make a program with checkboxes that calculates our grades on certain assignments. I thought I had it down, but here's the catch:

    We MUST use global constants to store the weighted grade value of assignments. And -

    We MUST use a function to calculate and display the total grade using the user's entered score on their assignment (out of 100 points).

    I worked forever on this trying different things, and eventually one warning I received locked me out of design view. I deleted all possible signs of the error, but it persisted. It's looking as if I may need to start from scratch, and I'm running out of time quickly.

    So more to the point: Could anyone help me develop a function that takes these global constants:

    'Declare Global variables
    Const lab2Grade As Decimal = 0.05
    Const lab3Grade As Decimal = 0.1
    Const lab4Grade As Decimal = 0.1
    Const lab5Grade As Decimal = 0.1
    Const exam1Grade As Decimal = 0.2
    Const exam2Grade As Decimal = 0.3
    Const finalProjGrade As Decimal = 0.15

    And using the user input through text boxes on each assignment where scores are entered out of 100, convert it into an average score that I can convert to a percent and display (Done through a button-click event)? I had it working without functions, but as functions are part of the assignment I'm forced to use them to get a decent grade, and I'm very new to them. If anyone could help, that would be fantastic.

    Thanks for reading!

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Need help: Grade program - Constants and Functions

    Are you sure that's what you're supposed to do because it's extremely poor practice. A function should be self contained. All values necessary for the completion of the function should either be contained within the function or passed in the function call. A Sub can use global constants. A function never should.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Re: Need help: Grade program - Constants and Functions

    "Edit: Might have misread what she put, granted instructions aren't clear".

    I'm certainly no expert on coding, but I've seen some completely weird things from this professor, such as giving us an example program that doesn't even work correctly.

    I might be able to declare these constants within the function, granted I'm unclear exactly on how to do it, but hopefully I can figure it out. I might lose points on her grading scale for not declaring them as global like she insisted, but if this is considered poor practice I suppose I'd only be in the right for doing so.
    Last edited by Alzecha; May 22nd, 2013 at 07:08 PM.

  4. #4
    Junior Member
    Join Date
    May 2013
    Posts
    31

    Re: Need help: Grade program - Constants and Functions

    Same exact project im working on right now. You must be in my class? lol
    Head over to the post that says "Working with Percentages" to get some help im woking on it right now

    http://www.vbforums.com/showthread.p...th-percentages

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    3

    Re: Need help: Grade program - Constants and Functions

    Wow, it appears we definitely are in the same class. Thanks so much for letting me know, I'll look over it and see if it helps me. I'm kinda in a crisis with my entire program breaking on the night before the due date, LOL.

  6. #6
    Junior Member
    Join Date
    May 2013
    Posts
    31

    Re: Need help: Grade program - Constants and Functions

    same thing happened to me last week, I thought for sure I knew exactly what I was doing and NOPE so i had to get help. No worries

  7. #7
    Junior Member
    Join Date
    May 2013
    Posts
    31

    Re: Need help: Grade program - Constants and Functions

    Has the post helped? Im currently on the write to file and read to file part and having a little trouble there now lol

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