Question

so im trying to make a grade program and idk what im doing wrong actually if...

so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them


Option Strict On
Option Explicit On
Public Class Form1
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Dim lblscore1 As Double
Dim lblscore2 As Double
Dim lblscore3 As Double

lblscore1 = CDbl(Txtscore1.Text)
lblscore2 = CDbl(Txtscore2.Text)
lblscore3 = CDbl(Txtscore3.Text)

lblaverage = Txtscore1 + Txtscore2 + Txtscore3 / 3

txtaverage.Text = lblaverage.ToString("n2")

'This is an If/Else statement that allows the user to
'convert their number grade into a letter grade
txtgrade.Text = numbergrade
lblgrade.Text = lettergrade

If (numbergrade >= 90 Or numbergrade <= 100) Then
lettergrade = "A"
ElseIf (numbergrade >= 80 Or numbergrade <= 79) Then
lettergrade = "B"
ElseIf (numbergrade >= 70 Or numbergrade <= 89) Then
lettergrade = "C"
ElseIf (numbergrade >= 60 Or numbergrade <= 69) Then
lettergrade = "D"
ElseIf (numbergrade >= 50 Or numbergrade <= 59) Then
lettergrade = "F"
End If
txtgrade.Focus()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Close()
End Sub

Private Sub btnclear_Click(sender As Object, e As EventArgs) Handles btnclear.Click

End Sub

Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles txtgrade.TextChanged


MessageBox.Show("Invalid Input", "Error")

End Sub
End Class

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in VB is created using Visual Studio 2017 with name "VB_GradeProgram".This application contains a form with name "Form1.vb".Below are the files associated with form1.

Solution Explorer :

Solution Explorer Search Solution Explorer (Ctri+) SolutionVB-Gradeprogram (1 project) VE VB_GradeProgram My Project Refere

1.Form1.vb[Design]

Student Grade Score 1 Score 2 Score 3 Calculate Exit Clear Average

2.Form1.Designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.lblScore1 = New System.Windows.Forms.Label()
Me.Txtscore1 = New System.Windows.Forms.TextBox()
Me.lblScore2 = New System.Windows.Forms.Label()
Me.lblScore3 = New System.Windows.Forms.Label()
Me.Txtscore2 = New System.Windows.Forms.TextBox()
Me.Txtscore3 = New System.Windows.Forms.TextBox()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.txtaverage = New System.Windows.Forms.TextBox()
Me.lblgrade = New System.Windows.Forms.Label()
Me.txtgrade = New System.Windows.Forms.TextBox()
Me.btnExit = New System.Windows.Forms.Button()
Me.btnClear = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'lblScore1
'
Me.lblScore1.AutoSize = True
Me.lblScore1.Location = New System.Drawing.Point(25, 41)
Me.lblScore1.Name = "lblScore1"
Me.lblScore1.Size = New System.Drawing.Size(44, 13)
Me.lblScore1.TabIndex = 0
Me.lblScore1.Text = "Score 1"
'
'Txtscore1
'
Me.Txtscore1.Location = New System.Drawing.Point(101, 38)
Me.Txtscore1.Name = "Txtscore1"
Me.Txtscore1.Size = New System.Drawing.Size(100, 20)
Me.Txtscore1.TabIndex = 1
'
'lblScore2
'
Me.lblScore2.AutoSize = True
Me.lblScore2.Location = New System.Drawing.Point(25, 86)
Me.lblScore2.Name = "lblScore2"
Me.lblScore2.Size = New System.Drawing.Size(44, 13)
Me.lblScore2.TabIndex = 2
Me.lblScore2.Text = "Score 2"
'
'lblScore3
'
Me.lblScore3.AutoSize = True
Me.lblScore3.Location = New System.Drawing.Point(25, 122)
Me.lblScore3.Name = "lblScore3"
Me.lblScore3.Size = New System.Drawing.Size(44, 13)
Me.lblScore3.TabIndex = 3
Me.lblScore3.Text = "Score 3"
'
'Txtscore2
'
Me.Txtscore2.Location = New System.Drawing.Point(101, 79)
Me.Txtscore2.Name = "Txtscore2"
Me.Txtscore2.Size = New System.Drawing.Size(100, 20)
Me.Txtscore2.TabIndex = 4
'
'Txtscore3
'
Me.Txtscore3.Location = New System.Drawing.Point(101, 119)
Me.Txtscore3.Name = "Txtscore3"
Me.Txtscore3.Size = New System.Drawing.Size(100, 20)
Me.Txtscore3.TabIndex = 5
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(12, 158)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(91, 30)
Me.btnCalculate.TabIndex = 6
Me.btnCalculate.Text = "&Calculate"
Me.btnCalculate.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(25, 208)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(47, 13)
Me.Label1.TabIndex = 7
Me.Label1.Text = "Average"
'
'txtaverage
'
Me.txtaverage.Location = New System.Drawing.Point(101, 201)
Me.txtaverage.Name = "txtaverage"
Me.txtaverage.Size = New System.Drawing.Size(100, 20)
Me.txtaverage.TabIndex = 8
'
'lblgrade
'
Me.lblgrade.AutoSize = True
Me.lblgrade.Location = New System.Drawing.Point(133, 251)
Me.lblgrade.Name = "lblgrade"
Me.lblgrade.Size = New System.Drawing.Size(0, 13)
Me.lblgrade.TabIndex = 9
'
'txtgrade
'
Me.txtgrade.Location = New System.Drawing.Point(22, 248)
Me.txtgrade.Name = "txtgrade"
Me.txtgrade.ReadOnly = True
Me.txtgrade.Size = New System.Drawing.Size(81, 20)
Me.txtgrade.TabIndex = 10
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(189, 158)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(71, 30)
Me.btnExit.TabIndex = 11
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(109, 158)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(71, 30)
Me.btnClear.TabIndex = 12
Me.btnClear.Text = "C&lear"
Me.btnClear.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(272, 295)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.txtgrade)
Me.Controls.Add(Me.lblgrade)
Me.Controls.Add(Me.txtaverage)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnCalculate)
Me.Controls.Add(Me.Txtscore3)
Me.Controls.Add(Me.Txtscore2)
Me.Controls.Add(Me.lblScore3)
Me.Controls.Add(Me.lblScore2)
Me.Controls.Add(Me.Txtscore1)
Me.Controls.Add(Me.lblScore1)
Me.Name = "Form1"
Me.Text = "Student Grade"
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub

Friend WithEvents lblScore1 As Label
Friend WithEvents Txtscore1 As TextBox
Friend WithEvents lblScore2 As Label
Friend WithEvents lblScore3 As Label
Friend WithEvents Txtscore2 As TextBox
Friend WithEvents Txtscore3 As TextBox
Friend WithEvents btnCalculate As Button
Friend WithEvents Label1 As Label
Friend WithEvents txtaverage As TextBox
Friend WithEvents lblgrade As Label
Friend WithEvents txtgrade As TextBox
Friend WithEvents btnExit As Button
Friend WithEvents btnClear As Button
End Class

3.Form1.vb

Option Strict On
Option Explicit On
Public Class Form1
'Calculate Button click
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
'Declaring variables
Dim lblscore1 As Double
Dim lblscore2 As Double
Dim lblscore3 As Double
Dim lblaverage As Double
Dim numbergrade As Double
Dim lettergrade As String = ""
'taking values entered by user
lblscore1 = CDbl(Txtscore1.Text) 'score 1
lblscore2 = CDbl(Txtscore2.Text) 'score 2
lblscore3 = CDbl(Txtscore3.Text) 'score 3
'calculate average
lblaverage = (lblscore1 + lblscore2 + lblscore3) / 3
'display average in the textbox
txtaverage.Text = lblaverage.ToString("n2")
'round average
numbergrade = Math.Round(lblaverage)
'This is an If/Else statement that allows the user to
'convert their number grade into a letter grade
'checking letter grade
If (numbergrade >= 90 And numbergrade <= 100) Then
lettergrade = "A" 'lettergrade is A
ElseIf (numbergrade >= 80 And numbergrade <= 89) Then
lettergrade = "B" 'lettergrade is B
ElseIf (numbergrade >= 70 And numbergrade <= 79) Then
lettergrade = "C" 'lettergrade is C
ElseIf (numbergrade >= 60 And numbergrade <= 69) Then
lettergrade = "D" 'lettergrade is D
ElseIf (numbergrade >= 50 And numbergrade <= 59) Then
lettergrade = "F" 'lettergrade is F
End If
txtgrade.Focus() 'set the focus
txtgrade.Text = numbergrade.ToString() 'display numbergrade
lblgrade.Text = lettergrade 'display lettergrade
End Sub
'clear button click
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
Txtscore1.Text = ""
Txtscore2.Text = ""
Txtscore3.Text = ""
txtaverage.Text = ""
txtgrade.Text = ""
lblgrade.Text = ""
End Sub
'Exit button click
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Student Grade Score 1 Score 2 Score 3 Calculate Exit Clear Average

Screen 2 :

Student Grade Score 1 70 Score 2 90 Score 3 20 Calculate Clear Exit 60.00 Average

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
so im trying to make a grade program and idk what im doing wrong actually if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this problem in Visual Basic 2012: Write a program that allows the...

    I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...

  • WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING,...

    WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...

  • The Murach's Visual Basic 2015 Book And Visual Studio Exercise 7-2 Enhance the Invoice Total application...

    The Murach's Visual Basic 2015 Book And Visual Studio Exercise 7-2 Enhance the Invoice Total application If you did exercise 6-1 in the last chapter, this exercise asks you to add data validation and exception handling to it. 1. Copy the Invoice Total application from your C:\VB 2015\Chapter 06 directory to your Chapter 07 directory. This should be your solution to exercise 6-1 of the last chapter. 2. If your application has both a Sub procedure and a Function procedure...

  • Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim...

    Public Class Form1     Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click         Dim room As Double 'Assigns room as double         Dim rate As Double 'Assigns rate as double         Dim room2 As Double 'Assigns room as double         Dim overallRate As Double 'Assigns overall as double         Dim a As Integer 'Assign a as an integer         For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors             With...

  • Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game si...

    Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game simulates a card game where the cards a placed face down and the player flips over pairs of cards in an attempt to find matching cards.   Program Procedure Display a 4x4 grid of “face down” cards. Assign the letters A through H randomly to the cards in pairs. Allow the user to click on a card to “flip” it over and...

  • I am new to programming (2 weeks of playing with it) I have written code for...

    I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...

  • Program using visual basic.net You will create a very simple two numbers calculator with save options;...

    Program using visual basic.net You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels 1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in [] a- "First Number" [textbox] b- "Second number" [texbox] c- "Result" [textbox] -...

  • Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the...

    Zander Inc. stores employee IDs and salaries in a sequential access file named Employees.txt. Open the VB2015\Chap10\Zander Solution\Zander Solution (Zander Solution.sln) file. Open the Employees.txt file, which is contained in the project’s bin\Debug folder. The ID and salary information appear on separate lines in the file. Close the Employees.txt window. a. Define a structure named Employee. The structure should contain two member variables: a String variable to store the ID and a Double variable to store the salary. b. Declare...

  • I really need some help fixing a code error in Visual Basic I was wondering if...

    I really need some help fixing a code error in Visual Basic I was wondering if anyone could help fix the error that I'm about to provide in bold thanks so much! I'll also tell what the error is. Public Class MainForm Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click Me.Close() End Sub Dim img As Image = Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg") house1PictureBox.Image = img house2PictureBox.Image = img house3PictureBox.Image = img house4PictureBox.Image = img house1PictureBox.Visible = False house2PictureBox.Visible = False house3PictureBox.Visible...

  • Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the valu...

    Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT