| | |
Letter Grade Array
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2007
Posts: 58
Reputation:
Solved Threads: 0
I need to average the numbers in the array and display and also detemine the letter grade and display. I've managed to average the numbers but I am unable to display the lettergrade, (won't compile) I think it has to do with "Average Grade" being a constant string
This is the error I get "Conversion from string "Average grade: " to type 'Double' is not valid."
Please Help! Thank You.
This is the error I get "Conversion from string "Average grade: " to type 'Double' is not valid."
Please Help! Thank You.
vb Syntax (Toggle Plain Text)
Public Class Form1 Dim grades(0 To 4) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim prompt, title As String Dim i As Short prompt = "Enter the grade" For i = 0 To UBound(grades) title = "Grade " & (i + 1) grades(i) = InputBox(prompt, title) Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim letterGrade As String Dim result As String Dim i As Short Dim total As Single = 0 result = "High temperatures for the week:" & vbCrLf & vbCrLf For i = 0 To UBound(grades) result = result & "Day " & (i + 1) & vbTab & _ grades(i) & vbCrLf total = total + grades(i) Next result = result & vbCrLf & _ "Average grade: " & Format(total / 5, "0.0") If "Average grade: " >= 90 Then letterGrade = "A" ElseIf "Average grade: " >= 80 Then letterGrade = "B" ElseIf "Average grade: " >= 70 Then letterGrade = "C" ElseIf "Average grade: " >= 60 Then letterGrade = "D" Else letterGrade = "F" End If result = result & vbCrLf & _ "Letter Grade: " & Format(letterGrade) TextBox1.Text = result End Sub
Here you made mistake.
change
as
change
VB Syntax (Toggle Plain Text)
If "Average grade: " >= 90 Then letterGrade = "A" ElseIf "Average grade: " >= 80 Then letterGrade = "B" ElseIf "Average grade: " >= 70 Then letterGrade = "C" ElseIf "Average grade: " >= 60 Then letterGrade = "D" Else letterGrade = "F" End If
as
VB Syntax (Toggle Plain Text)
If total >= 90 Then letterGrade = "A" ElseIf total >= 80 Then letterGrade = "B" ElseIf total >= 70 Then letterGrade = "C" ElseIf total >= 60 Then letterGrade = "D" Else letterGrade = "F" End If
KSG
![]() |
Similar Threads
- help...one-dimensional array averaging program (C++)
- Help with an Array GRading assignment (Java)
- struct array and enum problems (C++)
- Array troubles? (C++)
- Simple array/class problem (dot operator)??? (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Embedding Batch Files?
- Next Thread: ReportViewer.. Help me pleeeeease
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons center check code combobox component connectionstring crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images insert intel internet listview login mobile monitor ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial soap sql string table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





