How would I calculate overtime pay? - vba

I'm new to Visual Basics and I need some help.
I need to calculate the overtime pay into the gross pay.
Here is my whole code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Assigns integer and decimals'
Dim intHoursWorked As Integer
Dim decPayPerHour As Decimal
Dim decGrossPay As Decimal
Dim decTax As Decimal
Dim decNetPay As Decimal
'Conversions'
If IsNumeric(Me.HoursWorked.Text) Then
intHoursWorked = Convert.ToInt32(Me.HoursWorked.Text)
If IsNumeric(Me.txtPPH.Text) Then
decPayPerHour = Convert.ToDecimal(Me.txtPPH.Text)
End If
End If
'Hours worked + overtime'
If intHoursWorked > 48 Then
MsgBox("You have exceeded your maximum hours")
Me.HoursWorked.Text = ""
Me.lblNetPay.Text = ""
Me.lblGrossPay.Text = ""
Me.lblTax.Text = ""
ElseIf intHoursWorked < 23 Then
MsgBox("You must enter at least 23 hours")
' Add time and a half for overtime
ElseIf decGrossPay = decGrossPay + (decGrossPay - 40) * 0.5 Then
End If
'Pay per hour'
If decPayPerHour < 14.25 Then
MsgBox("You must enter a value above $14.25")
ElseIf decPayPerHour > 100 Then
MsgBox("You must enter a value lower than $100")
Else
If Me.radSingleRate.Checked = True Then
decTax = 0.205D
ElseIf Me.radFamilyRate.Checked = True Then
decTax = 0.15D
End If
End If
'Calculations for Gross, Tax, and Netpay'
decGrossPay = intHoursWorked * decPayPerHour
decTax = intHoursWorked * decPayPerHour * decTax
decNetPay = decGrossPay - decTax
Me.lblGrossPay.Text = decGrossPay.ToString("C")
Me.lblNetPay.Text = decNetPay.ToString("C")
Me.lblTax.Text = decTax.ToString("C")
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.txtName.Focus()
Me.radSingleRate.Checked = True
Me.lblTax.Text = ""
Me.lblGrossPay.Text = ""
Me.lblNetPay.Text = ""
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
' Clears all inputs '
Me.txtName.Text = ""
Me.HoursWorked.Text = ""
Me.txtPPH.Text = ""
Me.lblGrossPay.Text = ""
Me.lblTax.Text = ""
Me.lblNetPay.Text = ""
Me.radSingleRate.Checked = True
Me.radFamilyRate.Checked = False
Me.txtName.Focus()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' Closes Application '
Me.Close()
End Sub
End Class
I can't figure out what code I should be typing into my code to have it calculate the gross pay. The overtime should be automatically calculated by the program if a number over 40 hours worked is inputted by the user. Overtime is time and a half.

I think you are after something like this?
Select Case intHoursWorked
Case Is > 48
MsgBox ("You have exceeded your maximum hours")
Case Is < 23
MsgBox ("You must enter at least 23 hours")
Case 40 To 48
decGrossPay = decGrossPay * 5
Case Else
'Add code for any other scenarios if required.
End With
Edit, not really sure how you are calculating the pay. Don't you need a figure for the regular hourly rate? If so, maybe something like this. Can't test because it's only partial code and just a guess.
Select Case intHoursWorked
Case Is > 48
MsgBox ("You have exceeded your maximum hours")
Case Is < 23
MsgBox ("You must enter at least 23 hours")
Case 40 To 48
decGrossPay = hourlyrate * 40 + ((intHoursWorked - 40) * (hourlyrate * 1.5))
Case Else
decGrossPay = hourlyrate * intHoursWorked
End With

This part got problem as you did not consider the hours between 24 ~ 48:
ElseIf intHoursWorked < 23 Then
MsgBox("You must enter at least 23 hours")
' Add time and a half for overtime
ElseIf decGrossPay = decGrossPay + (decGrossPay - 40) * 0.5 Then
End If
Should it work if you amend the code as following, so that if the worker work more than 24 but less than 40 hours, they only get basic hours, when they work more than 40 hours, they will get basic + OT, although I did not go through the remaining part and i am consider the decGrossPay is total hours to be paid:
ElseIf intHoursWorked < 23 Then
MsgBox("You must enter at least 23 hours")
' Add time and a half for overtime
ElseIf intHoursWorked > 40 and intHoursWorked <= 48 Then
decGrossPay = 40+ ((intHoursWorked - 40) *0.5 )
else decGrossPay = 40
End If

Related

How to repeat a timer that ends with a message box?

The purpose of the program is to remind the user to take a break every 30 minutes. The timer also allows the user to input how often to remind them. The countdown works only once when it reaches zero, however, l want to repeat the process three times. Dice images are placeholders. Sorry for any rookie errors.
Here is the code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If lblHrs.Text = "0" And lblMin.Text = "0" And lblSec.Text = "0" Then
dice1 = Int(Rnd() * 6 + 1)
Select Case dice1
Case "1"
DiceRoll1.Image = My.Resources._1
Case "2"
DiceRoll1.Image = My.Resources._2
Case "3"
DiceRoll1.Image = My.Resources._3
Case "4"
DiceRoll1.Image = My.Resources._4
Case "5"
DiceRoll1.Image = My.Resources._5
Case "6"
DiceRoll1.Image = My.Resources._6
End Select
Timer1.Enabled = False
End If
Dim seconds As Double
Dim minutes As Double
Dim hours As Double
Double.TryParse(lblSec.Text, seconds)
Double.TryParse(lblMin.Text, minutes)
Double.TryParse(lblHrs.Text, hours)
If seconds = 0 And minutes <> 0 Then
lblSec.Text = 59
lblMin.Text = minutes - 1
ElseIf seconds > 0 Then
lblSec.Text = seconds - 1
End If
If minutes = 0 And hours <> 0 Then
lblMin.Text = 59
lblHrs.Text = hours - 1
End If
Dim Msg, Style, Title
Msg = "Time to rest and exercise." ' Define message.
Style = vbOKOnly + vbInformation ' Define buttons.
Title = "Rest reminder" ' Define title.
' Display message.
MsgBox(Msg, Style, Title)
End Sub
This is not a full answer to your question but I wanted to post a chunk of code so a comment was not a good option. This class will help you if you are trying to implement a countdown:
Public Class CountdownStopwatch
Inherits Stopwatch
Public Property Period As TimeSpan
Public ReadOnly Property Remaining As TimeSpan
Get
Dim timeRemaining = Period - Elapsed
Return If(timeRemaining > TimeSpan.Zero, timeRemaining, TimeSpan.Zero)
End Get
End Property
Public ReadOnly Property IsExpired As Boolean
Get
Return Elapsed >= Period
End Get
End Property
End Class
It's basically a Stopwatch with extra countdown functionality. For instance, if you want to do something for 10 minutes then you can do this:
myCountdownStopwatch.Period = TimeSpan.FromMinutes(10)
myCountDownStopwatch.Restart()
In the Tick event of your Timer, you can display the time remaining and prompt the user when time expires like this:
timeReaminingLabel.Text = myCountdownStopwatch.Remaining.ToString("m\:ss")
If myCountdownStopwatch.IsExpired Then
myTimer.Stop()
myCountdownStopwatch.Stop()
myCountdownStopwatch.Reset()
'Prompt user here.
End If

I HAVE BEEN OVER THIS GOD KNOWS HOW MANY TIMES, WHAT IS WRONG WITH IT? (TICKET MACHINE) NO ERRORS ON VS), i think the top few line may not work

I have been looking over this for the last couple of days and personally I am not to keen on VB, the tab is loading up but I am not getting an answer?
Private Sub Button1_click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Age As Double
Dim seatgrading As Double
Dim Cardaddition As Single
Dim Memberdiscount As Single
Dim installments As Double
Dim totalcost As Double
Dim eachpayment As Integer
Dim total As Single
Dim price As Single
Dim Subtotal As Single
Age = CBOAge.Text
If RBFootball.Checked = True And Age = rbChild.Checked Then
price = 275
ElseIf RBFootball.Checked = True And Age = rbAdult.Checked Then
price = 450
ElseIf RBFootball.Checked = True And Age = rbOAP.Checked Then
price = 295
End If
If RBRugby.Checked = True And Age = rbChild.Checked Then
price = 85
ElseIf RBRugby.Checked = True And Age = rbAdult.Checked Then
price = 175
ElseIf RBRugby.Checked = True And Age = rbOAP.Checked Then
price = 105
End If
' Seat Grades
If RBG1.Checked = True Then
seatgrading = 150
ElseIf RBG2.Checked = True Then
seatgrading = 120
ElseIf RBG3.Checked = True Then
seatgrading = 87.5
End If
total = price + seatgrading
MemberDiscount = installments
If RBBronze.Checked = True Then
MemberDiscount = total * 0.08
ElseIf RBSilver.Checked = True Then
MemberDiscount = total * 0.09
ElseIf RBGold.Checked = True Then
`Cardaddition` = total * 0.025
End If
If RBCard.Checked = True Then
Cardaddition = Subtotal = 0.025
End If
If installments = True Then
installments = total * 0.0375
total = totalcost + installments
eachpayment = totalcost / 12
For count = 1 To 12
installments = installments & "payment" & "is" & Format(eachpayment, "currency") & vbCrLf
Next
End If
total = Subtotal - MemberDiscount + Cardaddition
total = Format(totalcost, "currency")
End Sub
This answer is perhaps more of a way to show you how to get to the code you need than a complete answer.
When dealing with money, it is best to use the Decimal type instead of Single or Double, otherwise the pennies can go wrong after a calculation or two.
You can have an If statement inside another If statement, which can sometimes make for less typing and/or easier reading.
I can't see a need for the age variable because there are already radiobuttons for child/adult/OAP.
The way of calculating the final total price was not clear to me, so I moved some things around into what may or may not be the correct order.
Perhaps the installments variable is meant to be a checkbox for if the payments are going to be taken monthly - I assumed that is the case.
I couldn't see where the results are being presented to the user, so I used MessageBox.Show - I'm sure you will be able to adapt it to how you want to show the total etc.
Private Sub Button1_click(sender As Object, e As EventArgs) Handles Button1.Click
' What I think the variable types are:
' Dim rbChild, rbAdult, rbOAP As New RadioButton
' Dim rbFootball, rbRugby As New RadioButton
' Dim rbG1, rbG2, rbG3 As New RadioButton
' Dim rbBronze, rbSilver, rbGold As New RadioButton
' Dim cbCard As New CheckBox
' Dim cbInstallments As New CheckBox
Dim price As Decimal
If rbFootball.Checked Then
If rbChild.Checked Then
price = 275
ElseIf rbAdult.Checked Then
price = 450
ElseIf rbOAP.Checked Then
price = 295
End If
End If
If rbRugby.Checked Then
If rbChild.Checked Then
price = 85
ElseIf rbAdult.Checked Then
price = 175
ElseIf rbOAP.Checked Then
price = 105
End If
End If
Dim seatgrading As Decimal
If rbG1.Checked Then
seatgrading = 150
ElseIf rbG2.Checked Then
seatgrading = 120
ElseIf rbG3.Checked Then
seatgrading = 87.5D
End If
Dim subtotal As Decimal = price + seatgrading
Dim memberDiscount As Decimal
If rbBronze.Checked Then
memberDiscount = subtotal * 0.08D
ElseIf rbSilver.Checked Then
memberDiscount = subtotal * 0.09D
ElseIf rbGold.Checked Then
memberDiscount = subtotal * 0.025D
End If
Dim cardSurcharge As Decimal
If cbCard.Checked Then
cardSurcharge = subtotal * 0.025D
End If
Dim total As Decimal = subtotal - memberDiscount + cardSurcharge
If cbInstallments.Checked Then
Dim installmentSurcharge = total * 0.0375D
total = total + installmentSurcharge
Dim eachpayment As Decimal = total / 12
MessageBox.Show("Monthly payment is " & eachpayment.ToString("C"))
End If
MessageBox.Show("Total payment is " & total.ToString("C"))
End Sub

if, elseif, searching, comparison, greater, smaller

I have this code on VB. I get no syntax error but when running and testing the numbers i get "number is not valid" or a wrong answer. Would you please help me what is wrong with this code? Thank you.
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox2.Text = ""
Dim Num As Integer
Dim str As String
str = TextBox1.Text
Num = Integer.Parse(str)
If Num >= 100 And Num <= 199 Then
TextBox2.Text = "Basement"
ElseIf Num >= 200 And Num <= 500 And Num >= 900 Then
TextBox2.Text = "Main Floor"
ElseIf Num <= 700 And Num >= 501 And Num >= 750 And Num <= 900 Then
TextBox2.Text = "Upper Floor"
ElseIf Num <= 750 And Num >= 700 Then
TextBox2.Text = "Archives"
Else
TextBox2.Text = "Number is not valid"
End If
End Sub
This is impossible
ElseIf Num >= 200 And Num <= 500 And Num >= 900 Then
Here you are asking that a number be greater-equal than 200 (ok), lower-equal than 500 (ok) AND greater-equal than 900 (not ok since you already asked for a number lower-equal than 500). A number can't both be lower than 500 and greater than 900.
Without having the requirements, it's hard to know what your if statement should look like. I would suggest you run through your code manually "on paper" or start with one if statement at a time instead of writing all of them.
I would not mix to many checks in one line as it can get confusing.
Do somthing like this:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
TextBox2.Text = ""
Dim Num As Integer
Dim str As String
str = TextBox1.Text
Num = Integer.Parse(str)
If Num >= 100 And Num <= 199 Then
TextBox2.Text = "Basement"
ElseIf Num >= 200 And Num <= 500 Then
TextBox2.Text = "Main Floor"
ElseIf Num >= 501 And Num <= 700 then
TextBox2.Text = "Upper Floor"
ElseIf Num ..... and so on
Else
TextBox2.Text = "Number is not valid"
End If
End Sub
Also it's good practice to name your TextBox controls and any other controls:
textbox1 could be something like txtfloornumber
textbox2 could be something like txtfloorname
This makes coming back to your code later in life easier.

Limiting the range of values allowed in multiple textboxes

For my current assignment, I've been asked to create a form to allow customers to enter desired quantities of shoes in a textbox and then total the cost in a second textbox. However, the customer cannot purchase more than 3 of any one particular shoe. I attempted to do the first two shoes in the code below but am running into issues once I added the code for the second model.
Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
Dim qntyClassy, qntyHigh As Double
txtQntyClassy.Text = qntyClassy
txtQntyHigh.Text = qntyHigh
If 0 < Int(txtQntyClassy.Text) And Int(txtQntyClassy.Text) < 4 Then
txtTotalClassy.Text = FormatCurrency(txtQntyClassy.Text * 43)
txtQntyClassy.Text = Int(txtQntyClassy.Text)
Else
MsgBox("Enter a quantity no greater than 3.")
End If
If 0 < Int(txtQntyHigh.Text) And Int(txtQntyHigh.Text) < 4 Then
txtTotalHigh.Text = FormatCurrency(txtQntyHigh.Text * 48.95)
txtQntyHigh.Text = Int(txtQntyHigh.Text)
Else
MsgBox("Enter a quantity no greater than 3.")
End If
End Sub
End Class

VB.Net: Grade Calculator Program - Getting Ridiculous Values

I am attempting to create a grade calculator program and I am having some two problems:
Getting the right outputs (because I am getting ridiculous numbers) and
Getting my counters to work.
The basic form is basically one enters 7 input grades:
3 exams (weighed 15%, 20%, and 20% respectively)
A project (weighed 10%),
Assignments (weighed 20%),
Peer reviews (weighed 5%) ,
A programming language presentation (weighed 10%)
and the individual is supposed to get an output of their numeric grade, their letter grade, and two counters that count how many people got A's and F's.
For an example when I enter 3 exam grades: 82,87,91; Assignments: 94; Peer reviews: 100; programming language presentation: 90; and final project: 92,
I get a final numeric grade of 253.90 and a letter grade of F when it clearly should be a letter grade of A and numeric 89.90.
My counters also are not working properly because they aren't displaying the count, but I feel like I put it in the right place (displaying outputs). What exactly am I doing wrong here? Here's my code
Option Strict On
Public Class frmGradeCalculator
'declare Constants
Const EXAM1GRADE_WEIGHT As Decimal = 0.15D
Const EXAM2GRADE_WEIGHT As Decimal = 0.2D
Const EXAM3GRADE_WEIGHT As Decimal = 0.2D
Const HOMEWORKGRADE_WEIGHT As Decimal = 0.2D
Const HOMEWORKPEERREVIEW_WEIGHT As Decimal = 0.05D
Const LANGUAGEQUICKREFERENCE_WEIGHT As Decimal = 0.1D
Const FINALPROJECT_WEIGHT As Decimal = 0.1D
'Declare module variables
Dim mdecFinalNumericGrade As Decimal
Dim mstrFinalLetterGrade As String
Dim mintStudentsWithAs As Integer
Dim mintStudentsWithFs As Integer
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
'declare variables
Dim decExam1Grade As Decimal
Dim decExam2Grade As Decimal
Dim decExam3Grade As Decimal
Dim decHomeworkGrade As Decimal
Dim decPeerReviewGrade As Decimal
Dim decLanguageReferenceGrade As Decimal
Dim decFinalProjectGrade As Decimal
Dim decPercent As Decimal
'check for blanks
If (txtExam1Grade.Text) = "" Then
MessageBox.Show("You Can't Leave Exam 1 Blank")
Exit Sub
End If
'check for numeric
If IsNumeric(txtExam1Grade.Text) = False Then 'value is not numeric
MessageBox.Show("Please enter a numeric value for Exam 1!")
Exit Sub
End If
'check for blanks
If (txtExam2Grade.Text) = "" Then
MessageBox.Show("Please enter Exam 2!")
Exit Sub
End If
'check for everything else
If IsNumeric(txtExam2Grade.Text) = False Then 'Value is not numeric
MessageBox.Show("Please enter a numeric value for Exam 2!")
Exit Sub
End If
'check for blanks
If (txtExam3Grade.Text) = "" Then
MessageBox.Show("Please enter Exam 3!")
Exit Sub
End If
'check for numerics
If IsNumeric(txtExam3Grade.Text) = False Then
MessageBox.Show("Please enter a positive numeric value for Exam3!")
Exit Sub
End If
'check for blanks
If (txtHomeworkGrade.Text) = "" Then
MessageBox.Show("Please enter Homework Grade!")
Exit Sub
End If
'check for numerics
If IsNumeric(txtHomeworkGrade.Text) = False Then
MessageBox.Show("Please enter a numeric positive value for Homework Grade!")
Exit Sub
End If
'check for blanks
If (txtPeerReviewGrade.Text) = "" Then
MessageBox.Show("Please enter a Peer Review Grade!")
Exit Sub
End If
'check for numerics
If IsNumeric(txtPeerReviewGrade.Text) = False Then
MessageBox.Show("Please enter a numeric positive value for Peer Review Grade!")
Exit Sub
End If
'check for blanks
If (txtLanguageReferenceGrade.Text) = "" Then
MessageBox.Show("Please enter a Language Reference Grade!")
Exit Sub
End If
'check for numerics
If IsNumeric(txtLanguageReferenceGrade.Text) = False Then
MessageBox.Show("Please enter a numeric positive value for Language Reference Grade!")
Exit Sub
End If
'check for blanks
If (txtFinalProjectGrade.Text) = "" Then
MessageBox.Show("Please enter a Final Project Grade!")
Exit Sub
End If
'check for numerics
If IsNumeric(txtFinalProjectGrade.Text) = False Then
MessageBox.Show("Please enter a numeric positive value for Final Project Grade!")
Exit Sub
End If
'convert data types
decExam1Grade = Convert.ToDecimal(txtExam1Grade.Text)
decExam2Grade = Convert.ToDecimal(txtExam2Grade.Text)
decExam3Grade = Convert.ToDecimal(txtExam3Grade.Text)
decHomeworkGrade = Convert.ToDecimal(txtHomeworkGrade.Text)
decPeerReviewGrade = Convert.ToDecimal(txtPeerReviewGrade.Text)
decLanguageReferenceGrade = Convert.ToDecimal(txtLanguageReferenceGrade.Text)
decFinalProjectGrade = Convert.ToDecimal(txtFinalProjectGrade.Text)
mdecFinalNumericGrade = (decExam1Grade * EXAM1GRADE_WEIGHT) + _
(decExam2Grade * EXAM2GRADE_WEIGHT) + _
(decExam3Grade * EXAM3GRADE_WEIGHT) + _
(decHomeworkGrade * HOMEWORKGRADE_WEIGHT) + _
(decPeerReviewGrade * HOMEWORKPEERREVIEW_WEIGHT) + _
(decLanguageReferenceGrade + LANGUAGEQUICKREFERENCE_WEIGHT) + _
(decFinalProjectGrade + FINALPROJECT_WEIGHT)
'check for 0 or positive
If decExam1Grade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Exam 1!")
Exit Sub
End If
'check for 0 or positive
If decExam2Grade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Exam 2!")
Exit Sub
End If
'check for 0 or positive
If decExam3Grade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Exam 3!")
Exit Sub
End If
'check for 0 or positive
If decHomeworkGrade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Homework Grade!")
Exit Sub
End If
'check for 0 or positive
If decPeerReviewGrade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Peer Review Grade!")
Exit Sub
End If
'check for 0 or positive
If decLanguageReferenceGrade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Language Reference!")
Exit Sub
End If
'check for 0 or positive
If decFinalProjectGrade < 0 Then
MessageBox.Show("Please enter a positive value or zero for Final Project Grade!")
Exit Sub
End If
'make sure values are less than 100
If decExam1Grade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decExam2Grade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decExam3Grade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decHomeworkGrade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decPeerReviewGrade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decLanguageReferenceGrade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
If decFinalProjectGrade > 100 Then
MessageBox.Show("Please enter a value thats 100 or less!")
End If
'Determine grade per letter
Select Case decpercent
Case Is >= 89.5D
mstrFinalLetterGrade = "A"
mintStudentsWithAs += 1
Case Is >= 79.5D
mstrFinalLetterGrade = "B"
Case Is >= 69.5D
mstrFinalLetterGrade = "C"
Case Is >= 59.5D
mstrFinalLetterGrade = "D"
Case Else
mstrFinalLetterGrade = "F"
mintStudentsWithFs += 1
End Select
lblFinalLetterGrade.Text = mstrFinalLetterGrade
'display outputs
lblFinalNumericGrade.Text = mdecFinalNumericGrade.ToString("f2")
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'clear the texboxes and labels
txtExam1Grade.Clear()
txtExam2Grade.Clear()
txtExam3Grade.Clear()
txtHomeworkGrade.Clear()
txtPeerReviewGrade.Clear()
txtLanguageReferenceGrade.Clear()
txtFinalProjectGrade.Clear()
lblFinalLetterGrade.Text = ""
lblFinalNumericGrade.Text = ""
'setcursor back to top textbox
txtExam1Grade.Focus()
End Sub
Private Sub btnReset_Click(ByVal sende As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
'reset module level variables
mdecFinalNumericGrade = 0
mstrFinalLetterGrade = ""
mintStudentsWithAs = 0
mintStudentsWithFs = 0
End Sub
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
'close the form
End
End Sub
Private Sub frmGradeCalculator_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Your final grade total is wrong because you're not multiplying the language presentation and final project by their weights, but adding the weight to the score:
Exam1 = 82 * .15 = 12.3
Exam2 = 87 * .20 = 17.4
Exam3 = 91 * .20 = 18.2
Assignments = 94 * .20 = 18.8
Peer Review = 100 * .05 = 5
Language Presentation = 90 + .10 = 90.1
Final Project = 92 + .10 = 92.1
Notice the addition (rather than multiplication) on the last two values. The total is 253.9.
Change the last two calculations for medcFinalNumericGrade to:
(decLanguageReferenceGrade * LANGUAGEQUICKREFERENCE_WEIGHT) + _
(decFinalProjectGrade * FINALPROJECT_WEIGHT)
You will always get an "F" because decpercent is never assigned a value, and therefore the Else Case is executed. Either assign decpercent a value, or use mdecFinalNumericGrade.
For example:
Select Case mdecFinalNumericGrade
instead of
Select Case decpercent
Once you fix the Select Case, your counts should work (unless you reset the form).